Skip to content

Commit

Permalink
Add missing tests for error conditions of the asserta/1, `assertz/1…
Browse files Browse the repository at this point in the history
…`, `clause/2`, `retract/1`, and `retractall/1` standard predicates
  • Loading branch information
pmoura committed Apr 19, 2015
1 parent 9f77ca5 commit b854f64
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
5 changes: 3 additions & 2 deletions RELEASE_NOTES.md
Expand Up @@ -77,8 +77,9 @@ call.

* ADDED: Several missing unit tests for arithmetic functions.

* ADDED: Missing tests for error conditions of the `call/2-8`, `atom_chars/2`,
`atom_codes/2`, `number_codes/2`, and `open/4` predicates.
* ADDED: Missing tests for error conditions of the `asserta/1`, `assertz/1`,
`clause/2`, `retract/1`, `retractall/1`, `call/2-8`, `open/4`, `atom_chars/2`,
`atom_codes/2`, and `number_codes/2`, predicates.

* FIXED: Tests for the de facto standard `between/3` predicate for XSB.

Expand Down
13 changes: 11 additions & 2 deletions tests/prolog/predicates/asserta_1/tests.lgt
Expand Up @@ -19,9 +19,9 @@
extends(lgtunit)).

:- info([
version is 1.0,
version is 1.1,
author is 'Paulo Moura',
date is 2014/11/04,
date is 2015/04/19,
comment is 'Unit tests for the ISO Prolog standard asserta/1 built-in predicate.'
]).

Expand Down Expand Up @@ -64,4 +64,13 @@
findall(X-Y, {asserta(insct(bee)),insct(X),asserta(insct(ant)),insct(Y)}, L),
L == [bee-ant, bee-bee].

throws(lgt_asserta_1_09, error(instantiation_error,_)) :-
{asserta((_ :- foo))}.

throws(lgt_asserta_1_10, error(instantiation_error,_)) :-
{asserta((_ :- _))}.

throws(lgt_asserta_1_11, error(type_error(callable,4),_)) :-
{asserta((4 :- foo))}.

:- end_object.
13 changes: 11 additions & 2 deletions tests/prolog/predicates/assertz_1/tests.lgt
Expand Up @@ -19,9 +19,9 @@
extends(lgtunit)).

:- info([
version is 1.0,
version is 1.1,
author is 'Paulo Moura',
date is 2014/11/04,
date is 2015/04/19,
comment is 'Unit tests for the ISO Prolog standard assertz/1 built-in predicate.'
]).

Expand Down Expand Up @@ -54,4 +54,13 @@
{assertz((atom(_) :- true))}.
:- endif.

throws(lgt_assertz_1_08, error(instantiation_error,_)) :-
{assertz((_ :- foo))}.

throws(lgt_assertz_1_09, error(instantiation_error,_)) :-
{assertz((_ :- _))}.

throws(lgt_assertz_1_10, error(type_error(callable,4),_)) :-
{assertz((4 :- foo))}.

:- end_object.
12 changes: 9 additions & 3 deletions tests/prolog/predicates/retract_1/tests.lgt
Expand Up @@ -29,9 +29,9 @@ foo(X) :- call(X), call(X).
extends(lgtunit)).

:- info([
version is 1.0,
version is 1.1,
author is 'Paulo Moura',
date is 2014/11/21,
date is 2015/04/19,
comment is 'Unit tests for the ISO Prolog standard retract/1 built-in predicate.'
]).

Expand Down Expand Up @@ -59,7 +59,10 @@ foo(X) :- call(X), call(X).
{retract((legs(_X,_Y) :- _Z))}.

succeeds(iso_retract_1_06) :-
{retract(insect(I)), write(I), nl, retract(insect(bee))},
{ retract(insect(I)),
% write(I), nl,
retract(insect(bee))
},
I == ant.

:- if((
Expand Down Expand Up @@ -94,4 +97,7 @@ foo(X) :- call(X), call(X).
{retract((atom(X) :- X =='[]'))}.
:- endif.

throws(lgt_retract_1_12, error(instantiation_error,_)) :-
{retract(_)}.

:- end_object.
7 changes: 5 additions & 2 deletions tests/prolog/predicates/retractall_1/tests.lgt
Expand Up @@ -20,9 +20,9 @@ insect(bee).
extends(lgtunit)).

:- info([
version is 1.0,
version is 1.1,
author is 'Paulo Moura',
date is 2014/11/04,
date is 2015/04/19,
comment is 'Unit tests for the ISO Prolog standard retractall/1 built-in predicate.'
]).

Expand All @@ -49,4 +49,7 @@ insect(bee).
{retractall(retractall(_))}.
:- endif.

throws(lgt_retractall_1_06, error(instantiation_error,_)) :-
{retractall(_)}.

:- end_object.

0 comments on commit b854f64

Please sign in to comment.