TEST: Tests for "null" constant added
This commit is contained in:
committed by
vvlevchenko
parent
cf466e0cd7
commit
df358e8bd4
@@ -256,10 +256,15 @@ task local_variable(type: UnitKonanTest) {
|
|||||||
source = "codegen/basics/local_variable.kt"
|
source = "codegen/basics/local_variable.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
task cast_simple(type: UnitKonanTest) {
|
task cast_simple(type: UnitKonanTest) {
|
||||||
source = "codegen/basics/cast_simple.kt"
|
source = "codegen/basics/cast_simple.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task null_check(type: UnitKonanTest) {
|
||||||
|
source = "codegen/basics/null_check.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task hello0(type: RunKonanTest) {
|
task hello0(type: RunKonanTest) {
|
||||||
goldValue = "Hello, world!\n"
|
goldValue = "Hello, world!\n"
|
||||||
source = "runtime/basic/hello0.kt"
|
source = "runtime/basic/hello0.kt"
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
//--- Test "eqeq" -------------------------------------------------------------//
|
||||||
|
|
||||||
|
fun check_eqeq(a: Any?) = a == null
|
||||||
|
|
||||||
|
fun null_check_eqeq1() : Boolean {
|
||||||
|
return check_eqeq(Any())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun null_check_eqeq2() : Boolean {
|
||||||
|
return check_eqeq(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
//--- Test "eqeqeq" -----------------------------------------------------------//
|
||||||
|
|
||||||
|
fun check_eqeqeq(a: Any?) = a === null
|
||||||
|
|
||||||
|
fun null_check_eqeqeq1() : Boolean {
|
||||||
|
return check_eqeqeq(Any())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun null_check_eqeqeq2() : Boolean {
|
||||||
|
return check_eqeqeq(null)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user