Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tzbob
Created October 26, 2012 16:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tzbob/3959764 to your computer and use it in GitHub Desktop.
Save tzbob/3959764 to your computer and use it in GitHub Desktop.
Micro TDD Prolog
% test predicate
test(Summary, Predicate) :-
string_concat('\n ', Summary, Buf),
string_concat(Buf, ' is running', Message),
write(Message),
call(Predicate),
write('\ndone.').
% example
force(anakin, 9).
force(luke, 10).
stronger(X, Y) :-
force(X, FX),
force(Y, FY),
FX > FY.
test :-
test('anakin stronger', (
stronger(anakin, luke)
)).
% run tests on compile
:- test.
@byxor
Copy link

byxor commented Jan 3, 2017

Thanks for this! I've had a lot of trouble making PL-Unit do what I'd like.
This is a fantastically simple approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment