Created
December 4, 2017 19:29
-
-
Save hsk/ff712ab7e4ba400211557a3e59ed381f to your computer and use it in GitHub Desktop.
prolog test sample
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
:- module(fun1, [add/3,mul/3]). | |
% fun.pl | |
add(A,B,C) :- C is A+B. | |
mul(A,B,C) :- C is A*B. |
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
:- module(fun2, [add/3,mul/3]). | |
% fun2.pl | |
add(A,B,C) :- C is A+B. | |
mul(A,B,C) :- C is A*B. |
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
% funtest.pl | |
:- current_prolog_flag(argv, [M]),!,format('use ~w\n',[M]),use_module(M) ; | |
use_module(fun1). | |
:- begin_tests(add). | |
test(add1_2) :- add(1,2,3). | |
test(add0_1) :- add(0,1,1). | |
:- end_tests(add). | |
:- begin_tests(mul). | |
test(mul1_2) :- mul(1,2,2). | |
test(mul0_1) :- mul(0,1,0). | |
test(mul10_20) :- mul(10,20,200). | |
:- end_tests(mul). | |
:- run_tests. | |
:- halt. |
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
test: test1 test2 | |
test1: | |
swipl funtest.pl | |
test2: | |
swipl funtest.pl fun2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment