Boundary values and their toString() test. (#90)
This commit is contained in:
+8
-2
@@ -620,6 +620,7 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
LLVMSetInitializer(objectPtr, codegen.kNullObjHeaderPtr)
|
||||
}
|
||||
|
||||
val bbCurrent = codegen.currentBlock
|
||||
val bbInit = codegen.basicBlock("label_init")
|
||||
val bbExit = codegen.basicBlock("label_continue")
|
||||
val onePtr = codegen.intToPtr(kImmInt64One, codegen.kObjHeaderPtr, codegen.newVar())
|
||||
@@ -633,11 +634,16 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
val initFunction = value.descriptor.constructors.first { it.valueParameters.size == 0 }
|
||||
val ctor = codegen.llvmFunction(initFunction)
|
||||
val args = listOf(objectPtr, typeInfo, allocHint, ctor)
|
||||
currentCodeContext.genCall(context.initInstanceFunction, args, codegen.newVar())
|
||||
val newValue = currentCodeContext.genCall(
|
||||
context.initInstanceFunction, args, codegen.newVar())
|
||||
codegen.br(bbExit)
|
||||
|
||||
codegen.positionAtEnd(bbExit)
|
||||
return objectVal
|
||||
val valuePhi = codegen.phi(codegen.getLLVMType(value.type), codegen.newVar())
|
||||
codegen.addPhiIncoming(valuePhi,
|
||||
bbCurrent to objectVal, bbInit to newValue)
|
||||
|
||||
return valuePhi
|
||||
}
|
||||
//-------------------------------------------------------------------------//
|
||||
|
||||
|
||||
@@ -342,6 +342,14 @@ task tostring2(type: RunKonanTest) {
|
||||
source = "runtime/basic/tostring2.kt"
|
||||
}
|
||||
|
||||
task tostring3(type: RunKonanTest) {
|
||||
goldValue = "-128\n127\n-32768\n32767\n" +
|
||||
"-2147483648\n2147483647\n-9223372036854775808\n9223372036854775807\n" +
|
||||
"1.17549E-38\n3.40282E+38\n-INF\nINF\nNAN\n" +
|
||||
"4.94066E-324\n1.79769E+308\nINF\nINF\nNAN\n"
|
||||
source = "runtime/basic/tostring3.kt"
|
||||
}
|
||||
|
||||
task empty_substring(type: RunKonanTest) {
|
||||
goldValue = "\n"
|
||||
source = "runtime/basic/empty_substring.kt"
|
||||
@@ -349,12 +357,12 @@ task empty_substring(type: RunKonanTest) {
|
||||
|
||||
task array0(type: RunKonanTest) {
|
||||
goldValue = "5\n6\n7\n8\n9\n10\n11\n12\n13\n"
|
||||
source = "runtime/basic/array0.kt"
|
||||
source = "runtime/collections/array0.kt"
|
||||
}
|
||||
|
||||
task array1(type: RunKonanTest) {
|
||||
goldValue = "4 2\n1-1\n69\n38\n"
|
||||
source = "runtime/basic/array1.kt"
|
||||
source = "runtime/collections/array1.kt"
|
||||
}
|
||||
|
||||
task if_else(type: UnitKonanTest) {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
fun testByte() {
|
||||
val values = ByteArray(2)
|
||||
values[0] = Byte.MIN_VALUE
|
||||
values[1] = Byte.MAX_VALUE
|
||||
for (v in values) {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
|
||||
fun testShort() {
|
||||
val values = ShortArray(2)
|
||||
values[0] = Short.MIN_VALUE
|
||||
values[1] = Short.MAX_VALUE
|
||||
for (v in values) {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
|
||||
fun testInt() {
|
||||
val values = IntArray(2)
|
||||
values[0] = Int.MIN_VALUE
|
||||
values[1] = Int.MAX_VALUE
|
||||
for (v in values) {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
|
||||
fun testLong() {
|
||||
val values = LongArray(2)
|
||||
values[0] = Long.MIN_VALUE
|
||||
values[1] = Long.MAX_VALUE
|
||||
for (v in values) {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
|
||||
fun testFloat() {
|
||||
val values = FloatArray(5)
|
||||
values[0] = Float.MIN_VALUE
|
||||
values[1] = Float.MAX_VALUE
|
||||
values[2] = Float.NEGATIVE_INFINITY
|
||||
values[3] = Float.POSITIVE_INFINITY
|
||||
values[4] = Float.NaN
|
||||
for (v in values) {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
|
||||
fun testDouble() {
|
||||
val values = DoubleArray(5)
|
||||
values[0] = Double.MIN_VALUE
|
||||
values[1] = Double.MAX_VALUE
|
||||
values[2] = Double.NEGATIVE_INFINITY
|
||||
values[3] = Double.POSITIVE_INFINITY
|
||||
values[4] = Double.NaN
|
||||
for (v in values) {
|
||||
println(v)
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
testByte()
|
||||
testShort()
|
||||
testInt()
|
||||
testLong()
|
||||
testFloat()
|
||||
testDouble()
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user