Skip to content

Commit 8504a49

Browse files
committed
Define haskell-utils-compose-type-at-command test
1 parent 6f335a2 commit 8504a49

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/haskell-utils-tests.el

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,49 @@
131131
(forward-line 0)
132132
(haskell-utils-parse-import-statement-at-point)))))
133133

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)))))
134179
;;; haskell-utils-tests.el ends here

0 commit comments

Comments
 (0)