Anonymous user
Test a function: Difference between revisions
Same changes for the second program.
(Actually do the changes indicated in previous edit.) |
(Same changes for the second program.) |
||
Line 1,256:
=={{header|Nim}}==
Using assertions (
<lang nim>proc reversed(s: string): string =
result = newString(s.len)
Line 1,276:
assert(not isPalindrome("abab"))</lang>
Using the
<lang nim>import unittest
proc
result = newString(s.len)
for i, c in s:
result[s.high - i] = c
proc isPalindrome(s: string): bool =
s ==
when isMainModule:
Line 1,303:
test "no palindrome":
check isPalindrome("foo") == false</lang>
{{out}}:
<pre>[OK] empty string
|