Skip to content

Instantly share code, notes, and snippets.

@gbmele
Forked from tzbob/gist:3959764
Created October 1, 2023 10:35
Show Gist options
  • Save gbmele/1845c285f46de002c3ef97e4cca9cfd1 to your computer and use it in GitHub Desktop.
Save gbmele/1845c285f46de002c3ef97e4cca9cfd1 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment