From 1c395ef0df48dbec88a9403b2c7d545ce4d60e39 Mon Sep 17 00:00:00 2001 From: Vladimir Sukharev Date: Tue, 10 Oct 2023 10:41:58 +0200 Subject: [PATCH] [FIR-TEST] Remove accidentally committed testfiles --- ...0.fir.kt351.fir.kt735_StatementType.fir.kt | 162 ------------------ .../when.fir.kt234.fir.kt973.fir.kt | 41 ----- 2 files changed, 203 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/controlStructures/when.fir.kt234.fir.kt973.fir.kt diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt deleted file mode 100644 index f3377aea151..00000000000 --- a/compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt +++ /dev/null @@ -1,162 +0,0 @@ -// !DIAGNOSTICS: -UNREACHABLE_CODE -package kt770_351_735 - - -//KT-770 Reference is not resolved to anything, but is not marked unresolved -fun main() { - var i = 0 - when (i) { - 1 -> i-- - 2 -> i = 2 // i is surrounded by a black border - else -> j = 2 - } - System.out.println(i) -} - -//KT-351 Distinguish statement and expression positions -val w = while (true) {} - -fun foo() { - var z = 2 - val r = { // type fun(): Any is inferred - if (true) { - 2 - } - else { - z = 34 - } - } - val f: ()-> Int = r - val g: ()-> Any = r -} - -//KT-735 Statements without braces are prohibited on the right side of when entries. -fun box() : Int { - val d = 2 - var z = 0 - when(d) { - 5, 3 -> z++ - else -> z = -1000 - } - return z -} - -//More tests - -fun test1() { while(true) {} } -fun test2(): Unit { while(true) {} } - -fun testCoercionToUnit() { - val simple: ()-> Unit = { - 41 - } - val withIf: ()-> Unit = { - if (true) { - 3 - } else { - 45 - } - } - val i = 34 - val withWhen : () -> Unit = { - when(i) { - 1 -> { - val d = 34 - "1" - doSmth(d) - - } - 2 -> '4' - else -> true - } - } - - var x = 43 - val checkType = { - if (true) { - x = 4 - } else { - 45 - } - } - val f : () -> String = checkType -} - -fun doSmth(i: Int) {} - -fun testImplicitCoercion() { - val d = 21 - var z = 0 - var i = when(d) { - 3 -> null - 4 -> { val z = 23 } - else -> z = 20 - } - - var u = when(d) { - 3 -> { - z = 34 - } - else -> z-- - } - - var iff = if (true) { - z = 34 - } - val g = if (true) 4 - val h = if (false) 4 else {} - - bar(if (true) { - 4 - } - else { - z = 342 - }) -} - -fun fooWithAnyArg(arg: Any) {} -fun fooWithAnyNullableArg(arg: Any?) {} - -fun testCoercionToAny() { - val d = 21 - val x1: Any = if (1>2) 1 else 2.0 - val x2: Any? = if (1>2) 1 else 2.0 - val x3: Any? = if (1>2) 1 else (if (1>2) null else 2.0) - - fooWithAnyArg(if (1>2) 1 else 2.0) - fooWithAnyNullableArg(if (1>2) 1 else 2.0) - fooWithAnyNullableArg(if (1>2) 1 else (if (1>2) null else 2.0)) - - val y1: Any = when(d) { 1 -> 1.0 else -> 2.0 } - val y2: Any? = when(d) { 1 -> 1.0 else -> 2.0 } - val y3: Any? = when(d) { 1 -> 1.0; 2 -> null; else -> 2.0 } - - fooWithAnyArg(when(d) { 1 -> 1.0 else -> 2.0 }) - fooWithAnyNullableArg(when(d) { 1 -> 1.0 else -> 2.0 }) - fooWithAnyNullableArg(when(d) { 1 -> 1.0; 2 -> null; else -> 2.0 }) -} - -fun fooWithAnuNullableResult(s: String?, name: String, optional: Boolean): Any? { - return if (s == null) { - if (!optional) { - throw java.lang.IllegalArgumentException("Parameter '$name' was not found in the request") - } - null - } else { - name - } -} - -fun bar(a: Unit) {} - -fun testStatementInExpressionContext() { - var z = 34 - val a1: Unit = z = 334 - val f = for (i in 1..10) {} - if (true) return z = 34 - return while (true) {} -} - -fun testStatementInExpressionContext2() { - val a2: Unit = while(true) {} -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlStructures/when.fir.kt234.fir.kt973.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/when.fir.kt234.fir.kt973.fir.kt deleted file mode 100644 index b7fb0ec8796..00000000000 --- a/compiler/testData/diagnostics/tests/controlStructures/when.fir.kt234.fir.kt973.fir.kt +++ /dev/null @@ -1,41 +0,0 @@ -//KT-234 Force when() expressions to have an 'else' branch -//KT-973 Unreachable code - -package kt234_kt973 - -class Pair(a: A, b: B) - -fun test(t : Pair) : Int { - when (t) { - Pair(10, 10) -> return 1 - } - return 0 // unreachable code -} - -fun test1(t : Pair) : Int { - when (t) { - Pair(10, 10) -> return 1 - else -> return 2 - } - return 0 // unreachable code -} - -//more tests -fun t1(x: Int) = when(x) { - else -> 1 -} - -fun t5(x: Int) = when (x) { - is Int -> 1 - 2 -> 2 -} - -fun foo3(x: Int) = when(x) { - else -> 1 - 2 -> 2 -} - -fun foo4(x: Int) = when(x) { - 2 -> x - else -> 3 -} \ No newline at end of file