]> git.eshelyaron.com Git - dict.git/commitdiff
TEST: add two test cases
authorEshel Yaron <me@eshelyaron.com>
Fri, 28 Oct 2022 16:01:50 +0000 (19:01 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 5 Nov 2022 17:50:25 +0000 (19:50 +0200)
sweeprolog-tests.el

index 6c872629ceeb03d3e035709bd2b27723c824a44b..4dbc0de137928d60f1f94f51196f994518ba4a45 100644 (file)
   (should (equal (sweeprolog-next-solution) nil))
   (should (equal (sweeprolog-cut-query) t)))
 
+(ert-deftest font-lock ()
+  "Test semantic highlighting of Prolog code."
+  (let ((temp (make-temp-file "sweeprolog-test"
+                              nil
+                              "pl"
+                              ":- module(foo, [foo/1]).
+
+foo(Foo) :- bar.
+")))
+    (find-file-literally temp)
+    (sweeprolog-mode)
+    (should (equal (get-text-property (+ (point-min) 1)
+                                      'font-lock-face)
+                   '(sweeprolog-neck-default-face
+                     sweeprolog-directive-default-face)))
+    (should (equal (get-text-property (+ (point-min) 2)
+                                      'font-lock-face)
+                   '(sweeprolog-directive-default-face)))
+    (should (equal (get-text-property (+ (point-min) 3)
+                                      'font-lock-face)
+                   '(sweeprolog-built-in-default-face
+                     sweeprolog-directive-default-face)))
+    (should (equal (get-text-property (+ (point-min) 9)
+                                      'font-lock-face)
+                   '(sweeprolog-directive-default-face)))
+    (should (equal (get-text-property (+ (point-min) 10)
+                                      'font-lock-face)
+                   '(sweeprolog-identifier-default-face
+                     sweeprolog-directive-default-face)))
+    (should (equal (get-text-property (+ (point-min) 13)
+                                      'font-lock-face)
+                   '(sweeprolog-directive-default-face)))
+    (should (equal (get-text-property (+ (point-min) 16)
+                                      'font-lock-face)
+                   '(sweeprolog-local-default-face
+                     sweeprolog-predicate-indicator-default-face
+                     sweeprolog-directive-default-face)))
+    (should (equal (get-text-property (+ (point-min) 23)
+                                      'font-lock-face)
+                   '(sweeprolog-fullstop-default-face)))
+    (should (equal (get-text-property (+ (point-min) 26)
+                                      'font-lock-face)
+                   '(sweeprolog-head-exported-default-face
+                     sweeprolog-clause-default-face)))
+    (should (equal (get-text-property (+ (point-min) 31)
+                                      'font-lock-face)
+                   '(sweeprolog-singleton-default-face
+                     sweeprolog-clause-default-face)))
+    (should (equal (get-text-property (+ (point-min) 39)
+                                      'font-lock-face)
+                   '(sweeprolog-undefined-default-face
+                     sweeprolog-clause-default-face)))))
+
+(ert-deftest dwim-next-clause ()
+  "Tests inserting a new clause with `sweeprolog-insert-term-dwim'."
+  (with-temp-buffer
+    (sweeprolog-mode)
+    (insert "
+foo :- bar.")
+    (sweeprolog-insert-term-dwim)
+    (should (string= (buffer-string)
+                     "
+foo :- bar.
+foo :- _.
+"))))
 
 (ert-deftest dwim-define-predicate ()
   "Tests defining a new predicate with `sweeprolog-insert-term-dwim'."