From c8f73cfdae0a6a497180dac8d060c9b967cd9bcd Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 24 Jan 2013 22:00:03 +0400 Subject: [PATCH] Remove codegen tests out of JetNpeTest --- .../primitiveTypes/intLiteralIsNotNull.kt | 1 + .../primitiveTypes/nullAsNullableIntIsNull.kt | 9 ++++++++ .../jet/codegen/PrimitiveTypesTest.java | 8 +++++++ .../org/jetbrains/jet/runtime/JetNpeTest.java | 21 ++----------------- 4 files changed, 20 insertions(+), 19 deletions(-) create mode 100644 compiler/testData/codegen/primitiveTypes/intLiteralIsNotNull.kt create mode 100644 compiler/testData/codegen/primitiveTypes/nullAsNullableIntIsNull.kt diff --git a/compiler/testData/codegen/primitiveTypes/intLiteralIsNotNull.kt b/compiler/testData/codegen/primitiveTypes/intLiteralIsNotNull.kt new file mode 100644 index 00000000000..d9f9d0420f1 --- /dev/null +++ b/compiler/testData/codegen/primitiveTypes/intLiteralIsNotNull.kt @@ -0,0 +1 @@ +fun box() = if (10!! == 10) "OK" else "fail" diff --git a/compiler/testData/codegen/primitiveTypes/nullAsNullableIntIsNull.kt b/compiler/testData/codegen/primitiveTypes/nullAsNullableIntIsNull.kt new file mode 100644 index 00000000000..66bd59b3fd3 --- /dev/null +++ b/compiler/testData/codegen/primitiveTypes/nullAsNullableIntIsNull.kt @@ -0,0 +1,9 @@ +fun box(): String { + try { + if ((null : Int?)!! == 10) return "Fail #1" + return "Fail #2" + } + catch (e: Exception) { + return "OK" + } +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index 1c6d66b517e..144b714a462 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -449,4 +449,12 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testKt3078() { blackBoxFile("regressions/kt3078.kt"); } + + public void testIntLiteralIsNotNull() { + blackBoxFile("primitiveTypes/intLiteralIsNotNull.kt"); + } + + public void testNullAsNullableIntIsNull() { + blackBoxFile("primitiveTypes/nullAsNullableIntIsNull.kt"); + } } diff --git a/compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java b/compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java index 7ca461f2c30..563997ccfbd 100644 --- a/compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java +++ b/compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java @@ -16,20 +16,15 @@ package org.jetbrains.jet.runtime; +import com.intellij.testFramework.UsefulTestCase; import jet.runtime.Intrinsics; -import org.jetbrains.jet.codegen.CodegenTestCase; -import java.lang.reflect.Method; - -public class JetNpeTest extends CodegenTestCase { +public class JetNpeTest extends UsefulTestCase { @Override protected void setUp() throws Exception { super.setUp(); - createEnvironmentWithMockJdkAndIdeaAnnotations(); } - - public void testStackTrace () { try { Intrinsics.throwNpe(); @@ -41,16 +36,4 @@ public class JetNpeTest extends CodegenTestCase { assertEquals(stackTraceElement.getClassName(), "org.jetbrains.jet.runtime.JetNpeTest"); } } - - public void testNotNull () throws Exception { - loadText("fun box() = if(10!! == 10) \"OK\" else \"fail\""); - blackBox(); - } - - public void testNull () throws Exception { - loadText("fun box() = if((null : Int?)!! == 10) \"OK\" else \"fail\""); -// System.out.println(generateToText()); - Method box = generateFunction("box"); - assertThrows(box, NullPointerException.class, null); - } }