Test a function: Difference between revisions
Added Wren
(→{{header|Phix}}: enhanced output, set_wait_on_summary() has been renamed as set_test_pause()) |
(Added Wren) |
||
Line 2,204:
wombat is a palidrome ? False
in girum imus nocte et consumimur igni is a palidrome ? True</pre>
=={{header|Wren}}==
{{libheader|Wren-test}}
<lang ecmascript>import "/module" for Expect, Suite, ConsoleReporter
var isPal = Fn.new { |word| word == ((word.count > 0) ? word[-1..0] : "") }
var words = ["rotor", "rosetta", "step on no pets", "été", "wren", "🦊😀🦊"]
var expected = [true, false, true, true, false, true]
var TestPal = Suite.new("Pal") { |it|
it.suite("isPal") { |it|
for (i in 0...words.count) {
it.should("return true if its argument is a palindrome, false otherwise") {
Expect.call(isPal.call(words[i])).toEqual(expected[i])
}
}
}
}
var reporter = ConsoleReporter.new()
TestPal.run(reporter)
reporter.epilogue()</lang>
{{out}}
<pre>
Pal
isPal
✓ should return true if its argument is a palindrome, false otherwise
✓ should return true if its argument is a palindrome, false otherwise
✓ should return true if its argument is a palindrome, false otherwise
✓ should return true if its argument is a palindrome, false otherwise
✓ should return true if its argument is a palindrome, false otherwise
✓ should return true if its argument is a palindrome, false otherwise
==== Tests Summary ====
6 tests, 6 passed, 0 failed, 0 errors, 0 skipped (1 ms)
</pre>
=={{header|zkl}}==
|