From 6e3bf5c9965b34115f23e3578abd7a81df324e67 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sun, 27 Nov 2022 21:34:32 +0200 Subject: [PATCH] Add test for predicate completion with named arguments --- README.org | 5 ----- sweeprolog-tests.el | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index 244528f..a289c99 100644 --- a/README.org +++ b/README.org @@ -1648,11 +1648,6 @@ there some further improvements that we want to pursue: definition, ideally with optional =PlDoc= comments (see [[#sweeprolog-pldoc][Documenting predicates]]). -- Improve the information provided for predicate completion candidates :: predicate - completion with ~C-M-i~ should annotate each completion candidate with - the names and modes of its arguments, when available. E.g. say - ~foo(+Bar, -Baz)~ instead of ~foo/2~. - - Make predicate completion aware of module-qualification :: predicate completion should detect when the prefix it's trying to complete starts with a module-qualification ~foo:ba<|>~ and restrict completion diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el index 1830681..8732098 100644 --- a/sweeprolog-tests.el +++ b/sweeprolog-tests.el @@ -262,6 +262,38 @@ foo => barbaz(_, _)" )))) +(ert-deftest complete-predicate-with-args () + "Tests completing predicate calls." + (let ((temp (make-temp-file "sweeprolog-test" + nil + ".pl" + " +:- module(foobarbaz, []). + +%! foobarbaz(:Bar, ?Baz:integer) is det. + +foobarbaz(_, 5) :- spam. + +spam :- foobarb +" + ))) + (find-file-literally temp) + (sweeprolog-mode) + (goto-char (point-max)) + (backward-char) + (call-interactively #'completion-at-point) + (should (string= (buffer-string) + " +:- module(foobarbaz, []). + +%! foobarbaz(:Bar, ?Baz:integer) is det. + +foobarbaz(_, 5) :- spam. + +spam :- foobarbaz(Bar, Baz) +" + )))) + (ert-deftest complete-predicate () "Tests completing predicate calls." (let ((temp (make-temp-file "sweeprolog-test" -- 2.39.2