emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil-matchit 5c43939d01 212/244: Merge pull request #126 f


From: ELPA Syncer
Subject: [nongnu] elpa/evil-matchit 5c43939d01 212/244: Merge pull request #126 from neojski/more-ocaml-tests
Date: Thu, 6 Jan 2022 02:59:02 -0500 (EST)

branch: elpa/evil-matchit
commit 5c43939d014bd312f23c940a6d2f3598d2a452c5
Merge: 96a1aba323 721d0a9c56
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #126 from neojski/more-ocaml-tests
    
    More ocaml tests
---
 tests/evil-matchit-tests.el | 74 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 65 insertions(+), 9 deletions(-)

diff --git a/tests/evil-matchit-tests.el b/tests/evil-matchit-tests.el
index 0e207e331b..e91114d091 100644
--- a/tests/evil-matchit-tests.el
+++ b/tests/evil-matchit-tests.el
@@ -436,22 +436,78 @@
 (ert-deftest evilmi-test-ocaml ()
   (with-temp-buffer
     (require 'tuareg)
-
-    (insert "if foo\n"
-            "then 1 else 2\n")
     (tuareg-mode)
 
+    (defun prepare (&rest text)
+      (progn
+             (erase-buffer)
+             (apply 'insert text)
+             (goto-char (point-min))
+             (font-lock-ensure)))
+
+    (defun expect (text)
+      (progn
+           (insert "|")
+           (should (string= text (thing-at-point 'line)))
+           (delete-backward-char 1)))
+
     (when (fboundp 'font-lock-ensure)
-      (font-lock-ensure)
+      ;; if then
+      ;; TODO: doesn't work if there's no whitespace before if
+      (prepare " if foo then 1 else 2")
 
-      (goto-char (point-min))
+      (evilmi-jump-items)
+      (expect " if foo |then 1 else 2")
 
-      (should (string= "if" (thing-at-point 'word)))
       (evilmi-jump-items)
-      (should (string= "then" (thing-at-point 'word)))
-      ;; jump back
+      (expect " |if foo then 1 else 2")
+
+      ;; parentheses
+      (prepare "let x = (1, 2) in 3")
+
+      (evilmi-jump-items)
+      (expect "let x = (1, 2|) in 3" )
+
+      (evilmi-jump-items)
+      (expect "let x = |(1, 2) in 3" )
+
+      ;; struct end
+      (prepare "module X = struct type t = int end")
+
+      (evilmi-jump-items)
+      (expect "module X = struct type t = int |end" )
+
+      (evilmi-jump-items)
+      (expect "module X = |struct type t = int end" )
+
+      ;; TODO: begin end doesn't seem to be working
+      (prepare "begin 1 end ;;")
+
+      (evilmi-jump-items)
+      (expect "|begin 1 end ;;")
+
+      ;; match with
+      (prepare "let _ = match x with _ -> ()")
+
+      (evilmi-jump-items)
+      (expect "let _ = match x |with _ -> ()" )
+
+      (evilmi-jump-items)
+      (expect "let _ = |match x with _ -> ()" )
+
+      ;; let in
+      (prepare
+         "let () =\n"
+         "  let x = foo in bar")
+
+      (goto-char 10)
+      (expect "|  let x = foo in bar" )
+
+      (evilmi-jump-items)
+      (expect "  let x = foo |in bar" )
+
       (evilmi-jump-items)
-      (should (string= "if" (thing-at-point 'word))))
+      (expect "  |let x = foo in bar" ))
 
     (should (eq major-mode 'tuareg-mode))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]