|
31 | 31 | (require 'haskell-decl-scan)
|
32 | 32 | (require 'haskell-test-utils)
|
33 | 33 |
|
| 34 | +(ert-deftest haskell-ds-line-commented-p-1 () |
| 35 | + "All lines in this buffer should count as comments" |
| 36 | + (with-temp-buffer |
| 37 | + (haskell-mode) |
| 38 | + (insert-lines "" "--hi" " -- hi\t " "" "{-hi-}" " \t{-hi-} ") |
| 39 | + (font-lock-fontify-buffer) |
| 40 | + (goto-char (point-min)) |
| 41 | + |
| 42 | + (while (not (eobp)) |
| 43 | + (should (haskell-ds-line-commented-p)) |
| 44 | + (forward-line)))) |
| 45 | + |
| 46 | +(ert-deftest haskell-ds-comment-p-1 () |
| 47 | + "All characters in this buffer should count as comments" |
| 48 | + (with-temp-buffer |
| 49 | + (haskell-mode) |
| 50 | + (insert-lines "" "--hi" " -- hi\t " "" "{-hi-}" " \t{-hi-} ") |
| 51 | + (font-lock-fontify-buffer) |
| 52 | + (goto-char (point-min)) |
| 53 | + |
| 54 | + (while (not (bobp)) |
| 55 | + (should (haskell-ds-comment-p)) |
| 56 | + (forward-char)))) |
| 57 | + |
34 | 58 | (ert-deftest haskell-ds-backward-decl-1 ()
|
35 | 59 | "Test running haskell-ds-backward-decl"
|
36 | 60 | (with-temp-buffer
|
|
44 | 68 | (should-not (haskell-ds-backward-decl))
|
45 | 69 | (should (= (point-min) (point)))))
|
46 | 70 |
|
| 71 | +(ert-deftest haskell-ds-backward-decl-2-commented () |
| 72 | + "Test running haskell-ds-backward-decl" |
| 73 | + (with-temp-buffer |
| 74 | + (haskell-mode) |
| 75 | + (insert-lines "" "-- documentation" "fun :: Int -> Int" |
| 76 | + "" "{- comment -}" "fun = id" |
| 77 | + "" " -- space comment" "f2 :: Int" |
| 78 | + "" " {- trailing -} \t" "f2 = 3" |
| 79 | + "" "" "") |
| 80 | + (font-lock-fontify-buffer) |
| 81 | + (goto-char (point-max)) |
| 82 | + |
| 83 | + (should (haskell-ds-backward-decl)) |
| 84 | + (should (looking-at-p "f2 :: Int")) |
| 85 | + |
| 86 | + (should (haskell-ds-backward-decl)) |
| 87 | + (should (looking-at-p "fun :: Int -> Int")) |
| 88 | + |
| 89 | + (should-not (haskell-ds-backward-decl)) |
| 90 | + (should (bobp)))) |
| 91 | + |
47 | 92 | (ert-deftest haskell-ds-backward-decl-2 ()
|
48 | 93 | "Test running haskell-ds-backward-decl"
|
49 | 94 | (with-temp-buffer
|
|
92 | 137 | (should (= (point) (save-excursion (goto-line 13) (point))))
|
93 | 138 | (should (= (point-max) (progn (haskell-ds-forward-decl) (point))))))
|
94 | 139 |
|
| 140 | +(ert-deftest haskell-ds-forward-decl-2-commented () |
| 141 | + "Test running haskell-ds-backward-decl" |
| 142 | + (with-temp-buffer |
| 143 | + (haskell-mode) |
| 144 | + (insert-lines "" "-- documentation" "fun :: Int -> Int" |
| 145 | + "" "{- comment -}" "fun = id" |
| 146 | + "" " -- space comment" "f2 :: Int" |
| 147 | + "" " {- trailing -} \t" "f2 = 3" |
| 148 | + "" "" "") |
| 149 | + (font-lock-fontify-buffer) |
| 150 | + (goto-char (point-min)) |
| 151 | + |
| 152 | + (should (haskell-ds-forward-decl)) |
| 153 | + (should (looking-at-p "$")) |
| 154 | + (should (= (point) (save-excursion (goto-line 7) (point)))) |
| 155 | + |
| 156 | + (should (haskell-ds-forward-decl)) |
| 157 | + (should (looking-at-p "f2 :: Int")) |
| 158 | + |
| 159 | + (should (haskell-ds-forward-decl)) |
| 160 | + (should (= (point) (save-excursion (goto-line 13) (point)))) |
| 161 | + |
| 162 | + (should (= (point-max) (progn (haskell-ds-forward-decl) (point)))) |
| 163 | + (should (eobp)))) |
| 164 | + |
95 | 165 | (provide 'haskell-decl-scan-tests)
|
96 | 166 |
|
97 | 167 | ;;; haskell-decl-scan-tests.el ends here
|
0 commit comments