branch: elpa/haskell-tng-mode commit 2060f7a4c25d90770e587a49551a1668aea25a2c Author: Tseen She <ts33n....@gmail.com> Commit: Tseen She <ts33n....@gmail.com>
thoughts on indentation testing --- test/haskell-tng-indent-test.el | 31 +++++++++++++++++++++++++++++++ test/haskell-tng-lexer-test.el | 10 ++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/test/haskell-tng-indent-test.el b/test/haskell-tng-indent-test.el new file mode 100644 index 0000000..7c8321d --- /dev/null +++ b/test/haskell-tng-indent-test.el @@ -0,0 +1,31 @@ +;;; haskell-tng-indent-test.el --- Tests for indentation -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Tseen She +;; License: GPL 3 or any later version + +(require 'ert) +(require 's) + +(require 'haskell-tng-mode) + +(require 'haskell-tng-testutils + "test/haskell-tng-testutils.el") + +(ert-deftest haskell-tng-indent-file-tests () + ;; FIXME four kinds of indentation test: + ;; + ;; 1. newline-and-indent when writing code + ;; 2. ... with subsequent indent-line-function cycles + ;; 3. indent-line-function at the beginning of an existing line + ;; 4. ... with subsequent indent-line-function cycles + ;; + ;; Expectations could use lines of | and . to indicate where the + ;; indentation(s) go. 1 and 2 are the most interesting so could be combined + ;; into one test. 3 and 4 could also be combined. + ;; + ;; (should (have-expected-newline-indent (testdata "src/layout.hs"))) + ;; (should (have-expected-indent (testdata "src/layout.hs"))) + + ) + +;;; haskell-tng-indent-test.el ends here diff --git a/test/haskell-tng-lexer-test.el b/test/haskell-tng-lexer-test.el index fcc48e0..1e8044b 100644 --- a/test/haskell-tng-lexer-test.el +++ b/test/haskell-tng-lexer-test.el @@ -1,4 +1,4 @@ -;;; haskell-tng-lexer-test.el --- Tests for navigation and indentation -*- lexical-binding: t -*- +;;; haskell-tng-lexer-test.el --- Tests for the SMIE lexer -*- lexical-binding: t -*- ;; Copyright (C) 2018-2019 Tseen She ;; License: GPL 3 or any later version @@ -12,11 +12,11 @@ "test/haskell-tng-testutils.el") (ert-deftest haskell-tng-lexer-file-tests () - (should (have-expected-forward-lex (testdata "src/medley.hs"))) (should (have-expected-forward-lex (testdata "src/layout.hs"))) + (should (have-expected-forward-lex (testdata "src/medley.hs"))) - (should (have-expected-backward-lex (testdata "src/medley.hs"))) (should (have-expected-backward-lex (testdata "src/layout.hs"))) + (should (have-expected-backward-lex (testdata "src/medley.hs"))) ) (ert-deftest haskell-tng-lexer-state-invalidation-tests () @@ -126,7 +126,9 @@ "ยง") (t (error "Unknown token: '%s' with '%S'" (string (char-before)) - (syntax-before (point))))))) + (progn + (backward-char) + (syntax-after (point)))))))) (defun haskell-tng-lexer-test:tokens (&optional reverse) "Lex the current buffer using SMIE and return the list of lines,