Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A set of assertions for using erlog with eunit
I have found that I am using erlog to write tests a lot, so I created an assertion ?assertProlog which will let you run a prolog query and assert that it will pass. There is also an inverse option incase that is useful
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-define(assertProlog(PrologExp, Erlog), | ||
begin | ||
((fun() -> | ||
case (erlog:prove(PrologExp,Erlog)) of | ||
{{succeed,_}, E1} -> | ||
{ok,E1}; | ||
{fail, E1} -> | ||
erlang:error({assertProlog, [ | ||
[{module, ?MODULE}, | ||
{line, ?LINE}, | ||
{expression, PrologExp}, | ||
{expected, true}, | ||
{erlog_state, E1} | ||
]]}) | ||
end | ||
end)()) | ||
end). | ||
|
||
|
||
-define(assertPrologFail(PrologExp, Erlog), | ||
begin | ||
((fun() -> | ||
case (erlog:prove(PrologExp,Erlog)) of | ||
{fail, E1} -> | ||
{ok,E1}; | ||
{_, E1} -> | ||
erlang:error({assertProlog, [ | ||
[{module, ?MODULE}, | ||
{line, ?LINE}, | ||
{expression, PrologExp}, | ||
{expected, true}, | ||
{erlog_state, E1} | ||
]]}) | ||
end | ||
end)()) | ||
end). | ||
|