When you execute anything in prolog you can see that the result of the evaluation comes out as:
true
or
false
I would like to change those values for personalized ones.
Based on this question, I saw that what I want is defined in the messages.pl
file
where I found that they are defined as:
query_result(no) --> % failure
[ ansi(truth(false), 'false.', []) ],
extra_line.
query_result(yes(true, [])) --> % prompt_alternatives_on: groundness
!,
[ ansi(truth(true), 'true.', []) ],
extra_line.
I'd like that instead of getting false
or true
, I could get <ERROR::>
and <PASSED::>
respectively for my unit tests.
Additional info
I am doing the unit test to a file called adition.pl
consisting solely of.
my_add(A,B,Result):- number(A), number(B), is(Result,+(A,B)).
Attempt
:-['C:/Users/RuslanLopez/Documents/Prolog/adittion.pl'].
%:-['C:/Program Files/swipl/boot/messages.pl'].
:- begin_tests(my_add).
:- include(adittion).
%:- use_module($messages).
%:- include(messages).
error:-write('<ERROR::>'),nl.
passed:-write('<PASSED::>'),nl.
:- dynamic(user:query_result/1).
user:query_result(no) --> % failure
[ ansi(truth(false),'<ERROR::>', []) ].
user:query_result(yes(true, [])) --> % prompt_alternatives_on: groundness
!,
[ ansi(truth(true),'<PASSED::>' , []) ].
test(my_add):-
my_add(1,2,Result),
Result =:= 3.
test(my_add) :-
my_add(1,2,Result),
Result \= 4.
:- end_tests(my_add).
I understand that the more straightforward solution would be to go to the file and change the value directly there, but I really wish I could make the change at runtime to change that custom behavior only in my unit test and not for the entire system.