Test a function: Difference between revisions

Added Prolog
(Add Jsish)
(Added Prolog)
Line 1,375:
(test T (palindrome? "racecar"))
(test NIL (palindrome? "ferrari"))</lang>
 
=={{header|Prolog}}==
SWI-Prolog has an inbuilt unit test functionality which is run automatically when building.
 
It can also be run by using the run_tests predicate.
 
<lang Prolog>palindrome(Word) :- name(Word,List), reverse(List,List).
 
:- begin_tests(palindrome).
 
test(valid_palindrome) :- palindrome('ingirumimusnocteetconsumimurigni').
test(invalid_palindrome, [fail]) :- palindrome('this is not a palindrome').
 
:- end_tests(palindrome).</lang>
 
 
=={{header|PureBasic}}==
PureBasic allows for definition of Assert() and other tools & the debugger is integrated into the native editor.
Line 1,404 ⟶ 1,420:
Assert(IsPalindrome(text1$), "Catching this would be a fail")
Assert(IsPalindrome(text2$), "Catching this is correct")</lang>
 
 
=={{header|Python}}==
Anonymous user