branch: elpa/forth-mode
commit d1498037a28ceef1cc6479b52d34b29e4eaad5d4
Author: Helmut Eller <[email protected]>
Commit: Helmut Eller <[email protected]>
Add simple tests for forward-sexp
* test/tests.el (forth-sexp-movements): New test
(forth-assert-forward-sexp): New helper.
* fort-smie.el (forth-smie--grammar): Add rule for :noname ... ; so
that forward-sexp works and it "blinks" in the right when point is on it.
---
forth-smie.el | 3 ++-
test/tests.el | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/forth-smie.el b/forth-smie.el
index ae44364ca7..aa6b64a382 100644
--- a/forth-smie.el
+++ b/forth-smie.el
@@ -18,7 +18,8 @@
("do" words "loop")
("do" words "+loop")
("begin-structure" words "end-structure")
- (":" words ";"))
+ (":" words ";")
+ (":noname" words ";"))
(words)))))
(defvar forth-smie--basic-indent 2)
diff --git a/test/tests.el b/test/tests.el
index e9460de9cc..1681a10389 100644
--- a/test/tests.el
+++ b/test/tests.el
@@ -50,6 +50,12 @@ The whitespace before and including \"|\" on each line is
removed."
(should (string= (forth-strip-| expected)
(substring-no-properties (buffer-string))))))))
+(defun forth-assert-forward-sexp (content start end)
+ (forth-with-temp-buffer content
+ (goto-char start)
+ (forward-sexp)
+ (should (= (point) end))))
+
(ert-deftest forth-paren-comment-font-lock ()
(forth-assert-face "( )" 1 font-lock-comment-delimiter-face)
(forth-assert-face ".( )" 1 font-lock-comment-face)
@@ -170,3 +176,8 @@ The whitespace before and including \"|\" on each line is
removed."
| [char] b of bar endof
| drop exit
|endcase"))
+
+(ert-deftest forth-sexp-movements ()
+ (forth-assert-forward-sexp " : foo bar ; \ x" 2 13)
+ (forth-assert-forward-sexp " :noname foo bar ; \ x" 2 19)
+ (forth-assert-forward-sexp " if drop exit else 1+ then bar " 2 27))