Skip to content

Add haskell-simple-indent-tests.el. #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/haskell-simple-indent-tests.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(require 'ert)
(require 'haskell-simple-indent)

(defun find-indent-positions (lines-above-content)
(with-temp-buffer
(dolist (line lines-above-content)
(insert line)
(insert "\n"))
;; cursor is at the beginning of the second line now
(let ((result '()))
(dotimes (i 10)
(haskell-simple-indent)
(setq result (cons (current-column) result)))
(reverse result))))

(ert-deftest find-indent-positions-1 ()
(should (equal '(5 7 10 19 26 32 40 48 56 64)
(find-indent-positions '("main = do putStrLn \"Hello World!\"")))))


(ert-deftest find-indent-positions-2 ()
(should (equal '(8 10 13 20 24 27 32 35 37 45)
(find-indent-positions '("\tx <- return 123 {- This is a comment -}")))))


(ert-deftest find-indent-positions-3 ()
(should (equal '(2 4 6 8 10 12 14 16 24 32)
(find-indent-positions '("a b c d"
" e f g h")))))


(ert-deftest find-indent-positions-4 ()
(should (equal '(2 4 5 8 16 24 32 40 48 56)
(find-indent-positions '("a b c d e f g h"
" long_streak")))))