Skip to content

Commit

Permalink
Add tests/haskell-indentation-tests.el
Browse files Browse the repository at this point in the history
  • Loading branch information
gracjan committed Mar 22, 2015
1 parent fd5f64a commit d0d4303
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/haskell-indentation-tests.el
@@ -0,0 +1,39 @@
(require 'ert)
(require 'haskell-indentation)
(require 'haskell-mode)
(require 'cl-lib)


(defun haskell-indentation-check-on-last-line (lines expected)
(with-temp-buffer
(haskell-mode)
(haskell-indentation-mode)
;; insert lines
(dolist (line lines)
(insert line)
(insert "\n"))
(forward-line -1)
(let ((indentations (haskell-indentation-find-indentations))
(result "") )

(dotimes (i (1+ (apply #'max indentations)))
(setq result (concat result (if (memq i indentations)
"^" " "))))

(should (equal (car expected) result)))))


(ert-deftest haskell-indentation-check-1 ()
"Check if '{' on its own line gets properly indented"
(haskell-indentation-check-on-last-line
'("function = Record"
" { field = 123 }")
'("^ ^")))

(ert-deftest haskell-indentation-check-2 ()
"Handle underscore in identifiers"
(haskell-indentation-check-on-last-line
'("function = do"
" (_x) <- return ()"
" z")
'("^ ^ ^")))

0 comments on commit d0d4303

Please sign in to comment.