TEST: convertion unit tests into run tests
This commit is contained in:
committed by
vvlevchenko
parent
7fd4b4fe34
commit
3fe59cc46c
@@ -108,26 +108,6 @@ abstract class KonanTest extends DefaultTask {
|
||||
}
|
||||
}
|
||||
|
||||
// Please do not use this framework anymore!
|
||||
class UnitKonanTest extends KonanTest {
|
||||
void compileTest(File sourceS, File runtimeS, File stdlibKtBc, File exe) {
|
||||
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
|
||||
project.execClang {
|
||||
executable "clang"
|
||||
def argList = []
|
||||
argList.addAll([ runtimeS.absolutePath, stdlibKtBc.absolutePath, sourceS.absolutePath,
|
||||
"-o", exe.absolutePath, testC, mainC ])
|
||||
argList.addAll(clangLinkArgs())
|
||||
args argList
|
||||
}
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void executeTest() {
|
||||
// Do nothing, unit tests go away.
|
||||
}
|
||||
}
|
||||
|
||||
class RunKonanTest extends KonanTest {
|
||||
void compileTest(File sourceS, File runtimeS, File libraryPath, File exe) {
|
||||
project.execClang {
|
||||
@@ -216,36 +196,32 @@ task run() {
|
||||
dependsOn(tasks.withType(KonanTest).matching { it.enabled })
|
||||
}
|
||||
|
||||
task sum (type:UnitKonanTest) {
|
||||
task sum (type:RunKonanTest) {
|
||||
source = "codegen/function/sum.kt"
|
||||
}
|
||||
|
||||
task method_call(type: UnitKonanTest) {
|
||||
task method_call(type: RunKonanTest) {
|
||||
source = "codegen/object/method_call.kt"
|
||||
}
|
||||
|
||||
task fields(type: UnitKonanTest) {
|
||||
task fields(type: RunKonanTest) {
|
||||
source = "codegen/object/fields.kt"
|
||||
}
|
||||
|
||||
|
||||
task fields1(type: UnitKonanTest) {
|
||||
task fields1(type: RunKonanTest) {
|
||||
source = "codegen/object/fields1.kt"
|
||||
}
|
||||
// This test checks object layout can't be done in
|
||||
// RunKonanTest paradigm
|
||||
//task constructor(type: UnitKonanTest) {
|
||||
// source = "codegen/object/constructor.kt"
|
||||
//}
|
||||
|
||||
task constructor(type: UnitKonanTest) {
|
||||
source = "codegen/object/constructor.kt"
|
||||
}
|
||||
|
||||
task objectInitialization(type: UnitKonanTest) {
|
||||
task objectInitialization(type: RunKonanTest) {
|
||||
source = "codegen/object/initialization.kt"
|
||||
}
|
||||
|
||||
task objectBasic(type: UnitKonanTest) {
|
||||
disabled = true
|
||||
source = "codegen/klass/basic.kt"
|
||||
}
|
||||
|
||||
task check_type(type: RunKonanTest) {
|
||||
goldValue = "true\nfalse\ntrue\ntrue\ntrue\ntrue\n"
|
||||
source = "codegen/basics/check_type.kt"
|
||||
@@ -257,24 +233,24 @@ task safe_cast(type: RunKonanTest) {
|
||||
source = "codegen/basics/safe_cast.kt"
|
||||
}
|
||||
|
||||
task aritmetic(type: UnitKonanTest) {
|
||||
task aritmetic(type: RunKonanTest) {
|
||||
source = "codegen/function/arithmetic.kt"
|
||||
}
|
||||
|
||||
task sum1(type: UnitKonanTest) {
|
||||
task sum1(type: RunKonanTest) {
|
||||
source = "codegen/function/sum_foo_bar.kt"
|
||||
|
||||
}
|
||||
|
||||
task sum2(type: UnitKonanTest) {
|
||||
task sum2(type: RunKonanTest) {
|
||||
source = "codegen/function/sum_imm.kt"
|
||||
}
|
||||
|
||||
task sum_3const(type: UnitKonanTest) {
|
||||
task sum_3const(type: RunKonanTest) {
|
||||
source = "codegen/function/sum_3const.kt"
|
||||
}
|
||||
|
||||
task local_variable(type: UnitKonanTest) {
|
||||
task local_variable(type: RunKonanTest) {
|
||||
source = "codegen/basics/local_variable.kt"
|
||||
}
|
||||
|
||||
@@ -283,11 +259,11 @@ task canonical_name(type: RunKonanTest) {
|
||||
source = "codegen/basics/canonical_name.kt"
|
||||
}
|
||||
|
||||
task cast_simple(type: UnitKonanTest) {
|
||||
task cast_simple(type: RunKonanTest) {
|
||||
source = "codegen/basics/cast_simple.kt"
|
||||
}
|
||||
|
||||
task null_check(type: UnitKonanTest) {
|
||||
task null_check(type: RunKonanTest) {
|
||||
source = "codegen/basics/null_check.kt"
|
||||
}
|
||||
|
||||
@@ -364,59 +340,59 @@ task array1(type: RunKonanTest) {
|
||||
source = "runtime/collections/array1.kt"
|
||||
}
|
||||
|
||||
task if_else(type: UnitKonanTest) {
|
||||
task if_else(type: RunKonanTest) {
|
||||
source = "codegen/branching/if_else.kt"
|
||||
}
|
||||
|
||||
task when2(type: UnitKonanTest) {
|
||||
task when2(type: RunKonanTest) {
|
||||
source = "codegen/branching/when2.kt"
|
||||
}
|
||||
|
||||
task when5(type: UnitKonanTest) {
|
||||
task when5(type: RunKonanTest) {
|
||||
source = "codegen/branching/when5.kt"
|
||||
}
|
||||
|
||||
task when_through(type: UnitKonanTest) {
|
||||
task when_through(type: RunKonanTest) {
|
||||
source = "codegen/branching/when_through.kt"
|
||||
}
|
||||
|
||||
task advanced_when2(type: UnitKonanTest) {
|
||||
task advanced_when2(type: RunKonanTest) {
|
||||
source = "codegen/branching/advanced_when2.kt"
|
||||
}
|
||||
|
||||
task advanced_when5(type: UnitKonanTest) {
|
||||
task advanced_when5(type: RunKonanTest) {
|
||||
source = "codegen/branching/advanced_when5.kt"
|
||||
}
|
||||
|
||||
task bool_yes(type: UnitKonanTest) {
|
||||
task bool_yes(type: RunKonanTest) {
|
||||
source = "codegen/function/boolean.kt"
|
||||
}
|
||||
|
||||
task plus_eq(type: UnitKonanTest) {
|
||||
task plus_eq(type: RunKonanTest) {
|
||||
source = "codegen/function/plus_eq.kt"
|
||||
}
|
||||
|
||||
task minus_eq(type: UnitKonanTest) {
|
||||
task minus_eq(type: RunKonanTest) {
|
||||
source = "codegen/function/minus_eq.kt"
|
||||
}
|
||||
|
||||
task eqeq(type: UnitKonanTest) {
|
||||
task eqeq(type: RunKonanTest) {
|
||||
source = "codegen/function/eqeq.kt"
|
||||
}
|
||||
|
||||
task cycle(type: UnitKonanTest) {
|
||||
task cycle(type: RunKonanTest) {
|
||||
source = "codegen/cycles/cycle.kt"
|
||||
}
|
||||
|
||||
task cycle_do(type: UnitKonanTest) {
|
||||
task cycle_do(type: RunKonanTest) {
|
||||
source = "codegen/cycles/cycle_do.kt"
|
||||
}
|
||||
|
||||
task abstract_super(type: UnitKonanTest) {
|
||||
task abstract_super(type: RunKonanTest) {
|
||||
source = "datagen/rtti/abstract_super.kt"
|
||||
}
|
||||
|
||||
task vtable1(type: UnitKonanTest) {
|
||||
task vtable1(type: RunKonanTest) {
|
||||
source = "datagen/rtti/vtable1.kt"
|
||||
}
|
||||
|
||||
@@ -439,7 +415,7 @@ task empty_string(type: RunKonanTest) {
|
||||
source = "datagen/literals/empty_string.kt"
|
||||
}
|
||||
|
||||
task intrinsic(type: UnitKonanTest) {
|
||||
task intrinsic(type: RunKonanTest) {
|
||||
source = "codegen/function/intrinsic.kt"
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*castTest)() = resolve_symbol("kfun:castTest()");
|
||||
|
||||
if (!castTest()) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -8,3 +8,7 @@ fun castTest(): Boolean {
|
||||
castSimple(b)
|
||||
return true
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (!castTest()) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*local_variable)(int) = resolve_symbol("kfun:local_variable(Int)");
|
||||
|
||||
if (local_variable(3) != 14) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2,4 +2,8 @@ fun local_variable(a: Int) : Int {
|
||||
var b = 0
|
||||
b = a + 11
|
||||
return b
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (local_variable(3) != 14) throw Error()
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
uint8_t (*null_check_eqeq1 )() = resolve_symbol("kfun:null_check_eqeq1()");
|
||||
uint8_t (*null_check_eqeq2 )() = resolve_symbol("kfun:null_check_eqeq2()");
|
||||
uint8_t (*null_check_eqeqeq1)() = resolve_symbol("kfun:null_check_eqeqeq1()");
|
||||
uint8_t (*null_check_eqeqeq2)() = resolve_symbol("kfun:null_check_eqeqeq2()");
|
||||
|
||||
if (null_check_eqeq1()) return 1;
|
||||
if (!null_check_eqeq2()) return 1;
|
||||
if (null_check_eqeqeq1()) return 1;
|
||||
if (!null_check_eqeqeq2()) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -21,3 +21,10 @@ fun null_check_eqeqeq1() : Boolean {
|
||||
fun null_check_eqeqeq2() : Boolean {
|
||||
return check_eqeqeq(null)
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (null_check_eqeq1()) throw Error()
|
||||
if (!null_check_eqeq2()) throw Error()
|
||||
if (null_check_eqeqeq1()) throw Error()
|
||||
if (!null_check_eqeqeq2()) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*advanced_when2)(int) = resolve_symbol("kfun:advanced_when2(Int)");
|
||||
|
||||
if (advanced_when2(10) != 42) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -9,3 +9,6 @@ fun advanced_when2(i: Int): Int {
|
||||
return value
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (advanced_when2(10) != 42) throw Error()
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*advanced_when5)(int) = resolve_symbol("kfun:advanced_when5(Int)");
|
||||
|
||||
if (advanced_when5(5) != 24) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -7,4 +7,8 @@ fun advanced_when5(i: Int): Int {
|
||||
4 -> { val v = 42; return v}
|
||||
else -> return 24
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (advanced_when5(5) != 24) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*if_else)(int) = resolve_symbol("kfun:if_else(Boolean)");
|
||||
|
||||
if (if_else(0) != 24) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
fun if_else(b: Boolean): Int {
|
||||
if (b) return 42
|
||||
else return 24
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (if_else(false) != 24) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*when2)(int) = resolve_symbol("kfun:when2(Int)");
|
||||
|
||||
if (when2(0) != 42) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -3,4 +3,8 @@ fun when2(i: Int): Int {
|
||||
0 -> return 42
|
||||
else -> return 24
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (when2(0) != 42) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*when5)(int) = resolve_symbol("kfun:when5(Int)");
|
||||
|
||||
if (when5(2) != 3) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -7,4 +7,8 @@ fun when5(i: Int): Int {
|
||||
4 -> return 1
|
||||
else -> return 24
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (when5(2) != 3) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*when_through)(int) = resolve_symbol("kfun:when_through(Int)");
|
||||
|
||||
if (when_through(2) != 1) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -8,3 +8,7 @@ fun when_through(i: Int): Int {
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (when_through(2) != 1) throw Error()
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*cycle)(int) = resolve_symbol("kfun:cycle(Int)");
|
||||
|
||||
if (cycle(1) != 2) return 1;
|
||||
if (cycle(0) != 1) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,3 +5,8 @@ fun cycle(cnt: Int): Int {
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (cycle(1) != 2) throw Error()
|
||||
if (cycle(0) != 1) throw Error()
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*cycle_do)(int) = resolve_symbol("kfun:cycle_do(Int)");
|
||||
|
||||
if (cycle_do(3) != 5) return 1;
|
||||
if (cycle_do(0) != 3) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,3 +5,8 @@ fun cycle_do(cnt: Int): Int {
|
||||
} while (sum == cnt)
|
||||
return sum
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (cycle_do(3) != 5) throw Error()
|
||||
if (cycle_do(0) != 3) throw Error()
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*square)(int) = resolve_symbol("kfun:square(Int)");
|
||||
int (*sum_of_squares)(int, int) = resolve_symbol("kfun:sumOfSquares(Int;Int)");
|
||||
int (*diff_of_squares)(int, int) = resolve_symbol("kfun:diffOfSquares(Int;Int)");
|
||||
int (*mod)(int, int) = resolve_symbol("kfun:mod(Int;Int)");
|
||||
int (*div)(int, int) = resolve_symbol("kfun:remainder(Int;Int)");
|
||||
|
||||
if (square(2) != 4) return 1;
|
||||
if (sum_of_squares(2, 4) != 20) return 1;
|
||||
if (diff_of_squares(2, 4) != -12) return 1;
|
||||
if (mod(5, 2) != 2) return 1;
|
||||
if (div(5, 2) != 1) return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -2,4 +2,12 @@ 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
|
||||
fun remainder(a:Int, b:Int):Int = a % b
|
||||
|
||||
fun main(args:Array<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()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*bool_yes)() = resolve_symbol("kfun:bool_yes()");
|
||||
|
||||
if (!bool_yes()) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1 +1,5 @@
|
||||
fun bool_yes(): Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (!bool_yes()) throw Error()
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#include <stdint.h>
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
void *(*helloString)() = resolve_symbol("kfun:helloString()");
|
||||
void *(*goodbyeString)() = resolve_symbol("kfun:goodbyeString()");
|
||||
|
||||
uint8_t (*eqeqB)(uint8_t, uint8_t) = resolve_symbol("kfun:eqeqB(Byte;Byte)");
|
||||
uint8_t (*eqeqS)(int16_t, int16_t) = resolve_symbol("kfun:eqeqS(Short;Short)");
|
||||
uint8_t (*eqeqI)(int , int ) = resolve_symbol("kfun:eqeqI(Int;Int)");
|
||||
uint8_t (*eqeqL)(int64_t, int64_t) = resolve_symbol("kfun:eqeqL(Long;Long)");
|
||||
uint8_t (*eqeqF)(float , float ) = resolve_symbol("kfun:eqeqF(Float;Float)");
|
||||
uint8_t (*eqeqD)(double , double ) = resolve_symbol("kfun:eqeqD(Double;Double)");
|
||||
uint8_t (*eqeqStr)(void *, void *) = resolve_symbol("kfun:eqeqStr(String;String)");
|
||||
uint8_t (*eqeqeq)(void *, void *) = resolve_symbol("kfun:eqeqeq(Any?;Any?)");
|
||||
|
||||
uint8_t (*gtI )(int , int ) = resolve_symbol("kfun:gtI(Int;Int)");
|
||||
uint8_t (*ltI )(int , int ) = resolve_symbol("kfun:ltI(Int;Int)");
|
||||
uint8_t (*geI )(int , int ) = resolve_symbol("kfun:geI(Int;Int)");
|
||||
uint8_t (*leI )(int , int ) = resolve_symbol("kfun:leI(Int;Int)");
|
||||
uint8_t (*neI )(int , int ) = resolve_symbol("kfun:neI(Int;Int)");
|
||||
|
||||
uint8_t (*gtF )(float , float ) = resolve_symbol("kfun:gtF(Float;Float)");
|
||||
uint8_t (*ltF )(float , float ) = resolve_symbol("kfun:ltF(Float;Float)");
|
||||
uint8_t (*geF )(float , float ) = resolve_symbol("kfun:geF(Float;Float)");
|
||||
uint8_t (*leF )(float , float ) = resolve_symbol("kfun:leF(Float;Float)");
|
||||
uint8_t (*neF )(float , float ) = resolve_symbol("kfun:neF(Float;Float)");
|
||||
|
||||
if (!eqeqB(3 , 3 )) return 1;
|
||||
if (!eqeqS(3 , 3 )) return 1;
|
||||
if (!eqeqI(3 , 3 )) return 1;
|
||||
if (!eqeqL(3ll , 3ll )) return 1;
|
||||
if (!eqeqF(3.0f, 3.0f)) return 1;
|
||||
if (!eqeqD(3.0 , 3.0 )) return 1;
|
||||
|
||||
if (!eqeqStr(helloString(), helloString())) return 1;
|
||||
if (!eqeqeq(helloString(), helloString())) return 1;
|
||||
if (eqeqeq(helloString(), goodbyeString())) return 1;
|
||||
|
||||
if (gtI (2 , 3 )) return 1;
|
||||
if (ltI (3 , 2 )) return 1;
|
||||
if (geI (2 , 3 )) return 1;
|
||||
if (leI (3 , 2 )) return 1;
|
||||
if (neI (2 , 2 )) return 1;
|
||||
|
||||
if (gtF (2.0 , 3.0 )) return 1;
|
||||
if (ltF (3.0 , 2.0 )) return 1;
|
||||
if (geF (2.0 , 3.0 )) return 1;
|
||||
if (leF (3.0 , 2.0 )) return 1;
|
||||
if (neF (2.0 , 2.0 )) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -21,4 +21,29 @@ fun leF (a:Float, b:Float ) = a <= b
|
||||
fun neF (a:Float, b:Float ) = a != b
|
||||
|
||||
fun helloString() = "Hello"
|
||||
fun goodbyeString() = "Goodbye"
|
||||
fun goodbyeString() = "Goodbye"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (!eqeqB(3 , 3 )) throw Error()
|
||||
if (!eqeqS(3 , 3 )) throw Error()
|
||||
if (!eqeqI(3 , 3 )) throw Error()
|
||||
if (!eqeqL(3L , 3L )) throw Error()
|
||||
if (!eqeqF(3.0f, 3.0f)) throw Error()
|
||||
if (!eqeqD(3.0 , 3.0 )) throw Error()
|
||||
|
||||
if (!eqeqStr(helloString(), helloString())) throw Error()
|
||||
if (!eqeqeq(helloString(), helloString())) throw Error()
|
||||
if (eqeqeq(helloString(), goodbyeString())) throw Error()
|
||||
|
||||
if (gtI (2 , 3 )) throw Error()
|
||||
if (ltI (3 , 2 )) throw Error()
|
||||
if (geI (2 , 3 )) throw Error()
|
||||
if (leI (3 , 2 )) throw Error()
|
||||
if (neI (2 , 2 )) throw Error()
|
||||
|
||||
if (gtF (2.0f , 3.0f )) throw Error()
|
||||
if (ltF (3.0f , 2.0f )) throw Error()
|
||||
if (geF (2.0f , 3.0f )) throw Error()
|
||||
if (leF (3.0f , 2.0f )) throw Error()
|
||||
if (neF (2.0f , 2.0f )) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*intrinsic)(int) = resolve_symbol("kfun:intrinsic(Int)");
|
||||
|
||||
if (intrinsic(3) != 4) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -9,3 +9,7 @@ fun intrinsic(b: Int): Int {
|
||||
sum = sum + b
|
||||
return sum
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (intrinsic(3) != 4) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*minus_eq)(int) = resolve_symbol("kfun:minus_eq(Int)");
|
||||
|
||||
if (minus_eq(23) != -12) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -3,3 +3,7 @@ fun minus_eq(a: Int): Int {
|
||||
b -= a
|
||||
return b
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (minus_eq(23) != -12) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*plus_eq)(int) = resolve_symbol("kfun:plus_eq(Int)");
|
||||
|
||||
if (plus_eq(3) != 14) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2,4 +2,8 @@ fun plus_eq(a: Int): Int {
|
||||
var b = 11
|
||||
b += a
|
||||
return b
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (plus_eq(3) != 14) throw Error()
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#include <stdint.h>
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*sumIB)(int, uint8_t) = resolve_symbol("kfun:sumIB(Int;Byte)");
|
||||
int (*sumIS)(int, int16_t) = resolve_symbol("kfun:sumIS(Int;Short)");
|
||||
int (*sumII)(int, int ) = resolve_symbol("kfun:sumII(Int;Int)");
|
||||
int64_t (*sumIL)(int, int64_t) = resolve_symbol("kfun:sumIL(Int;Long)");
|
||||
float (*sumIF)(int, float ) = resolve_symbol("kfun:sumIF(Int;Float)");
|
||||
double (*sumID)(int, double ) = resolve_symbol("kfun:sumID(Int;Double)");
|
||||
double (*modID)(int, double ) = resolve_symbol("kfun:modID(Int;Double)");
|
||||
if (sumIB(2, 3) != 5) return 1;
|
||||
if (sumIS(2, 3) != 5) return 1;
|
||||
if (sumII(2, 3) != 5) return 1;
|
||||
if (sumIL(2, 3l) != 5l) return 1;
|
||||
if (sumIF(2, 3.0f) != 5.0f) return 1;
|
||||
if (sumID(2, 3.0) != 5.0) return 1;
|
||||
if (modID(5, 3.0) != 2.0) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,4 +5,14 @@ fun sumIL(a:Int, b:Long ) = a + b
|
||||
fun sumIF(a:Int, b:Float ) = a + b
|
||||
fun sumID(a:Int, b:Double) = a + b
|
||||
|
||||
fun modID(a:Int, b:Double) = a % b
|
||||
fun modID(a:Int, b:Double) = a % b
|
||||
|
||||
fun main(args:Array<String>) {
|
||||
if (sumIB(2, 3) != 5) throw Error()
|
||||
if (sumIS(2, 3) != 5) throw Error()
|
||||
if (sumII(2, 3) != 5) throw Error()
|
||||
if (sumIL(2, 3L) != 5L) throw Error()
|
||||
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()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*sum3)() = resolve_symbol("kfun:sum3()");
|
||||
|
||||
if (sum3() != 36) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,2 +1,6 @@
|
||||
fun sum3():Int = sum(1, 2, 33)
|
||||
fun sum(a:Int, b:Int, c:Int): Int = a + b + c
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (sum3() != 36) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*sum)(int, int) = resolve_symbol("kfun:sumFooBar(Int;Int)");
|
||||
|
||||
if (sum(2, 3) != 5) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
fun foo(a:Int):Int = a
|
||||
fun bar(a:Int):Int = a
|
||||
|
||||
fun sumFooBar(a:Int, b:Int):Int = foo(a) + bar(b)
|
||||
fun sumFooBar(a:Int, b:Int):Int = foo(a) + bar(b)
|
||||
|
||||
fun main(args:Array<String>) {
|
||||
if (sumFooBar(2, 3) != 5) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*sum)(int) = resolve_symbol("kfun:sum(Int)");
|
||||
|
||||
if (sum(2) != 35) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1 +1,5 @@
|
||||
fun sum(a:Int): Int = a + 33
|
||||
fun sum(a:Int): Int = a + 33
|
||||
|
||||
fun main(args:Array<String>) {
|
||||
if (sum(2) != 35) throw Error()
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
class Foo {
|
||||
var x : Int = 3
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*globalTest)() = resolve_symbol("kfun:globalTest(Int)");
|
||||
int (*getGlobal)() = resolve_symbol("kfun:<get-globalValue>()");
|
||||
|
||||
if (getGlobal() != 1) return 1;
|
||||
if (globalTest(41) != 42) return 1;
|
||||
if (getGlobal() != 42) return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -6,4 +6,11 @@ var global:Int
|
||||
fun globalTest(i:Int):Int {
|
||||
global += i
|
||||
return global
|
||||
}
|
||||
|
||||
|
||||
fun main(args:Array<String>) {
|
||||
if (global != 1) throw Error()
|
||||
if (globalTest(41) != 42) throw Error()
|
||||
if (global != 42) throw Error()
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*primary_constructor)(int, int) = resolve_symbol("kfun:primaryConstructorCall(Int;Int)");
|
||||
int (*secondary_constructor)(int) = resolve_symbol("kfun:secondaryConstructorCall(Int)");
|
||||
|
||||
if (primary_constructor(0xdeadbeef, 41) != 42) return 1;
|
||||
|
||||
if (secondary_constructor(41) != 42) return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -5,4 +5,9 @@ class B(val a:Int, b:Int) {
|
||||
|
||||
fun primaryConstructorCall(a:Int, b:Int) = B(a, b).pos
|
||||
|
||||
fun secondaryConstructorCall(a:Int) = B(a).pos
|
||||
fun secondaryConstructorCall(a:Int) = B(a).pos
|
||||
|
||||
fun main(args:Array<String>) {
|
||||
if (primaryConstructorCall(0xdeadbeef.toInt(), 41) != 42) throw Error()
|
||||
if (secondaryConstructorCall(41) != 42) throw Error()
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*foo)(int, int) = resolve_symbol("kfun:foo(Int;Int)");
|
||||
|
||||
if (foo(2, 3) != 5) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -17,4 +17,8 @@ fun foo(i:Int) : Unit {}
|
||||
fun foo(i:Int, j:Int):Int {
|
||||
val c = D(i, j)
|
||||
return c.c
|
||||
}
|
||||
|
||||
fun main(args:Array<String>) {
|
||||
if (foo(2, 3) != 5) throw Error()
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
int (*fortyTwo)() = resolve_symbol("kfun:fortyTwo()");
|
||||
|
||||
if (fortyTwo() != 42) return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -2,4 +2,8 @@ class A(val a:Int) {
|
||||
fun foo(i:Int) = a + i
|
||||
}
|
||||
|
||||
fun fortyTwo() = A(41).foo(1)
|
||||
fun fortyTwo() = A(41).foo(1)
|
||||
|
||||
fun main(args:Array<String>) {
|
||||
if (fortyTwo() != 42) throw Error()
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
// This test now checks that the source can be successfully compiled and linked;
|
||||
// TODO: check the contents of TypeInfo?
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
abstract class Super
|
||||
|
||||
class Foo : Super()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
// This test now checks that the source can be successfully compiled and linked;
|
||||
// TODO: check the contents of TypeInfo?
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
extern void *resolve_symbol(const char*);
|
||||
|
||||
int
|
||||
run_test() {
|
||||
// This test now checks that the source can be successfully compiled and linked;
|
||||
// TODO: check the contents of TypeInfo?
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,3 +5,8 @@ abstract class Super {
|
||||
class Foo : Super() {
|
||||
final override fun bar() {}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
// This test now checks that the source can be successfully compiled and linked;
|
||||
// TODO: check the contents of TypeInfo?
|
||||
}
|
||||
Reference in New Issue
Block a user