mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 04:21:24 +00:00
New SES test ses-tests-snake-move-after-entry.
* test/lisp/ses-tests.el (ses-tests-snake-move): New defun, a funny after entry move. (ses-tests-snake-move-after-entry): New test.
This commit is contained in:
parent
d81505a3eb
commit
9d7e7ca715
1 changed files with 61 additions and 1 deletions
|
|
@ -32,7 +32,9 @@
|
|||
(lexical ses--foo)
|
||||
(lexical ses--bar)
|
||||
(lexical B2)
|
||||
(lexical ses--toto))
|
||||
(lexical ses--toto)
|
||||
(lexical ses-row)
|
||||
(lexical ses-col))
|
||||
(defvar ses--cells)
|
||||
(defvar A2)
|
||||
(defvar A3)
|
||||
|
|
@ -304,6 +306,64 @@ cell has to be rewritten to data area."
|
|||
(should (equal (ses-cell-references 1 1) '(B3)))))
|
||||
(ses-tests-check-no-border-effect))
|
||||
|
||||
(defun ses-tests-snake-move (count)
|
||||
"Move like a snake.
|
||||
|
||||
left to right on even rows, and right to left on odd row. Go next row
|
||||
assuming a four columns sheet."
|
||||
(if (evenp ses-row)
|
||||
(if (= ses-col 3)
|
||||
(next-line count)
|
||||
(forward-char count))
|
||||
(if (= ses-col 0)
|
||||
(next-line count)
|
||||
(backward-char count))))
|
||||
|
||||
(ert-deftest ses-tests-snake-move-after-entry ()
|
||||
"\
|
||||
Test `ses-after-entry-functions' hook.
|
||||
Integers are input to a sheet with a snake pattern using the
|
||||
`ses-tests-snake-move' as a `ses-after-entry-functions' hook. As the
|
||||
input is made an expected text area content string is built. The test
|
||||
verdict is that in the end the sheet text area actually contains what
|
||||
has been built as expected.
|
||||
"
|
||||
(ses-tests-unbind-local-vars)
|
||||
(let ((ses-initial-size '(4 . 4))
|
||||
(ses-after-entry-functions (list #'ses-tests-snake-move))
|
||||
keys ; to input integers interactively to the sES sheet
|
||||
rows cols ; to build reference test vector programmatically
|
||||
)
|
||||
(ert-with-test-buffer (:selected t)
|
||||
(ses-mode)
|
||||
(dotimes (i 16)
|
||||
;; fill the SES sheet with snake move
|
||||
(setq keys (concat (mapconcat #'string (number-to-string i) " ") " RET"))
|
||||
(ert-play-keys keys)
|
||||
;; build the snake move test vector
|
||||
(push i cols)
|
||||
(when (= (logand i 3) 3); when row is complete
|
||||
;; even rows are left to right, so reverse cols in this case.
|
||||
(if (= (logand i 4) 0)
|
||||
(setq cols (nreverse cols)))
|
||||
;; just store the row string
|
||||
(push
|
||||
;; columns are 7 char wide, and there is one extra inter-column space
|
||||
(substring
|
||||
(mapconcat (lambda (i) (format "%8d" i)) cols "")
|
||||
1)
|
||||
rows)
|
||||
;; start a new fresh row
|
||||
(setq cols nil)))
|
||||
(should (string=
|
||||
;; actual sheet content
|
||||
(buffer-substring-no-properties (point-min)
|
||||
(- ses--data-marker 2))
|
||||
;; expected sheet content
|
||||
(mapconcat #'identity (nreverse rows) "\n")))))
|
||||
(ses-tests-check-no-border-effect))
|
||||
|
||||
|
||||
(provide 'ses-tests)
|
||||
|
||||
;;; ses-tests.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue