Test a function: Difference between revisions
Content added Content deleted
(Clojure should come after C) |
(Add Brat example) |
||
Line 64: | Line 64: | ||
#Include assert.ahk |
#Include assert.ahk |
||
#Include palindrome.ahk</lang> |
#Include palindrome.ahk</lang> |
||
=={{header|Brat}}== |
|||
<lang brat>include :assert |
|||
palindrome? = { str | |
|||
str = str.downcase.sub /\s+/ "" |
|||
str == str.reverse |
|||
} |
|||
setup name: "palindrome test" { |
|||
test "is a palindrome" { |
|||
assert { palindrome? "abba" } |
|||
} |
|||
test "is not a palindrome" { |
|||
assert_false { palindrome? "abb" } |
|||
} |
|||
test "is not a string" { |
|||
assert_fail { palindrome? 1001 } |
|||
} |
|||
test "this test fails" { |
|||
assert { palindrome? "blah blah" } |
|||
} |
|||
}</lang> |
|||
Output: |
|||
<pre>Loading tests... |
|||
Running palindrome test... |
|||
(4/4) this test fails |
|||
Test failure(s): |
|||
1. 'this test fails': assert failed |
|||
4 tests, 4 assertions, 1 failures.</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |