Skip to content

Commit dc538f1

Browse files
committed
add tests for goto-error functions
- haskell-goto-next-error - haskell-goto-prev-error - haskell-goto-first-error
1 parent 9eaf461 commit dc538f1

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

tests/haskell-load-tests.el

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
;;; haskell-load-tests.el
2+
3+
;;; Code:
4+
5+
(require 'ert)
6+
(require 'haskell-test-utils)
7+
8+
(require 'haskell-load)
9+
10+
(defun insert-errors ()
11+
(insert "import Control.Applicativ\nimport Data.Mayb\nimport Data.String")
12+
(let ((a (make-overlay 18 36))
13+
(b (make-overlay 54 63)))
14+
(overlay-put a 'haskell-check t)
15+
(overlay-put a 'haskell-msg-type 'error)
16+
(overlay-put a 'haskell-msg "Could not find module ‘Control.Applicativ’\n Perhaps you meant Control.Applicative (from base-4.8.1.0)\n Use -v to see a list of the files searched for.")
17+
(overlay-put b 'haskell-check t)
18+
(overlay-put b 'haskell-msg-type 'error)
19+
(overlay-put b 'haskell-msg "Could not find module ‘Data.Mayb’\n Perhaps you meant\n Data.Maybe (from base-4.8.1.0)\n Data.Map (from containers-0.5.6.2@conta_LKCPrTJwOTOLk4OU37YmeN)\n Use -v to see a list of the files searched for.")))
20+
21+
(ert-deftest goto-first-error-before ()
22+
(with-temp-switch-to-buffer
23+
(insert-errors)
24+
(goto-char 1)
25+
(haskell-goto-first-error)
26+
(should (equal (point) 18))))
27+
28+
(ert-deftest goto-first-error-after ()
29+
(with-temp-switch-to-buffer
30+
(insert-errors)
31+
(goto-char 92)
32+
(haskell-goto-first-error)
33+
(should (equal (point) 18))))
34+
35+
(ert-deftest goto-first-error-between ()
36+
(with-temp-switch-to-buffer
37+
(insert-errors)
38+
(goto-char 37)
39+
(haskell-goto-first-error)
40+
(should (equal (point) 18))))
41+
42+
(ert-deftest goto-next-error-before ()
43+
(with-temp-switch-to-buffer
44+
(insert-errors)
45+
(goto-char 1)
46+
(haskell-goto-next-error)
47+
(should (equal (point) 18))))
48+
49+
(ert-deftest goto-next-error-between ()
50+
(with-temp-switch-to-buffer
51+
(insert-errors)
52+
(goto-char 37)
53+
(haskell-goto-next-error)
54+
(should (equal (point) 54))))
55+
56+
(ert-deftest goto-next-error-after ()
57+
(with-temp-switch-to-buffer
58+
(insert-errors)
59+
(goto-char 64)
60+
(haskell-goto-next-error)
61+
(should (equal (point) 64))))
62+
63+
(ert-deftest goto-prev-error-before ()
64+
(with-temp-switch-to-buffer
65+
(insert-errors)
66+
(goto-char 1)
67+
(haskell-goto-prev-error)
68+
(should (equal (point) 1))))
69+
70+
(ert-deftest goto-prev-error-between ()
71+
(with-temp-switch-to-buffer
72+
(insert-errors)
73+
(goto-char 37)
74+
(haskell-goto-prev-error)
75+
(should (equal (point) 18))))
76+
77+
(ert-deftest goto-prev-error-before ()
78+
(with-temp-switch-to-buffer
79+
(insert-errors)
80+
(goto-char 64)
81+
(haskell-goto-prev-error)
82+
(should (equal (point) 54))))

0 commit comments

Comments
 (0)