From 17a9772feeb331619cf4f3cb43119c0766817fe4 Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Thu, 16 Aug 2012 15:48:45 +0300 Subject: [PATCH] test for obsolete KT-1649 --- .../testData/codegen/regressions/kt1649_1.kt | 9 ++++ .../testData/codegen/regressions/kt1649_2.kt | 9 ++++ .../jet/codegen/FunctionGenTest.java | 46 +++++++++++-------- 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 compiler/testData/codegen/regressions/kt1649_1.kt create mode 100644 compiler/testData/codegen/regressions/kt1649_2.kt diff --git a/compiler/testData/codegen/regressions/kt1649_1.kt b/compiler/testData/codegen/regressions/kt1649_1.kt new file mode 100644 index 00000000000..d3691a55633 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt1649_1.kt @@ -0,0 +1,9 @@ +trait A { + val method : (() -> Unit)? +} + +fun test(a : A) { + if (a.method != null) { + a.method!!() + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/regressions/kt1649_2.kt b/compiler/testData/codegen/regressions/kt1649_2.kt new file mode 100644 index 00000000000..e76f4994147 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt1649_2.kt @@ -0,0 +1,9 @@ +trait A { + val method : () -> Unit? +} + +fun test(a : A) { + if (a.method != null) { + a.method!!() + } +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java index 7b1abba69f2..b7f90099a60 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java @@ -40,32 +40,32 @@ public class FunctionGenTest extends CodegenTestCase { public void testDefaultArgs() throws Exception { blackBoxFile("functions/defaultargs.jet"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); } public void testDefaultArgs1() throws Exception { blackBoxFile("functions/defaultargs1.jet"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); } public void testDefaultArgs2() throws Exception { blackBoxFile("functions/defaultargs2.jet"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); } public void testDefaultArgs3() throws Exception { blackBoxFile("functions/defaultargs3.jet"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); } public void testDefaultArgs4() throws Exception { blackBoxFile("functions/defaultargs4.jet"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); } public void testDefaultArgs5() throws Exception { blackBoxFile("functions/defaultargs5.jet"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); } public void testDefaultArgs6() { @@ -78,50 +78,50 @@ public class FunctionGenTest extends CodegenTestCase { public void testNoThisNoClosure() throws Exception { blackBoxFile("functions/nothisnoclosure.jet"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); } - public void testAnyEqualsNullable () throws InvocationTargetException, IllegalAccessException { + public void testAnyEqualsNullable() throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any?) = x.equals(\"lala\")"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); Method foo = generateFunction(); assertTrue((Boolean) foo.invoke(null, "lala")); assertFalse((Boolean) foo.invoke(null, "mama")); } - public void testAnyEquals () throws InvocationTargetException, IllegalAccessException { + public void testAnyEquals() throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any) = x.equals(\"lala\")"); -// System.out.println(generateToText()); + // System.out.println(generateToText()); Method foo = generateFunction(); assertTrue((Boolean) foo.invoke(null, "lala")); assertFalse((Boolean) foo.invoke(null, "mama")); } - public void testKt395 () { + public void testKt395() { blackBoxFile("regressions/kt395.jet"); } - public void testKt785 () { + public void testKt785() { blackBoxFile("regressions/kt785.jet"); } - public void testKt873 () { + public void testKt873() { blackBoxFile("regressions/kt873.kt"); } - public void testKt1413 () { + public void testKt1413() { blackBoxFile("regressions/kt1413.kt"); } - public void testKt1199 () { + public void testKt1199() { blackBoxFile("regressions/kt1199.kt"); } - public void testFunction () throws InvocationTargetException, IllegalAccessException { + public void testFunction() throws InvocationTargetException, IllegalAccessException { blackBoxFile("functions/functionExpression.jet"); } - public void testLocalFunction () throws InvocationTargetException, IllegalAccessException { + public void testLocalFunction() throws InvocationTargetException, IllegalAccessException { blackBoxFile("functions/localFunction.kt"); } @@ -149,6 +149,16 @@ public class FunctionGenTest extends CodegenTestCase { blackBoxFile("regressions/kt2270.kt"); } + public void testK1649_1() { + loadFile("regressions/kt1649_1.kt"); + generateToText(); + } + + public void testK1649_2() { + loadFile("regressions/kt1649_2.kt"); + generateToText(); + } + public static class WithJavaFunctionGenTest extends CodegenTestCase { private void blackBoxFileWithJava(@NotNull String ktFile) throws Exception { File javaClassesTempDirectory = new File(FileUtil.getTempDirectory(), "java-classes");