[K/N][Tests] Adjust moved codegen tests to new infra
^KT-61259
This commit is contained in:
committed by
Space Team
parent
71a834b778
commit
73032213f0
@@ -3,20 +3,18 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.arithmetic
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun square(a:Int):Int = a * a
|
||||
fun sumOfSquares(a:Int, b:Int):Int = square(a) + square(b)
|
||||
fun diffOfSquares(a:Int, b:Int):Int = square(a) - square(b)
|
||||
fun mod(a:Int,b:Int):Int = a / b
|
||||
fun remainder(a:Int, b:Int):Int = a % b
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
if (square(2) != 4) throw Error()
|
||||
if (sumOfSquares(2, 4) != 20) throw Error()
|
||||
if (diffOfSquares(2, 4) != -12) throw Error()
|
||||
if (mod(5, 2) != 2) throw Error()
|
||||
if (remainder(5, 2) != 1) throw Error()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,12 +3,10 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.boolean
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun bool_yes(): Boolean = true
|
||||
|
||||
@Test fun runTest() {
|
||||
if (!bool_yes()) throw Error()
|
||||
fun box(): String {
|
||||
if (!bool_yes()) return "FAIL !bool_yes()"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
/**
|
||||
* Created by minamoto on 12/26/16.
|
||||
*/
|
||||
@@ -48,7 +44,7 @@ fun foo(a: A = A.magic, b:Int = 0xdeadbeef.toInt()) = a.a
|
||||
fun bar(a:A, inc:Int = 0) = A(a.a + inc)
|
||||
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
|
||||
// if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
// arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ
|
||||
@@ -98,5 +94,5 @@ fun bar(a:A, inc:Int = 0) = A(a.a + inc)
|
||||
println("A one + 1 failed")
|
||||
throw Error()
|
||||
}
|
||||
println("all tests passed")
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,16 +3,15 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(x:Int = 0, y:Int = x + 1, z:Int = x + y + 1) = x + y + z
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val v = foo()
|
||||
if (v != 3) {
|
||||
println("test failed $v expected 3")
|
||||
throw Error()
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,14 +3,13 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults10
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
enum class A(one: Int, val two: Int = one) {
|
||||
FOO(42)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(A.FOO.two)
|
||||
fun box(): String {
|
||||
assertEquals(42, (A.FOO.two))
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -3,17 +3,16 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
fun Int.foo(inc0:Int, inc:Int = 0) = this + inc0 + inc
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val v = 42.foo(0)
|
||||
if (v != 42) {
|
||||
println("test failed v:$v expected:42")
|
||||
throw Error()
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,14 +3,10 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(a:Int = 2, b:String = "Hello", c:Int = 4):String = "$b-$c$a"
|
||||
fun foo(a:Int = 3, b:Int = a + 1, c:Int = a + b) = a + b + c
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val a = foo(b="Universe")
|
||||
if (a != "Universe-42")
|
||||
throw Error()
|
||||
@@ -18,4 +14,6 @@ fun foo(a:Int = 3, b:Int = a + 1, c:Int = a + b) = a + b + c
|
||||
val b = foo(b = 5)
|
||||
if (b != (/* a = */ 3 + /* b = */ 5 + /* c = */ (3 + 5)))
|
||||
throw Error()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,20 +3,23 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults4
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
open class A {
|
||||
open fun foo(x: Int = 42) = println(x)
|
||||
open fun foo(x: Int = 42) = sb.append(x)
|
||||
}
|
||||
|
||||
open class B : A()
|
||||
|
||||
class C : B() {
|
||||
override fun foo(x: Int) = println(x + 1)
|
||||
override fun foo(x: Int) = sb.append(x + 1)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
C().foo()
|
||||
|
||||
assertEquals("43", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
43
|
||||
@@ -3,21 +3,24 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults5
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
class TestClass(val x: Int) {
|
||||
fun foo(y: Int = x) {
|
||||
println(y)
|
||||
sb.appendLine(y)
|
||||
}
|
||||
}
|
||||
|
||||
fun TestClass.bar(y: Int = x) {
|
||||
println(y)
|
||||
sb.appendLine(y)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
TestClass(5).foo()
|
||||
TestClass(6).bar()
|
||||
|
||||
assertEquals("5\n6\n", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
5
|
||||
6
|
||||
@@ -3,13 +3,12 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults6
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
open class Foo(val x: Int = 42)
|
||||
class Bar : Foo()
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Bar().x)
|
||||
fun box(): String {
|
||||
assertEquals(42, Bar().x)
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults7
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
/**
|
||||
@@ -16,10 +14,15 @@ import kotlin.test.*
|
||||
* to label %label_1 unwind label %cleanup_landingpad
|
||||
*/
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun <T> foo(a : T, b : Int = 42){
|
||||
println(b)
|
||||
sb.append(b)
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
foo(1)
|
||||
|
||||
assertEquals("42", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults8
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Foo {
|
||||
@@ -15,6 +13,8 @@ class Bar {
|
||||
fun test(x: Int = 2) = x
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
println(Bar().test())
|
||||
fun box(): String {
|
||||
assertEquals(2, Bar().test())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
2
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaults9
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class Foo {
|
||||
@@ -13,4 +11,7 @@ class Foo {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() = println(Foo().Bar().y)
|
||||
fun box(): String {
|
||||
assertEquals(1, Foo().Bar().y)
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -3,12 +3,10 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaultsFromFakeOverride
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
interface I<T> {
|
||||
fun f(x: String = "42"): String
|
||||
fun f(x: String = "OK"): String
|
||||
}
|
||||
|
||||
open class A<T> {
|
||||
@@ -17,7 +15,7 @@ open class A<T> {
|
||||
|
||||
class B : A<String>(), I<String>
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val b = B()
|
||||
println(b.f())
|
||||
return b.f()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
@@ -3,14 +3,14 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaultsWithInlineClasses
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
inline class Foo(val value: Int)
|
||||
fun foo(x: Foo = Foo(42)) = x.value
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
assertEquals(foo(), 42)
|
||||
assertEquals(foo(Foo(17)), 17)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,24 +3,32 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaultsWithVarArg1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun foo(s: String = "", vararg args: Any) {
|
||||
if (args == null) {
|
||||
println("Failed!")
|
||||
sb.appendLine("Failed!")
|
||||
} else {
|
||||
print("$s ")
|
||||
sb.append("$s ")
|
||||
args.forEach {
|
||||
print("$it")
|
||||
sb.append("$it")
|
||||
}
|
||||
println(", Correct!")
|
||||
sb.appendLine(", Correct!")
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
foo("Hello")
|
||||
foo("Hello", "World")
|
||||
foo()
|
||||
|
||||
assertEquals("""
|
||||
Hello , Correct!
|
||||
Hello World, Correct!
|
||||
, Correct!
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
Hello , Correct!
|
||||
Hello World, Correct!
|
||||
, Correct!
|
||||
@@ -3,15 +3,23 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.defaultsWithVarArg2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun foo(vararg arr: Int = intArrayOf(1, 2)) {
|
||||
arr.forEach { println(it) }
|
||||
arr.forEach { sb.appendLine(it) }
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
foo()
|
||||
foo(42)
|
||||
|
||||
assertEquals("""
|
||||
1
|
||||
2
|
||||
42
|
||||
|
||||
""".trimIndent(), sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
1
|
||||
2
|
||||
42
|
||||
+3
-3
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.eqeq
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun eqeqB (a:Byte, b:Byte ) = a == b
|
||||
@@ -35,7 +33,7 @@ fun neF (a:Float, b:Float ) = a != b
|
||||
fun helloString() = "Hello"
|
||||
fun goodbyeString() = "Goodbye"
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
if (!eqeqB(3 , 3 )) throw Error()
|
||||
if (!eqeqS(3 , 3 )) throw Error()
|
||||
if (!eqeqI(3 , 3 )) throw Error()
|
||||
@@ -61,4 +59,6 @@ fun goodbyeString() = "Goodbye"
|
||||
if (geF (2.0f , 3.0f )) throw Error()
|
||||
if (leF (3.0f , 2.0f )) throw Error()
|
||||
if (neF (2.0f , 2.0f )) throw Error()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,6 +3,13 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class B(val a: Int)
|
||||
|
||||
fun B.foo() = this.a
|
||||
fun B.foo() = this.a
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(42, B(42).foo())
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.intrinsic
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// This code fails to link when bultins are taken from the
|
||||
@@ -18,6 +16,7 @@ fun intrinsic(b: Int): Int {
|
||||
return sum
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
if (intrinsic(3) != 4) throw Error()
|
||||
fun box(): String {
|
||||
assertEquals(4, intrinsic(3))
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,13 +3,13 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.localFunction
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val sb = StringBuilder()
|
||||
|
||||
fun box(): String {
|
||||
val x = 1
|
||||
fun local0() = println(x)
|
||||
fun local0() = sb.appendLine(x)
|
||||
fun local1() {
|
||||
fun local2() {
|
||||
local1()
|
||||
@@ -28,5 +28,6 @@ import kotlin.test.*
|
||||
}
|
||||
}
|
||||
|
||||
println("OK")
|
||||
assertEquals("", sb.toString())
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -3,11 +3,9 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.localFunction2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
var a = 0
|
||||
fun local() {
|
||||
class A {
|
||||
@@ -21,5 +19,5 @@ import kotlin.test.*
|
||||
return A()
|
||||
}
|
||||
}
|
||||
println("OK")
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -3,11 +3,9 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.localFunction3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
fun bar() {
|
||||
fun local1() {
|
||||
bar()
|
||||
@@ -21,5 +19,5 @@ import kotlin.test.*
|
||||
}
|
||||
local2()
|
||||
}
|
||||
println("OK")
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
OK
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.minus_eq
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun minus_eq(a: Int): Int {
|
||||
@@ -13,6 +11,7 @@ fun minus_eq(a: Int): Int {
|
||||
return b
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
if (minus_eq(23) != -12) throw Error()
|
||||
fun box(): String {
|
||||
assertEquals (-12, minus_eq(23))
|
||||
return "OK"
|
||||
}
|
||||
+3
-5
@@ -3,13 +3,11 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.named
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(a:Int, b:Int) = a - b
|
||||
|
||||
@Test fun runTest() {
|
||||
if (foo(b = 24, a = 42) != 18)
|
||||
throw Error()
|
||||
fun box(): String {
|
||||
assertEquals(18, foo(b = 24, a = 42))
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package codegen.function.nothingN_returning_safe_call
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun Any.nothing(): Nothing {
|
||||
@@ -34,7 +32,7 @@ fun testLambda2() {
|
||||
block(null)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
fun box(): String {
|
||||
testFunction1(null)
|
||||
testFunction2(null)
|
||||
testFunction3(null)
|
||||
@@ -43,4 +41,6 @@ fun main() {
|
||||
|
||||
testLambda1()
|
||||
testLambda2()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.plus_eq
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun plus_eq(a: Int): Int {
|
||||
@@ -13,6 +11,7 @@ fun plus_eq(a: Int): Int {
|
||||
return b
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
if (plus_eq(3) != 14) throw Error()
|
||||
fun box(): String {
|
||||
assertEquals(14, plus_eq(3))
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.referenceBigArity
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun фу(а: Int, б: Int, в: Int, г: Int, д: Int, е: Int, ё: Int, ж: Int, з: Int, и: Int, й: Int, к: Int,
|
||||
@@ -14,8 +12,9 @@ fun фу(а: Int, б: Int, в: Int, г: Int, д: Int, е: Int, ё: Int, ж: Int,
|
||||
п + р + с + т + у + ф + х + ц + ч + ш + щ + ъ + ы + ь + э + ю + я
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
val ref = ::фу
|
||||
println(ref(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
assertEquals(528, ref(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32))
|
||||
return "OK"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
528
|
||||
+3
-3
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.sum
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun sumIB(a:Int, b:Byte ) = a + b
|
||||
@@ -16,7 +14,7 @@ fun sumID(a:Int, b:Double) = a + b
|
||||
|
||||
fun modID(a:Int, b:Double) = a % b
|
||||
|
||||
@Test fun runTest() {
|
||||
fun box(): String {
|
||||
if (sumIB(2, 3) != 5) throw Error()
|
||||
if (sumIS(2, 3) != 5) throw Error()
|
||||
if (sumII(2, 3) != 5) throw Error()
|
||||
@@ -24,4 +22,6 @@ fun modID(a:Int, b:Double) = a % b
|
||||
if (sumIF(2, 3.0f) != 5.0f) throw Error()
|
||||
if (sumID(2, 3.0) != 5.0) throw Error()
|
||||
if (modID(5, 3.0) != 2.0) throw Error()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,13 +3,12 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.sum_3const
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun sum3():Int = sum(1, 2, 33)
|
||||
fun sum(a:Int, b:Int, c:Int): Int = a + b + c
|
||||
|
||||
@Test fun runTest() {
|
||||
if (sum3() != 36) throw Error()
|
||||
fun box(): String {
|
||||
assertEquals(36, sum3())
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.sum_foo_bar
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo(a:Int):Int = a
|
||||
@@ -12,6 +10,7 @@ fun bar(a:Int):Int = a
|
||||
|
||||
fun sumFooBar(a:Int, b:Int):Int = foo(a) + bar(b)
|
||||
|
||||
@Test fun runTest() {
|
||||
if (sumFooBar(2, 3) != 5) throw Error()
|
||||
fun box(): String {
|
||||
assertEquals(5, sumFooBar(2, 3))
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,12 +3,13 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.sum_func
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun foo():Int = 1
|
||||
//fun bar():Int = 2
|
||||
//fun sum():Int = foo() + bar()
|
||||
fun bar():Int = 2
|
||||
fun sum():Int = foo() + bar()
|
||||
|
||||
// FIXME: has no checks
|
||||
fun box(): String {
|
||||
assertEquals(3, sum())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.sum_imm
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
fun sum(a:Int): Int = a + 33
|
||||
|
||||
@Test fun runTest() {
|
||||
if (sum(2) != 35) throw Error()
|
||||
fun box(): String {
|
||||
assertEquals(35, sum(2))
|
||||
return "OK"
|
||||
}
|
||||
@@ -3,9 +3,11 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.sum_mixed
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// FIXME: has no checks
|
||||
fun sum(a:Float, b:Int) = a + b
|
||||
fun sum(a:Float, b:Int) = a + b
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(3.0F, sum(1.0F, 2))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,14 +3,15 @@
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package codegen.function.sum_silly
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// FIXME: has no checks
|
||||
|
||||
fun sum(a:Int, b:Int):Int {
|
||||
var c:Int
|
||||
c = a + b
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(50, sum(42, 8))
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+12
-10
@@ -3,8 +3,8 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package codegen.function.unreachable_statement_after_return
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.test.*
|
||||
|
||||
fun test1(): Any? {
|
||||
return 1
|
||||
@@ -53,15 +53,17 @@ private fun <T> (suspend () -> T).runCoroutine() : T {
|
||||
return result as T
|
||||
}
|
||||
|
||||
fun main() {
|
||||
println(test1())
|
||||
println(test2())
|
||||
println(test3())
|
||||
println(test4())
|
||||
fun box(): String {
|
||||
assertEquals(1, test1())
|
||||
assertEquals(2, test2())
|
||||
assertEquals(3, test3())
|
||||
assertEquals(4, test4())
|
||||
|
||||
println(::test5.runCoroutine())
|
||||
println(::test6.runCoroutine())
|
||||
println(::test7.runCoroutine())
|
||||
println(::test8.runCoroutine())
|
||||
assertEquals(5, ::test5.runCoroutine())
|
||||
assertEquals(6, ::test6.runCoroutine())
|
||||
assertEquals(7, ::test7.runCoroutine())
|
||||
assertEquals(8, ::test8.runCoroutine())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
Reference in New Issue
Block a user