Test a function: Difference between revisions

→‎{{header|Kotlin}}: Improved example
(Added Kotlin)
(→‎{{header|Kotlin}}: Improved example)
Line 801:
 
fun main(args: Array<String>) {
assert(isPalindromeval testCases = listOf("racecar"), "alice", "eertree", "david")
for (testCase in testCases) {
assert(isPalindrome("alice"))
try {
assert(isPalindrome(testCase)) { "$testCase is not a palindrome" }
}
catch (ae: AssertionError) {
println(ae.message)
}
}
}</lang>
 
{{out}}
<pre>
alice is not a palindrome
Exception in thread "main" java.lang.AssertionError: Assertion failed
david is not a palindrome
at TestfuncKt.main(testfunc.kt:7)
</pre>
 
9,482

edits