Skip to content

Implement tests for indenting function type declarations #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions tests/purescript-indentation-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
(require 'purescript-mode)
(require 'purescript-indentation)

(defun purescript-test-indentation-expected-only (expected)
(with-temp-buffer
(insert expected)
(purescript-mode)
(turn-on-purescript-indentation)
(indent-region (point-min) (point-max))
(should (string= expected (buffer-string)))))

(defun purescript-test-indentation (before after &optional start-line)
(with-temp-buffer
(insert before)
Expand Down Expand Up @@ -210,15 +218,11 @@ type MyRec = { data :: Number

(ert-deftest func-with-do ()
:expected-result :failed
(purescript-test-indentation "
(purescript-test-indentation-expected-only "
foo :: Foo
foo = do
pure unit"

"
foo :: Foo
foo = do
pure unit"))
pure unit
"))

(ert-deftest do-bindings ()
:expected-result :failed
Expand Down Expand Up @@ -267,14 +271,25 @@ test3 a
(ert-deftest comma-first-list-after-case-of ()
"A comma-first list was getting misindented if goes after case-of"
:expected-result :failed
(purescript-test-indentation "
(purescript-test-indentation-expected-only "
fun = case _ of
[ a
, b ]
"
"))

"
fun = case _ of
[ a
, b ]
(ert-deftest multiline-func-decl-arrow-first ()
(purescript-test-indentation-expected-only "
foo ::
∀ a. A
-> B
-> C
"))

(ert-deftest multiline-func-decl-arrow-last ()
(purescript-test-indentation-expected-only "
foo ::
∀ a.
A ->
B ->
C
"))