JetDiagnosticsTest migrated to TestGenerator

- test data files renamed from *.jet to *.kt
This commit is contained in:
Andrey Breslav
2012-07-10 14:04:59 +04:00
parent 6c23c093ef
commit 3d8d92c7d3
467 changed files with 2764 additions and 146 deletions
@@ -0,0 +1,30 @@
package sum
import java.util.*
fun sum(a : IntArray) : Int {
// Write your solution here
<!UNRESOLVED_REFERENCE!>res<!> = 0
for (e in a)
res +=<!SYNTAX!><!>
}
fun main(args : Array<String>) {
test(0)
test(1, 1)
test(-1, -1, 0)
test(6, 1, 2, 3)
test(6, 1, 1, 1, 1, 1, 1)
}
// HELPER FUNCTIONS
fun test(expectedSum : Int, vararg data : Int) {
val actualSum = sum(data)
assertEquals(actualSum, expectedSum, "\ndata = ${Arrays.toString(data)}\n" +
"sum(data) = ${actualSum}, but must be $expectedSum ")
}
fun assertEquals<T>(actual : T?, expected : T?, message : Any? = null) {
if (actual != expected) {
if (message == null)
throw AssertionError()
else
throw AssertionError(message)
}
}