This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/misc/tests
Vítor Santos Costa 661f33ac7e bug fices
2016-01-03 02:06:09 +00:00

34 lines
635 B
Plaintext

:- op(test, fx, 1200).
test_mode.
test( ( G :- Sols ) :-
reset_sols,
init_io( Streams ),
catch( do_test(G, Sols), Done, handler( Done ) ).
close_io( Streams ).
do_test(G0, Sols)
copy_term(G0, G),
catch( ( G, answer(G, Sol) ) , Error, test_error(Error, Sol) ),
next_solution( I, Sol, G0, Sol ),
!.
do_test(G, Sols) :-
counter(I),
failure(G, Sols, I).
next_solution( I, Sol , G0, Sols ) :-
inc(I),
fetch(I, Sols, Pattern, Next),
(
Sol =@= Pattern
->
success(I, G0)
;
error(I, G0, Sol )
),
( var(Next) -> throw( done ) ).