|
131 | 131 | (forward-line 0)
|
132 | 132 | (haskell-utils-parse-import-statement-at-point)))))
|
133 | 133 |
|
| 134 | +(ert-deftest type-at-command-composition () |
| 135 | + "Test haskell-utils-compose-type-at-command. |
| 136 | +Test only position conversion to line and column numbers, do not |
| 137 | +test last string compontent, it is used in `:type-at` command to |
| 138 | +provide user friendly output only and could be any string, even |
| 139 | +empty one. Very likely the way how its composed for multilne |
| 140 | +strings will change in future." |
| 141 | + (with-temp-buffer |
| 142 | + (insert-lines "module A where" |
| 143 | + "" |
| 144 | + "int :: Int" |
| 145 | + "int = 369" |
| 146 | + "" |
| 147 | + "act =" |
| 148 | + " do print int" |
| 149 | + " return int") |
| 150 | + (goto-char (point-min)) |
| 151 | + (let (test-a-points |
| 152 | + test-b-points |
| 153 | + test-a-result |
| 154 | + test-b-result) |
| 155 | + ;; go to third line, e.g. `int` definition |
| 156 | + (forward-line 3) |
| 157 | + (setq test-a-points (point)) |
| 158 | + ;; go to at the end of `int` definition, i.e. point stands at whitespace |
| 159 | + (forward-char 3) |
| 160 | + (setq test-a-points `(,test-a-points . ,(point))) |
| 161 | + (goto-char (line-beginning-position)) |
| 162 | + ;; go to do-block line |
| 163 | + (forward-line 3) |
| 164 | + ;; go to `do` keyword beginning |
| 165 | + (forward-char 2) |
| 166 | + (setq test-b-points (point)) |
| 167 | + ;; go to the end of do-block |
| 168 | + (goto-char (point-max)) |
| 169 | + ;; note `insert-line' inserts one extra newline, go up one line |
| 170 | + (forward-line -1) |
| 171 | + (goto-char (line-end-position)) |
| 172 | + (setq test-b-points `(,test-b-points . ,(point))) |
| 173 | + (setq test-a-result |
| 174 | + (haskell-utils-compose-type-at-command test-a-points)) |
| 175 | + (setq test-b-result |
| 176 | + (haskell-utils-compose-type-at-command test-b-points)) |
| 177 | + (should (string-prefix-p ":type-at nil 4 1 4 4" test-a-result)) |
| 178 | + (should (string-prefix-p ":type-at nil 7 3 8 16" test-b-result))))) |
134 | 179 | ;;; haskell-utils-tests.el ends here
|
0 commit comments