[Spec tests] Add tests for logical-disjunction-expression (paragraph 2)
This commit is contained in:
+81
@@ -0,0 +1,81 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 2 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 2 -> sentence 2
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: Both operands of a logical disjunction expression must have a type which is a subtype of kotlin.Boolean, otherwise it is a type error.
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
|
||||
// MODULE: libModule
|
||||
// FILE: libModule/JavaClass.java
|
||||
package libModule;
|
||||
|
||||
public class JavaClass {
|
||||
public static Object VALUE = false;
|
||||
}
|
||||
|
||||
// MODULE: mainModule(libModule)
|
||||
// FILE: KotlinClass.kt
|
||||
package mainModule
|
||||
import libModule.*
|
||||
import checkSubtype
|
||||
import checkType
|
||||
import check
|
||||
|
||||
// TESTCASE NUMBER: 0
|
||||
fun foo() = run { false || <!TYPE_MISMATCH!>JavaClass.VALUE<!> || throw Exception() }
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case1() {
|
||||
val a: Boolean? = false
|
||||
checkSubtype<Boolean?>(a)
|
||||
val x4 = <!TYPE_MISMATCH!>a<!> || true
|
||||
x4 checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
fun case2() {
|
||||
val a: Any = false
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>a<!>
|
||||
val x4 = <!TYPE_MISMATCH!>a<!> || true
|
||||
x4 checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun case3() {
|
||||
val a1 = false
|
||||
val a2 = JavaClass.VALUE
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(kotlin.Any..kotlin.Any?)")!>a2<!>
|
||||
|
||||
val x3 = a1 || <!TYPE_MISMATCH!>a2<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean")!>x3<!>
|
||||
|
||||
x3 checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
fun case4() {
|
||||
var x = false ||<!SYNTAX!><!> ;
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 5
|
||||
fun case5() {
|
||||
var y = false ||<!SYNTAX!><!>
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 5
|
||||
fun case5() {
|
||||
var x =<!SYNTAX!><!> <!SYNTAX!>||<!>
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 6
|
||||
fun case6() {
|
||||
var x =<!SYNTAX!><!> <!SYNTAX!>|| false || true<!>
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
// SKIP_TXT
|
||||
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, logical-disjunction-expression -> paragraph 2 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, logical-disjunction-expression -> paragraph 2 -> sentence 2
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION:Both operands of a logical disjunction expression must have a type which is a subtype of kotlin.Boolean
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
|
||||
// MODULE: libModule
|
||||
// FILE: libModule/JavaClass.java
|
||||
package libModule;
|
||||
|
||||
public class JavaClass {
|
||||
public static boolean VALUE;
|
||||
|
||||
public static Object VALUE_OBJ = true;
|
||||
|
||||
public Boolean getValue ()
|
||||
{ return new Boolean ("true"); }
|
||||
}
|
||||
|
||||
// MODULE: mainModule(libModule)
|
||||
// FILE: KotlinClass.kt
|
||||
package mainModule
|
||||
import libModule.*
|
||||
import checkSubtype
|
||||
import checkType
|
||||
import check
|
||||
|
||||
fun foo() = run { false || JavaClass.VALUE || throw Exception() }
|
||||
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case1() {
|
||||
val a1 = false
|
||||
val a2 = JavaClass.VALUE
|
||||
val a3 = foo()
|
||||
val a4 = JavaClass().getValue()
|
||||
val a5 = JavaClass.VALUE_OBJ
|
||||
|
||||
checkSubtype<Boolean>(a1)
|
||||
checkSubtype<Boolean>(a2)
|
||||
checkSubtype<Boolean>(a3)
|
||||
checkSubtype<Boolean>(a4)
|
||||
|
||||
val x3 = a1 || a2 || a3 || a4 || a5 as Boolean
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Boolean")!>x3<!>
|
||||
|
||||
x3 checkType { check<Boolean>()}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"2": {
|
||||
"neg": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 6,
|
||||
"description": "Both operands of a logical conjunction expression must have a type which is a subtype of kotlin.Boolean, otherwise it is a type error.",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
],
|
||||
"2": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 6,
|
||||
"description": "Both operands of a logical conjunction expression must have a type which is a subtype of kotlin.Boolean, otherwise it is a type error.",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 1,
|
||||
"description": "Both operands of a logical conjunction expression must have a type which is a subtype of kotlin.Boolean",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
],
|
||||
"2": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 1,
|
||||
"description": "Both operands of a logical conjunction expression must have a type which is a subtype of kotlin.Boolean",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/pos/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+65
-3
@@ -25,7 +25,7 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDiagnostics() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), true, "helpers", "linked/type-inference", "linked/expressions.when-expression", "linked/type-system/type-kinds/type-parameters", "linked/type-system/subtyping", "linked/control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "linked/declarations/classifier-declaration/classifier-initialization", "linked/declarations/function-declaration", "linked/declarations/property-declaration/property-initialization", "linked/annotations", "linked/statements", "linked/inheritance", "linked/expressions.conditional-expression", "linked/expressions/logical-disjunction-expression", "linked/expressions/function-literals", "linked/expressions/built-in-types-and-their-semantics/kotlin.nothing-1/p-1/neg", "linked/overload-resolution", "linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), true, "helpers", "linked/type-inference", "linked/expressions.when-expression", "linked/type-system/type-kinds/type-parameters", "linked/type-system/subtyping", "linked/control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "linked/declarations/classifier-declaration/classifier-initialization", "linked/declarations/function-declaration", "linked/declarations/property-declaration/property-initialization", "linked/annotations", "linked/statements", "linked/inheritance", "linked/expressions.conditional-expression", "linked/expressions/function-literals", "linked/expressions/built-in-types-and-their-semantics/kotlin.nothing-1/p-1/neg", "linked/overload-resolution", "linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked")
|
||||
@@ -37,7 +37,7 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLinked() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked"), Pattern.compile("^(.+)\\.kt$"), true, "type-inference", "expressions.when-expression", "type-system/type-kinds/type-parameters", "type-system/subtyping", "control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "declarations/classifier-declaration/classifier-initialization", "declarations/function-declaration", "declarations/property-declaration/property-initialization", "annotations", "statements", "inheritance", "expressions.conditional-expression", "expressions/logical-disjunction-expression", "expressions/function-literals", "expressions/built-in-types-and-their-semantics/kotlin.nothing-1/p-1/neg", "overload-resolution", "control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked"), Pattern.compile("^(.+)\\.kt$"), true, "type-inference", "expressions.when-expression", "type-system/type-kinds/type-parameters", "type-system/subtyping", "control--and-data-flow-analysis.control-flow-graph.expressions-1.conditional-expressions", "declarations/classifier-declaration/classifier-initialization", "declarations/function-declaration", "declarations/property-declaration/property-initialization", "annotations", "statements", "inheritance", "expressions.conditional-expression", "expressions/function-literals", "expressions/built-in-types-and-their-semantics/kotlin.nothing-1/p-1/neg", "overload-resolution", "control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis")
|
||||
@@ -452,7 +452,7 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExpressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), true, "logical-disjunction-expression", "function-literals", "built-in-types-and-their-semantics/kotlin.nothing-1/p-1/neg");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), true, "function-literals", "built-in-types-and-their-semantics/kotlin.nothing-1/p-1/neg");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/built-in-types-and-their-semantics")
|
||||
@@ -1604,6 +1604,68 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Logical_disjunction_expression extends AbstractDiagnosticsTestSpec {
|
||||
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/diagnostics/linked/expressions/logical-disjunction-expression"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class P_2 extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInP_2() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Neg extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNeg() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/pos")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Pos extends AbstractDiagnosticsTestSpec {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("1.1.kt")
|
||||
public void test1_1() throws Exception {
|
||||
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/pos/1.1.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPos() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/prefix-expressions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user