Skip to content

Commit

Permalink
pascals-triangle: fix tests
Browse files Browse the repository at this point in the history
See #81
  • Loading branch information
ErikSchierboom committed Mar 31, 2023
1 parent e1bd549 commit a094536
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions exercises/practice/pascals-triangle/pascals_triangle_tests.plt
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
pending :-
current_prolog_flag(argv, ['--all'|_]).
current_prolog_flag(argv, Rows),
Rows == ['--all'|_].
pending :-
write('\nA TEST IS PENDING!\n'),
fail.

:- begin_tests(pascal).

test(zero_rows, condition(true)) :-
pascal(0, []).
pascal(0, Rows),
Rows == [].

test(single_row, condition(pending)) :-
pascal(1, [[1]]).
pascal(1, Rows),
Rows == [[1]].

test(two_rows, condition(pending)) :-
pascal(2, [[1], [1,1]]).
pascal(2, Rows),
Rows == [[1], [1,1]].

test(three_rows, condition(pending)) :-
pascal(3, [[1], [1,1], [1,2,1]]).
pascal(3, Rows),
Rows == [[1], [1,1], [1,2,1]].

test(four_rows, condition(pending)) :-
pascal(4, [[1], [1,1], [1,2,1], [1,3,3,1]]).
pascal(4, Rows),
Rows == [[1], [1,1], [1,2,1], [1,3,3,1]].

test(five_rows, condition(pending)) :-
pascal(5, [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]).
pascal(5, Rows),
Rows == [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]].

test(six_rows, condition(pending)) :-
pascal(6, [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1], [1,5,10,10,5,1]]).
pascal(6, Rows),
Rows == [[1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1], [1,5,10,10,5,1]].

test(ten_rows, condition(pending)) :-
pascal(10, [ [1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1],
[1,5,10,10,5,1],
[1,6,15,20,15,6,1],
[1,7,21,35,35,21,7,1],
[1,8,28,56,70,56,28,8,1],
[1,9,36,84,126,126,84,36,9,1]
]).
pascal(10, Rows),
Rows == [[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1],
[1,5,10,10,5,1],
[1,6,15,20,15,6,1],
[1,7,21,35,35,21,7,1],
[1,8,28,56,70,56,28,8,1],
[1,9,36,84,126,126,84,36,9,1]
].

:- end_tests(pascal).

0 comments on commit a094536

Please sign in to comment.