]> git.eshelyaron.com Git - dict.git/commitdiff
TEST: add unit test for nested Elisp->Prolog->Elisp call chains
authorEshel Yaron <me@eshelyaron.com>
Thu, 6 Oct 2022 19:04:52 +0000 (22:04 +0300)
committerEshel Yaron <me@eshelyaron.com>
Thu, 6 Oct 2022 19:04:52 +0000 (22:04 +0300)
sweeprolog-tests.el

index bb51661d69825b667b9a1e98e207eaa4c5a6f9af..a294c5f6019e86fd097b85b7e4915de9d7a64611 100644 (file)
@@ -2,6 +2,29 @@
 
 (require 'sweeprolog)
 
+(defconst sweeprolog-tests-greeting
+  "Hello from Elisp from Prolog from Elisp from Prolog from Elisp!")
+
+(defun sweeprolog-tests-greet ()
+  (sweeprolog-open-query "user" "user"
+                         "sweep_funcall"
+                         "sweeprolog-tests-greet-1")
+  (let ((sol (sweeprolog-next-solution)))
+    (sweeprolog-cut-query)
+    (cdr sol)))
+
+(defun sweeprolog-tests-greet-1 ()
+  (message sweeprolog-tests-greeting))
+
+(ert-deftest elisp->prolog->elisp->prolog->elisp ()
+  "Tests calling Elisp from Prolog from Elisp from Prolog from Elisp."
+  (should (equal (sweeprolog-open-query "user" "user"
+                                        "sweep_funcall"
+                                        "sweeprolog-tests-greet")
+                 t))
+  (should (equal (sweeprolog-next-solution) (cons '! sweeprolog-tests-greeting)))
+  (should (equal (sweeprolog-cut-query) t)))
+
 (ert-deftest lists:member/2 ()
   "Tests calling the Prolog predicate permutation/2 from Elisp."
   (should (equal (sweeprolog-open-query "user" "lists" "member" (list 1 2 3) t) t))