Skip to content

Commit

Permalink
A set of assertions for using erlog with eunit
Browse files Browse the repository at this point in the history
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
zkessin committed Mar 6, 2016
1 parent 072f4d4 commit 9cb612d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions srl/erlog_assert.hrl
@@ -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).

0 comments on commit 9cb612d

Please sign in to comment.