Skip to content

Commit

Permalink
Merge 02c4090 into a5d18da
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldus committed Jan 17, 2016
2 parents a5d18da + 02c4090 commit 4d4af05
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/haskell-utils-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,52 @@ removed."
" TestTest Test test"
(haskell-utils-reduce-string " Test\r\nTest\n Test test"))))

(ert-deftest post-command-hooks ()
"Test commands related `haskell-utils-async-post-command-flag'.
Tests flag updates and `post-command-hook' cleanup."
(with-temp-buffer
;; flag value should be reseted to nil when started watching chages
(setq haskell-utils-async-post-command-flag "non nil")
(haskell-utils-async-watch-changes)
(should (null haskell-utils-async-post-command-flag))
;; now invoke some commands and test flag value
(insert "Hello World!")

;; (should (null haskell-utils-async-post-command-flag))
;; (should (let ((list haskell-utils-async-post-command-flag)
;; command-found)
;; (while list
;; (when (equal #'goto-char (car list))
;; (setq command-found t))
;; (setq list (cdr list)))
;; command-found))

;; check that hook was installed
(should
(let ((list (cl-copy-list post-command-hook))
hook-installed)
(while list
(when (equal #'haskell-utils-async-update-post-command-flag
(car list))
(setq hook-installed t))
(setq list (cdr list)))
hook-installed))

;; check that flag was cleaned up
(haskell-utils-async-stop-watching-changes (current-buffer))
(should (null haskell-utils-async-post-command-flag))


;; check that hook was removed
(should
(not (let ((list (cl-copy-list post-command-hook))
hook-not-cleaned)
(while list
(when (equal #'haskell-utils-async-update-post-command-flag
(car list))
(setq hook-not-cleaned t))
(setq list (cdr list)))
hook-not-cleaned)))
))

;;; haskell-utils-tests.el ends here

0 comments on commit 4d4af05

Please sign in to comment.