From 9165d65560bd923985a8d0353065b94800a4a24d Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Wed, 22 Feb 2017 14:37:42 +0300 Subject: [PATCH] Added tests on interface calls of enum class --- backend.native/tests/build.gradle | 10 +++++++++ .../codegen/enum/interfaceCallNoEntryClass.kt | 19 ++++++++++++++++ .../enum/interfaceCallWithEntryClass.kt | 22 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 backend.native/tests/codegen/enum/interfaceCallNoEntryClass.kt create mode 100644 backend.native/tests/codegen/enum/interfaceCallWithEntryClass.kt diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 6fa2cbde478..fc1f56b8ac6 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -366,6 +366,16 @@ task enum_companionObject(type: RunKonanTest) { source = "codegen/enum/companionObject.kt" } +task enum_interfaceCallNoEntryClass(type: RunKonanTest) { + goldValue = "('z3', 3)\n('z3', 3)\n" + source = "codegen/enum/interfaceCallNoEntryClass.kt" +} + +task enum_interfaceCallWithEntryClass(type: RunKonanTest) { + goldValue = "z1z2\nz1z2\n" + source = "codegen/enum/interfaceCallWithEntryClass.kt" +} + task innerClass_simple(type: RunKonanTest) { goldValue = "OK\n" source = "codegen/innerClass/simple.kt" diff --git a/backend.native/tests/codegen/enum/interfaceCallNoEntryClass.kt b/backend.native/tests/codegen/enum/interfaceCallNoEntryClass.kt new file mode 100644 index 00000000000..a340c7afb9f --- /dev/null +++ b/backend.native/tests/codegen/enum/interfaceCallNoEntryClass.kt @@ -0,0 +1,19 @@ +interface A { + fun foo(): String +} + +enum class Zzz(val zzz: String, val x: Int) : A { + Z1("z1", 1), + Z2("z2", 2), + Z3("z3", 3); + + override fun foo(): String{ + return "('$zzz', $x)" + } +} + +fun main(args: Array) { + println(Zzz.Z3.foo()) + val a: A = Zzz.Z3 + println(a.foo()) +} \ No newline at end of file diff --git a/backend.native/tests/codegen/enum/interfaceCallWithEntryClass.kt b/backend.native/tests/codegen/enum/interfaceCallWithEntryClass.kt new file mode 100644 index 00000000000..bc64cf70ae1 --- /dev/null +++ b/backend.native/tests/codegen/enum/interfaceCallWithEntryClass.kt @@ -0,0 +1,22 @@ +interface A { + fun f(): String +} + +enum class Zzz: A { + Z1 { + override fun f() = "z1" + }, + + Z2 { + override fun f() = "z2" + }; + + override fun f() = "" +} + +fun main(args: Array) { + println(Zzz.Z1.f() + Zzz.Z2.f()) + val a1: A = Zzz.Z1 + val a2: A = Zzz.Z2 + println(a1.f() + a2.f()) +} \ No newline at end of file