emacs-ipython-notebook/tests/test-ein-autoexec.el
2012-07-22 17:40:35 +02:00

43 lines
1.5 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-autoexec)
(require 'test-ein-cell-notebook)
;;; `ein:autoexec-should-execute-p'
(defun* eintest:autoexec-should-execute-p (cell &key (this-command t) beg end)
"Simple wrapper for `ein:autoexec-should-execute-p' which
returns `t' by default, if the CELL is code cell."
(unless beg (setq beg (ein:cell-input-pos-min cell)))
(unless end (setq end (ein:cell-input-pos-max cell)))
(ein:autoexec-should-execute-p cell beg end))
;; cell types
(ert-deftest ein:autoexec-should-execute-p-codecell ()
(eintest:with-one-cell 'code
(should (eintest:autoexec-should-execute-p cell))))
(ert-deftest ein:autoexec-should-execute-p-markdowncell ()
(eintest:with-one-cell 'markdown
(should-not (eintest:autoexec-should-execute-p cell))))
(ert-deftest ein:autoexec-should-execute-p-dead-cell ()
(eintest:with-one-cell 'code
(should-not (eintest:autoexec-should-execute-p (ein:cell-copy cell)))))
;; other
(ert-deftest ein:autoexec-should-execute-p-non-interactive ()
(eintest:with-one-cell 'code
(should-not (eintest:autoexec-should-execute-p cell :this-command nil))))
(ert-deftest ein:autoexec-should-execute-p-beg-too-small ()
(eintest:with-one-cell 'code
(should-not (eintest:autoexec-should-execute-p cell :beg (point-min)))))
(ert-deftest ein:autoexec-should-execute-p-end-too-big ()
(eintest:with-one-cell 'code
(should-not (eintest:autoexec-should-execute-p cell :end (point-max)))))