Test a function: Difference between revisions

Content added Content deleted
(added scheme example)
Line 1,547: Line 1,547:
its second half, it isn't a palindrome: OK, passed 100 tests.
its second half, it isn't a palindrome: OK, passed 100 tests.
</pre>
</pre>

=={{header|Scheme}}==

{{libheader|Scheme/SRFIs}}

SRFI 64 is a popular test library.

<lang scheme>
(import (srfi 64))
(test-begin "palindrome-tests")
(test-assert (palindrome? "ingirumimusnocteetconsumimurigni"))
(test-assert (not (palindrome? "This is not a palindrome")))
(test-equal #t (palindrome? "ingirumimusnocteetconsumimurigni")) ; another of several test functions
(test-end)
</lang>

The library reports the number of pass/fail tests at the end; the report may be customised.
Also, a detailed log file is created, showing the results of each test.


=={{header|Swift}}==
=={{header|Swift}}==