[Spec tests] Add codegen tests for indexing-expression (paragraph 3)
This commit is contained in:
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-220
|
||||
* PLACE: expressions, indexing-expressions -> paragraph 3 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, indexing-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, indexing-expressions -> paragraph 2 -> sentence 1
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope
|
||||
*/
|
||||
|
||||
class A1(val a: Int = 0) {
|
||||
|
||||
operator fun get(x: Int): A1 {
|
||||
return A1(x)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A1()[9]
|
||||
val x = a[1][2][3][4]
|
||||
if (x.a == 4 && a.a == 9)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-220
|
||||
* PLACE: expressions, indexing-expressions -> paragraph 3 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, indexing-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, indexing-expressions -> paragraph 2 -> sentence 1
|
||||
* NUMBER: 2
|
||||
* DESCRIPTION: A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope
|
||||
*/
|
||||
class A1(val a: Int = 0) {
|
||||
operator fun get(x: Any): Any {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A1()
|
||||
val x = a[a[a[a["qwsax"]]]]
|
||||
if (x == "qwsax")
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-220
|
||||
* PLACE: expressions, indexing-expressions -> paragraph 3 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, indexing-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, indexing-expressions -> paragraph 2 -> sentence 1
|
||||
* NUMBER: 3
|
||||
* DESCRIPTION: A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope
|
||||
*/
|
||||
|
||||
|
||||
class A1(val a: Int = 0) {
|
||||
operator fun get(x: Any): Any {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
class B() {
|
||||
operator fun get(x: Any, y: Any, z: Any): Any {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = B()[A1(), 'c', false]
|
||||
val a = A1()
|
||||
val x = a[a[a[a[B()[A1(100500), 'c', false]]]]]
|
||||
|
||||
x as A1
|
||||
if (x.a == 100500)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-220
|
||||
* PLACE: expressions, indexing-expressions -> paragraph 3 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, indexing-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, indexing-expressions -> paragraph 2 -> sentence 1
|
||||
* NUMBER: 4
|
||||
* DESCRIPTION: A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope
|
||||
*/
|
||||
|
||||
class A1(val a: Int = 0) {
|
||||
operator fun get(x: Any): Any {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
class B() {
|
||||
operator fun get(x: Any, y: Any, z: Any): Any {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = B()[A1(5555), 'c', false]
|
||||
val a = A1(4444)
|
||||
val x = a[a[a[a[B()[A1(100500)[c], 'c', false]]]]]
|
||||
|
||||
x as A1
|
||||
if (x.a == 5555)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
|
||||
/*
|
||||
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-220
|
||||
* PLACE: expressions, indexing-expressions -> paragraph 3 -> sentence 1
|
||||
* RELEVANT PLACES: expressions, indexing-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, indexing-expressions -> paragraph 2 -> sentence 1
|
||||
* NUMBER: 5
|
||||
* DESCRIPTION: A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope
|
||||
*/
|
||||
|
||||
|
||||
class A1(val a: Int = 0) {
|
||||
operator fun get(x: Any): Any {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
class B() {
|
||||
operator fun get(x: Any, y: Any, z: Any): Any {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
||||
class C() {
|
||||
operator fun get(function: () -> Any): Any {
|
||||
return function()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() : String{
|
||||
val a = A1(4444)
|
||||
val c = a [C()[{ 1 + 900 }]]
|
||||
val x = a[a[a[a[B()[A1(100500)[ C()[{ 1 + 900 }] ], 'c', false]]]]]
|
||||
|
||||
if (c == 901 && x == 901)
|
||||
return "OK"
|
||||
return "NOK"
|
||||
}
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"3": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"1": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/indexing-expressions/p-3/pos/1.2.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/indexing-expressions/p-3/pos/1.3.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/indexing-expressions/p-3/pos/1.4.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/indexing-expressions/p-3/pos/1.5.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-220",
|
||||
"casesNumber": 0,
|
||||
"description": "A[I_0,I_1,...,I_N] is exactly the same as A.get(I_0,I_1,...,I_N), where get is a valid operator function available in the current scope",
|
||||
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/indexing-expressions/p-3/pos/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user