[Spec tests] Add box tests for callables-and-invoke-convention to check priority

This commit is contained in:
anastasiia.spaseeva
2020-02-04 13:29:17 +03:00
committed by Victor Petukhov
parent f7ff60cb77
commit 81b6e5a373
12 changed files with 615 additions and 0 deletions
@@ -0,0 +1,41 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 2
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 6
* NUMBER: 1
* DESCRIPTION: function-like prio is higher than property-like callables
*/
// FILE: KotlinLib.kt
package test.lib
var booInt: Boolean = false
var booLambda: Boolean = false
fun boo(a: Int) { booInt = true }
val boo: (Int) -> Unit = { a: Int -> booLambda = true}
// FILE: KotlinClass.kt
package overloadResolution
var fooInt: Boolean = false
var fooLambda: Boolean = false
fun foo(a: Int) { fooInt = true }
val foo: (Int) -> Unit = { a: Int -> fooLambda = true}
fun box(): String {
overloadResolution.foo(1)
if (fooInt && ! fooLambda)
return "OK"
return "NOK"
}
@@ -0,0 +1,38 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 4
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 9
* NUMBER: 10
* DESCRIPTION: function-like prio is higher than property-like callables
*/
// FILE: KotlinLib.kt
package test.lib
class MyClass {
//property-like (II prio)
companion object foo {
var fooCompanionObj = false
operator fun invoke() {
fooCompanionObj = true
}
}
}
// FILE: KotlinClass.kt
package overloadResolution
import test.lib.MyClass.foo as boo
//function-like (I prio)
class boo(){}
fun box(): String {
val x = boo()
if (x is boo && !test.lib.MyClass.fooCompanionObj)
return "OK"
return "NOK"
}
@@ -0,0 +1,39 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 6
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 3
* NUMBER: 2
* DESCRIPTION: function-like prio is higher than property-like callables
*/
// FILE: KotlinLib.kt
package test.lib
var isBooCalled: Boolean = false
fun boo(a: Int) { isBooCalled = true }
// FILE: KotlinClass.kt
package overloadResolution
import test.lib.boo as foo
var isFooCalled: Boolean = false
val foo: (Int) -> Unit = { a: Int -> isFooCalled = true}
fun box(): String {
foo(1)
if (!isFooCalled && test.lib.isBooCalled)
return "OK"
return "NOK"
}
@@ -0,0 +1,30 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 4
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 6
* NUMBER: 3
* DESCRIPTION: function-like prio is higher than property-like callables
*/
class foo(val a: Int)
var fooLambda: Boolean = false
val foo: (Int) -> Unit = { a: Int -> fooLambda = true }
fun box(): String {
val x = foo(1)
if (x is foo && !fooLambda)
return "OK"
return "NOK"
}
@@ -0,0 +1,35 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 2
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 10
* NUMBER: 4
* DESCRIPTION: function-like prio is higher than property-like callables
*/
// FILE: KotlinLib.kt
package test.lib
var isFooCalled: Boolean = false
val foo: (Int) -> Unit = { a: Int -> isFooCalled = true}
// FILE: KotlinClass.kt
package overloadResolution
import test.lib.foo as boo
var isBooCalled: Boolean = false
fun boo(a: Int) { isBooCalled = true }
fun box(): String {
boo(1)
if (!test.lib.isFooCalled && isBooCalled)
return "OK"
return "NOK"
}
@@ -0,0 +1,30 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 2
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 7
* NUMBER: 5
* DESCRIPTION: function-like prio is higher than property-like callables
*/
//function-like (I prio)
var fooFun: Boolean = false
fun foo() { fooFun = true }
//property-like (II prio)
var isMarker = false
val foo: Marker = object : Marker {}
interface Marker {
operator fun invoke() { isMarker = true }
}
fun box(): String {
foo()
if (!isMarker && fooFun)
return "OK"
return "NOK"
}
@@ -0,0 +1,38 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 2
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 7
* NUMBER: 6
* DESCRIPTION: function-like prio is higher than property-like callables
*/
// FILE: KotlinLib.kt
package test.lib
//property-like (II prio)
var isMarker = false
val foo: Marker = object : Marker {}
interface Marker {
operator fun invoke() { isMarker = true }
}
// FILE: KotlinClass.kt
package overloadResolution
import test.lib.foo as foo
//function-like (I prio)
var fooFun: Boolean = false
fun foo() { fooFun = true }
fun box(): String {
foo()
if (!test.lib.isMarker && fooFun)
return "OK"
return "NOK"
}
@@ -0,0 +1,36 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 2
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 7
* NUMBER: 7
* DESCRIPTION: function-like prio is higher than property-like callables
*/
// FILE: KotlinLib.kt
package test.lib
//function-like (I prio)
var fooFun: Boolean = false
fun foo() { fooFun = true }
// FILE: KotlinClass.kt
package overloadResolution
import test.lib.foo as foo
//property-like (II prio)
var isMarker = false
val foo: Marker = object : Marker {}
interface Marker {
operator fun invoke() { isMarker = true }
}
fun box(): String {
foo()
if (!isMarker && test.lib.fooFun)
return "OK"
return "NOK"
}
@@ -0,0 +1,38 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 2
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 8
* NUMBER: 8
* DESCRIPTION: function-like prio is higher than property-like callables
*/
class MyClass {
//function-like (I prio)
var fooFun: Boolean = false
fun foo() { fooFun = true }
//property-like (II prio)
companion object foo {
var fooCompanionObj = false
operator fun invoke() {
fooCompanionObj = true
}
}
fun check() : String {
foo()
if (fooFun && !fooCompanionObj)
return "OK"
return "NOK"
}
}
fun box() : String{
return MyClass().check()
}
@@ -0,0 +1,40 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-253
* PLACE: overload-resolution, callables-and-invoke-convention -> paragraph 6 -> sentence 1
* RELEVANT PLACES: overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 2
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 8
* overload-resolution, callables-and-invoke-convention -> paragraph 2 -> sentence 10
* NUMBER: 9
* DESCRIPTION: function-like prio is higher than property-like callables
*/
// FILE: KotlinLib.kt
package test.lib
class MyClass {
//property-like (II prio)
companion object foo {
var fooCompanionObj = false
operator fun invoke() {
fooCompanionObj = true
}
}
}
// FILE: KotlinClass.kt
package overloadResolution
import test.lib.MyClass.foo as boo
//function-like (I prio)
var booFun: Boolean = false
fun boo() { booFun = true }
fun box(): String {
boo()
if (booFun && !test.lib.MyClass.fooCompanionObj)
return "OK"
return "NOK"
}
@@ -0,0 +1,148 @@
{
"6": {
"pos": {
"1": [
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"unexpectedBehaviour": false
}
]
}
},
"2": {
"pos": {
"2": [
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.6.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.7.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.8.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.9.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.4.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.5.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.1.kt",
"unexpectedBehaviour": false
}
],
"6": [
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.2.kt",
"unexpectedBehaviour": false
}
],
"4": [
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.3.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-253",
"casesNumber": 0,
"description": "function-like prio is higher than property-like callables",
"path": "compiler/tests-spec/testData/codegen/box/linked/overload-resolution/callables-and-invoke-convention/p-6/pos/1.10.kt",
"unexpectedBehaviour": false
}
]
}
}
}