Hi,

I just wrote a *really simple* testing framework for my project, it looks like 
this at the test script end:

test_package([it('should ensure that global values have expected settings', 
defaults_correctly_set_test)
             ,it('should correctly set the quiet flag on "-q"', 
respect_quiet('-q'))
             ,it('should correctly set the quiet flag on "--quiet"', 
respect_quiet('--quiet'))
             ,it('should correctly set the wrap flag on "--wrap"', respect_wrap)
             ,it('should correctly set the check flag on "--nocheck"', 
respect_check)
             ,it('should add unhandled options as source filenames', 
filename_check)
             ,it('should throw exceptions on unknown options', 
handle_unknown_options)
             ]).

The test_package predicate is called from the framework by the script, the 
script pulls in the file and that has an initialisation instruction:

:- initialization(run_tests).

run_tests :-
        test_package(AllTests),
        maplist(call, AllTests),
        ink(normal, '*done*'),
        stop.


What would have made it *really* nice was to have been able to find all 
predicates starting with test_ or ending with _test etc. so that I would not 
have needed to make the test_package predicate unify the variable with the list 
of tests to be run. Some tests mentioned above...

defaults_correctly_set_test :-
        cl_set_defaults,
        
get_all_globals([],[],user_input,user_output,php,nowrap,check,plain,noisy).


respect_quiet(Flag) :-
        cl_set_defaults,
        process_option(Flag),
        get_all_globals(_,_,_,_,_,_,_,_,quiet).


As you can see, having to enter the test predicate AND enter it in the test 
package isn’t ideal ALTHOUGH it does allow me to provide a nice label but I 
could have done that with a really long predicate name anyway.

So, how would I do that in GNU Prolog…if it is possible. The listing() 
predicate is not much help in this instance…

Thanks,
Sean.

_______________________________________________
Users-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/users-prolog

Reply via email to