[Spec tests] Add codegen tests for logical-disjunction-expression (paragraph 1)
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 2
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 1
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false
|
||||
*/
|
||||
|
||||
fun box(): String {
|
||||
val aval = A()
|
||||
val x = aval.a(false) ||
|
||||
aval.b(false) ||
|
||||
aval.c(true) ||
|
||||
aval.d(true)
|
||||
|
||||
if (aval.a && aval.b && aval.c && !aval.d && x)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
|
||||
|
||||
class A (var a: Boolean = false,
|
||||
var b: Boolean = false,
|
||||
var c: Boolean = false,
|
||||
var d: Boolean = false){
|
||||
|
||||
fun a(a: Boolean): Boolean { this.a = true; return a }
|
||||
|
||||
fun b(a: Boolean): Boolean { this.b = true; return a }
|
||||
|
||||
fun c(a: Boolean): Boolean { this.c = true; return a }
|
||||
|
||||
fun d(a: Boolean): Boolean { this.d = true; return a }
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 2
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 1
|
||||
* NUMBER: 2
|
||||
* DESCRIPTION: operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false
|
||||
*/
|
||||
|
||||
fun box(): String {
|
||||
val x: Boolean
|
||||
try {
|
||||
x = false || false || true || throw MyException()
|
||||
} catch (e: MyException) {
|
||||
return "NOK"
|
||||
}
|
||||
if (x)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
|
||||
class MyException : Exception() {}
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 2
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 1 -> sentence 1
|
||||
* NUMBER: 3
|
||||
* DESCRIPTION: operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false
|
||||
*/
|
||||
|
||||
fun box(): String {
|
||||
val x: Boolean = false
|
||||
try {
|
||||
x = (throw MyException()) || true
|
||||
} catch (e: MyException) {
|
||||
if (!x)
|
||||
return "OK"
|
||||
}
|
||||
return "NOK"
|
||||
}
|
||||
|
||||
class MyException : Exception() {}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"1": {
|
||||
"pos": {
|
||||
"2": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
],
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.3.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 0,
|
||||
"description": "operator || does not evaluate the right hand side argument unless the left hand side argument evaluated to false",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.2.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+57
-3
@@ -25,7 +25,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInBox() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), true, "helpers", "templates", "linked/expressions.when-expression", "linked/statements", "linked/expressions.conditional-expression", "linked/expressions/logical-disjunction-expression", "linked/expressions/equality-expressions/reference-equality-expressions/p-1/neg", "linked/expressions/built-in-types-and-their-semantics/kotlin.unit/p-1/neg", "linked/expressions/prefix-expressions/prefix-increment-expression/p-1/neg");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), true, "helpers", "templates", "linked/expressions.when-expression", "linked/declarations", "linked/statements", "linked/expressions.conditional-expression", "linked/expressions/equality-expressions/reference-equality-expressions/p-1/neg", "linked/expressions/built-in-types-and-their-semantics/kotlin.unit/p-1/neg", "linked/expressions/prefix-expressions/prefix-increment-expression/p-1/neg");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked")
|
||||
@@ -37,7 +37,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLinked() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked"), Pattern.compile("^(.+)\\.kt$"), true, "expressions.when-expression", "statements", "expressions.conditional-expression", "expressions/logical-disjunction-expression", "expressions/equality-expressions/reference-equality-expressions/p-1/neg", "expressions/built-in-types-and-their-semantics/kotlin.unit/p-1/neg", "expressions/prefix-expressions/prefix-increment-expression/p-1/neg");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked"), Pattern.compile("^(.+)\\.kt$"), true, "expressions.when-expression", "declarations", "statements", "expressions.conditional-expression", "expressions/equality-expressions/reference-equality-expressions/p-1/neg", "expressions/built-in-types-and-their-semantics/kotlin.unit/p-1/neg", "expressions/prefix-expressions/prefix-increment-expression/p-1/neg");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions")
|
||||
@@ -49,7 +49,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExpressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), true, "logical-disjunction-expression", "equality-expressions/reference-equality-expressions/p-1/neg", "built-in-types-and-their-semantics/kotlin.unit/p-1/neg", "prefix-expressions/prefix-increment-expression/p-1/neg");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), true, "equality-expressions/reference-equality-expressions/p-1/neg", "built-in-types-and-their-semantics/kotlin.unit/p-1/neg", "prefix-expressions/prefix-increment-expression/p-1/neg");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/built-in-types-and-their-semantics")
|
||||
@@ -1051,6 +1051,60 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Logical_disjunction_expression extends AbstractBlackBoxCodegenTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLogical_disjunction_expression() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_1 extends AbstractBlackBoxCodegenTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_1() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractBlackBoxCodegenTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("2.1.kt")
|
||||
public void test2_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("2.2.kt")
|
||||
public void test2_2() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("2.3.kt")
|
||||
public void test2_3() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos/2.3.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/logical-disjunction-expression/p-1/pos"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/prefix-expressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user