From 8dda6cbe17324cf8aed55a21ac0a23fc5a5a0391 Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Thu, 5 Jun 2025 00:11:35 +0300 Subject: [PATCH 1/2] tests: factor out indentation testing, where before == after --- tests/purescript-indentation-tests.el | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/purescript-indentation-tests.el b/tests/purescript-indentation-tests.el index c3fd10f..2a885b7 100644 --- a/tests/purescript-indentation-tests.el +++ b/tests/purescript-indentation-tests.el @@ -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) @@ -210,15 +218,11 @@ type MyRec = { data :: Number (ert-deftest func-with-do () :expected-result :failed - (purescript-test-indentation " -foo :: Foo -foo = do - pure unit" - -" + (purescript-test-indentation-expected-only " foo :: Foo foo = do - pure unit")) + pure unit +")) (ert-deftest do-bindings () :expected-result :failed @@ -267,13 +271,7 @@ 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 " -fun = case _ of - [ a - , b ] -" - -" + (purescript-test-indentation-expected-only " fun = case _ of [ a , b ] From 073e742cfe57615c3498db67ba73d5cb2c8ae77e Mon Sep 17 00:00:00 2001 From: Konstantin Kharlamov Date: Thu, 5 Jun 2025 00:13:33 +0300 Subject: [PATCH 2/2] tests: test multiline function type declarations --- tests/purescript-indentation-tests.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/purescript-indentation-tests.el b/tests/purescript-indentation-tests.el index 2a885b7..c058d67 100644 --- a/tests/purescript-indentation-tests.el +++ b/tests/purescript-indentation-tests.el @@ -276,3 +276,20 @@ 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 +"))