Last active
August 29, 2015 14:11
-
-
Save ktosiek/da94857ab63c12052e2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gerrit_test_utils: [1] ?- [gerrit_test_utils]. run_tests. | |
% gerrit_test_utils compiled into gerrit_test_utils 0.00 sec, 1 clauses | |
true. | |
% PL-Unit: with_facts . | |
Warning: /home/tomek/prolog/gerrit_test_utils.pl:16: | |
PL-Unit: Test multiple_facts: Test succeeded with choicepoint | |
done | |
% All 2 tests passed | |
true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% -*- Prolog -*- | |
:- module(gerrit_test_utils). | |
with_facts([], Goal) :- Goal. | |
with_facts([Term | Ts], Goal) :- | |
setup_call_cleanup( | |
assert(Term), | |
with_facts(Ts, Goal), | |
retract(Term) | |
). | |
:- begin_tests(with_facts). | |
test(return_fact) :- | |
with_facts([a(1)], a(X)), | |
assertion(X == 1). | |
test(multiple_facts) :- | |
with_facts([a(1), a(2)], findall(Y, a(Y), Ys)), | |
assertion(Ys == [1, 2]). | |
:- end_tests(with_facts). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment