Created
October 26, 2012 16:31
-
-
Save tzbob/3959764 to your computer and use it in GitHub Desktop.
Micro TDD Prolog
This file contains hidden or 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
% 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this! I've had a lot of trouble making PL-Unit do what I'd like.
This is a fantastically simple approach.