Add test and fix inter-buffer yanking

This commit is contained in:
Takafumi Arakaki 2012-05-16 12:58:59 +02:00
parent b7c5dd4996
commit e1fd1a1364
2 changed files with 18 additions and 2 deletions

View file

@ -263,6 +263,8 @@ is `nil', BODY is executed with any cell types."
((eq arg '-) -2)
(t (1- arg)))))
(clone (ein:cell-copy killed)))
;; Cell can be from another buffer, so reset `ewoc'.
(oset clone :ewoc (ein:$notebook-ewoc ein:notebook))
(ein:notebook-insert-cell-below ein:notebook clone cell)
(ein:cell-goto clone)))

View file

@ -52,10 +52,10 @@
(name . ,name)
(worksheets . [((cells . ,(apply #'vector cells)))])))
(defun eintest:notebook-make-empty ()
(defun eintest:notebook-make-empty (&optional name)
"Make empty notebook and return its buffer."
(eintest:notebook-from-json
(json-encode (eintest:notebook-make-data nil))))
(json-encode (eintest:notebook-make-data nil name))))
(ert-deftest ein:notebook-from-json-simple ()
(with-current-buffer (eintest:notebook-from-json
@ -141,6 +141,20 @@
do (ein:notebook-yank-cell-command))
(should (equal (ein:notebook-ncells ein:notebook) 3)))))
(ert-deftest ein:notebook-yank-cell-command-two-buffers ()
(let (ein:kill-ring ein:kill-ring-yank-pointer)
(with-current-buffer (eintest:notebook-make-empty "NB1")
(ein:notebook-insert-cell-above-command)
(should (equal (ein:notebook-ncells ein:notebook) 1))
(ein:notebook-kill-cell-command)
(should (equal (ein:notebook-ncells ein:notebook) 0))
(flet ((y-or-n-p (&rest ignore) t))
;; FIXME: are there anyway to skip confirmation?
(kill-buffer)))
(with-current-buffer (eintest:notebook-make-empty "NB2")
(ein:notebook-yank-cell-command)
(should (equal (ein:notebook-ncells ein:notebook) 1)))))
(ert-deftest ein:notebook-toggle-cell-type-simple ()
(with-current-buffer (eintest:notebook-make-empty)
(ein:notebook-insert-cell-above-command)