Permalink
Browse files

Add tests for `optional` library `or_else_call/2` and `or_else_fail/1…

…` predicates
  • Loading branch information...
pmoura committed Dec 4, 2017
1 parent 8aa1e8e commit a746775fcc683f85d92d1663fad160fbe1b5f54e
Showing with 25 additions and 3 deletions.
  1. +3 −0 RELEASE_NOTES.md
  2. +22 −3 tests/logtalk/library/optional/tests.lgt
View
@@ -91,6 +91,9 @@ Tests
* ADDED: Two more tests for the Prolog standard `arg/3` built-in predicate.
* ADDED: Unit tests for the `optional` library predicates `or_else_call/2`
and `or_else_fail/1`
Examples
--------
@@ -22,14 +22,14 @@
extends(lgtunit)).
:- info([
version is 0.4,
version is 0.5,
author is 'Paulo Moura',
date is 2017/08/08,
date is 2017/12/04,
comment is 'Unit tests for the "optional" library.'
]).
:- discontiguous([
succeeds/1, throws/2
fails/1, succeeds/1, throws/2
]).
% is_empty/0 tests
@@ -127,6 +127,25 @@
optional::of(1, Ref), optional(Ref)::or_else_get(Term, current_logtalk_flag(prolog_dialect)),
Term == 1.
% or_else_call/2 tests
succeeds(optional_or_else_call_2_01) :-
optional::empty(Ref), optional(Ref)::or_else_call(Term, X = 1),
X == 1.
succeeds(optional_or_else_call_2_02) :-
optional::of(1, Ref), optional(Ref)::or_else_call(Term, X = 1),
var(X).
% or_else_fail/1 tests
fails(optional_or_else_fail_1_01) :-
optional::empty(Ref), optional(Ref)::or_else_fail(_).
succeeds(optional_or_else_fail_1_02) :-
optional::of(1, Ref), optional(Ref)::or_else_fail(Term),
Term == 1.
% "optional" type tests
succeeds(optional_type_checking_support_01) :-

0 comments on commit a746775

Please sign in to comment.