|
From: | Daniel Diaz |
Subject: | Re: Predicate ordering when using current_predicate/1 |
Date: | Fri, 22 Nov 2013 17:53:03 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
Hi,
here is a piece of code doing what you want get_tests(L) :- setof(t(File, Line, Name), get_one_test(File, Line, Name), L). get_one_test(File, Line, Name) :- current_predicate(Name/0), atom_concat('test_', _, Name), predicate_property(Name, prolog_file(File)), predicate_property(Name, prolog_line(Line)). This returns a list containing triplets t(File, Line, Name) where File is the file pathname of the test, Line is the line number in the source file and Name the test name (beginning by test_). The list is sorted on File and then on Line. I keep the File in case your tests reside in different files, if it is not the case you simplify the code by removing everything related to File (including predicate_property(..., prolog_line(Line))). If you only need the list of test names (and don't want the File and Line), you can define get_tests_name(AllTests) :- get_tests(L), findall(Name, member(t(_,_,Name), L), AllTests). Then get_test_names does the job. Daniel Le 21/11/2013 16:48, emacstheviking a écrit :
-- Ce message a été vérifié par MailScanner pour des virus ou des polluriels et rien de suspect n'a été trouvé. |
[Prev in Thread] | Current Thread | [Next in Thread] |