emacs-ipython-notebook/test/test-ein-worksheet-notebook.el
John Miller 9d5309af59 Trying something new with testing.
Let's do this with ert-runner instead of python. Maybe it will work for once.
2018-02-27 14:38:13 -06:00

47 lines
1.9 KiB
EmacsLisp
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(eval-when-compile (require 'cl))
(require 'ert)
(require 'ein-notebook)
(require 'ein-testing-notebook)
;;; Event handler
(defun ein:testing-worksheet-set-dirty
(pre-dirty value post-dirty fired-in)
(with-current-buffer (ein:testing-make-notebook-with-outputs '(nil))
(when pre-dirty
(ein:cell-goto (ein:worksheet-get-current-cell))
(insert "something"))
(should (equal (ein:worksheet-modified-p ein:%worksheet%) pre-dirty))
(with-current-buffer (funcall fired-in)
(let ((events (oref ein:%worksheet% :events))
(cell (ein:worksheet-get-current-cell)))
(ein:events-trigger events 'set_dirty.Worksheet
(list :cell cell :value value))))
(should (equal (ein:worksheet-modified-p ein:%worksheet%) post-dirty))))
(defun ein:testing-scratchsheet-buffer ()
(ein:worksheet-buffer (ein:notebook-scratchsheet-open ein:%notebook%)))
(defmacro ein:testing-worksheet-set-dirty-deftest
(pre-dirty value post-dirty &optional fired-in)
(let ((name (intern (format "ein:worksheet-set-dirty/%s-to-%s-fired-in-%s"
pre-dirty value
(or fired-in "current-buffer"))))
(fired-in-defun
(case fired-in
(scratchsheet 'ein:testing-scratchsheet-buffer)
(t 'current-buffer))))
`(ert-deftest ,name ()
(ein:testing-worksheet-set-dirty ,pre-dirty ,value ,post-dirty
#',fired-in-defun))))
(ein:testing-worksheet-set-dirty-deftest t nil nil)
(ein:testing-worksheet-set-dirty-deftest t t t )
(ein:testing-worksheet-set-dirty-deftest nil nil nil)
(ein:testing-worksheet-set-dirty-deftest nil t t )
(ein:testing-worksheet-set-dirty-deftest t nil t scratchsheet)
(ein:testing-worksheet-set-dirty-deftest t t t scratchsheet)
(ein:testing-worksheet-set-dirty-deftest nil nil nil scratchsheet)
(ein:testing-worksheet-set-dirty-deftest nil t nil scratchsheet)