[Spec tests] Add fixed tests for expressions section, fix linkage for reference-equality-expressions section

This commit is contained in:
anastasiia.spaseeva
2019-12-26 15:11:29 +03:00
parent 9e3ecbd902
commit e0743f2268
42 changed files with 1162 additions and 106 deletions
@@ -5,7 +5,6 @@
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, equality-expressions, reference-equality-expressions -> paragraph 1 -> sentence 2
* RELEVANT PLACES: expressions, built-in-types-and-their-semantics, kotlin.unit -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: check if two values are equal (===) by reference
*/
@@ -5,8 +5,7 @@
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, equality-expressions, reference-equality-expressions -> paragraph 1 -> sentence 2
* RELEVANT PLACES: expressions, built-in-types-and-their-semantics, kotlin.unit -> paragraph 1 -> sentence 1,
* expressions, equality-expressions, reference-equality-expressions -> paragraph 3 -> sentence 3
* RELEVANT PLACES: expressions, equality-expressions, reference-equality-expressions -> paragraph 3 -> sentence 3
* expressions, equality-expressions, reference-equality-expressions -> paragraph 2 -> sentence 1
* NUMBER: 2
* DESCRIPTION: check if two values are equal (===) by reference
@@ -5,7 +5,6 @@
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, equality-expressions, reference-equality-expressions -> paragraph 1 -> sentence 2
* RELEVANT PLACES: expressions, built-in-types-and-their-semantics, kotlin.unit -> paragraph 1 -> sentence 1
* NUMBER: 3
* DESCRIPTION: check if two values are non-equal (!==) by reference
*/
@@ -5,7 +5,6 @@
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, equality-expressions, reference-equality-expressions -> paragraph 1 -> sentence 2
* RELEVANT PLACES: expressions, built-in-types-and-their-semantics, kotlin.unit -> paragraph 1 -> sentence 1
* NUMBER: 4
* DESCRIPTION: check if values are non-equal (!==) by reference
*/
@@ -5,7 +5,6 @@
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, equality-expressions, reference-equality-expressions -> paragraph 1 -> sentence 2
* RELEVANT PLACES: expressions, built-in-types-and-their-semantics, kotlin.unit -> paragraph 1 -> sentence 1
* NUMBER: 5
* DESCRIPTION: two values are equal (===) or non-equal (!==) by reference
*/
@@ -5,7 +5,6 @@
*
* SPEC VERSION: 0.1-213
* PLACE: expressions, equality-expressions, reference-equality-expressions -> paragraph 1 -> sentence 3
* RELEVANT PLACES: expressions, built-in-types-and-their-semantics, kotlin.unit -> paragraph 1 -> sentence 1
* NUMBER: 1
* DESCRIPTION: check equallity by refference via constructor
*/
@@ -10,8 +10,13 @@
*/
// FILE: JavaClass.java
public class JavaClass{
public static Object NULL_VALUE ;
public class JavaClass {
public static Object NULL_VALUE;
public Integer x;
public static <T> T id(T x) { return null; }
}
// FILE: KotlinClass.kt
@@ -27,10 +32,31 @@ fun box(): String {
val x = null
if (null === x) {
if (x === null)
flag2 = true
flag2 = true
}
if (flag1 && flag2) return "OK"
var flag3 = false
if (null === null)
flag3 = true
var flag4 = false
val s: String? = null
if (s === JavaClass.NULL_VALUE)
if (JavaClass.NULL_VALUE === s)
flag4 = true
var flag5 = false
if (null === JavaClass().x)
if (JavaClass().x === null)
flag5 = true
var flag6 = false
if (null === JavaClass.id(null))
if (JavaClass.id(null) === null)
flag6 = true
if (flag1 && flag2 && flag3 && flag4 && flag5 &&flag6) return "OK"
else
return "NOK"
}
@@ -0,0 +1,47 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, reference-equality-expressions -> paragraph 3 -> sentence 2
* NUMBER: 2
* DESCRIPTION: Any instance of the null reference null is equal by reference to any other instance of the null reference;
*/
// FILE: JavaClass.java
public class JavaClass {
public static Object NULL_VALUE;
public Integer x;
public static <T> T id(T x) { return null; }
}
// FILE: KotlinClass.kt
fun box(): String {
if (null !== JavaClass.NULL_VALUE) return "NOK"
if (JavaClass.NULL_VALUE !== null) return "NOK"
val x = null
if (null !== x) return "NOK"
if (x !== null) return "NOK"
if (null !== null) return "NOK"
val s: String? = null
if (s !== JavaClass.NULL_VALUE) return "NOK"
if (JavaClass.NULL_VALUE !== s) return "NOK"
if (getNull(true) !== getNull(false) === getNull(true) !== getNull(false) === getNull(true)) return "NOK"
if (JavaClass().x !== null) return "NOK"
if (null !== JavaClass().x ) return "NOK"
if (JavaClass.id(null) !== null) return "NOK"
if (null !== JavaClass.id(null) ) return "NOK"
return "OK"
}
fun getNull(x: Boolean): Any? = if (x) null else ""
@@ -52,7 +52,22 @@
},
"3": {
"pos": {
"3": [
{
"specVersion": "0.1-213",
"casesNumber": 0,
"description": "check if two values are equal (\u003d\u003d\u003d) by reference",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/equality-expressions/reference-equality-expressions/p-1/pos/2.2.kt",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "Any instance of the null reference null is equal by reference to any other instance of the null reference;",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
@@ -16,18 +16,21 @@ fun box(): String {
val x = A(false)
val y = A(false)
if (x == y) {
if ((x == y) == checkEqualls(x, y)) {
if (x.isEqualsCalled && !y.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkEqualls(A: Any?, B: Any?): Boolean {
return (A as? Any)?.equals(B) ?: (B === null)
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override fun equals(anObject: Any?): Boolean {
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
@@ -0,0 +1,44 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 1
* RELEVANT PLACES: expressions, equality-expressions, value-equality-expressions -> paragraph 3 -> sentence 1
* NUMBER: 2
* DESCRIPTION: check value-equality-expression
*/
//A == B is exactly the same as (A as? Any)?.equals(B) ?: (B === null) where equals is the method of kotlin.Any;
fun box(): String {
val x = A(false)
val y = A(true)
if ((x == y) == checkEqualls(x, y)) {
if (x.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkEqualls(A: Any?, B: Any?): Boolean {
return (A as? Any)?.equals(B) ?: (B === null)
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -0,0 +1,44 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 1
* RELEVANT PLACES: expressions, equality-expressions, value-equality-expressions -> paragraph 3 -> sentence 1
* NUMBER: 3
* DESCRIPTION: check value-equality-expression
*/
//A == B is exactly the same as (A as? Any)?.equals(B) ?: (B === null) where equals is the method of kotlin.Any;
fun box(): String {
val x = A(false)
val y = null
if ((x == y) == checkEqualls(x, y)) {
if (x.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkEqualls(A: Any?, B: Any?): Boolean {
return (A as? Any)?.equals(B) ?: (B === null)
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -0,0 +1,43 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 1
* RELEVANT PLACES: expressions, equality-expressions, value-equality-expressions -> paragraph 3 -> sentence 1
* NUMBER: 4
* DESCRIPTION: check value-equality-expression
*/
//A == B is exactly the same as (A as? Any)?.equals(B) ?: (B === null) where equals is the method of kotlin.Any;
fun box(): String {
val x = null
val y = null
if ((x == y) == checkEqualls(x, y)) {
return "OK"
}
return "NOK"
}
fun checkEqualls(A: Any?, B: Any?): Boolean {
return (A as? Any)?.equals(B) ?: (B === null)
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -0,0 +1,44 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 1
* RELEVANT PLACES: expressions, equality-expressions, value-equality-expressions -> paragraph 3 -> sentence 1
* NUMBER: 5
* DESCRIPTION: check value-equality-expression
*/
//A == B is exactly the same as (A as? Any)?.equals(B) ?: (B === null) where equals is the method of kotlin.Any;
fun box(): String {
val x: A = A(false)
val y: Any = ""
if ((x == y) == checkEqualls(x, y)) {
if (x.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkEqualls(A: Any?, B: Any?): Boolean {
return (A as? Any)?.equals(B) ?: (B === null)
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -1,10 +1,10 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (NEGATIVE)
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 1
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 2
* NUMBER: 1
* DESCRIPTION: check value-equality-expression
*/
@@ -12,22 +12,27 @@
//A != B is exactly the same as !((A as? Any)?.equals(B) ?: (B === null)) where equals is the method of kotlin.Any.
fun box():String{
val x = A(true)
val y = A(false)
if (x != y) {
if ((x != y) == checkNotEquals(x, y)) {
if (x.isEqualsCalled && !y.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkNotEquals(A: Any?, B: Any?): Boolean {
return !((A as? Any)?.equals(B) ?: (B === null))
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override fun equals(anObject: Any?): Boolean {
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
@@ -0,0 +1,45 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 2
* NUMBER: 2
* DESCRIPTION: check value-equality-expression
*/
//A != B is exactly the same as !((A as? Any)?.equals(B) ?: (B === null)) where equals is the method of kotlin.Any.
fun box():String{
val x = A(true)
val y = A(true)
if ((x != y) == checkNotEquals(x, y)) {
if (x.isEqualsCalled && !y.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkNotEquals(A: Any?, B: Any?): Boolean {
return !((A as? Any)?.equals(B) ?: (B === null))
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -0,0 +1,44 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 2
* NUMBER: 3
* DESCRIPTION: check value-equality-expression
*/
//A != B is exactly the same as !((A as? Any)?.equals(B) ?: (B === null)) where equals is the method of kotlin.Any.
fun box():String{
val x = null
val y = A(true)
if ((x != y) == checkNotEquals(x, y)) {
return "OK"
}
return "NOK"
}
fun checkNotEquals(A: Any?, B: Any?): Boolean {
return !((A as? Any)?.equals(B) ?: (B === null))
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -0,0 +1,44 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 2
* NUMBER: 4
* DESCRIPTION: check value-equality-expression
*/
//A != B is exactly the same as !((A as? Any)?.equals(B) ?: (B === null)) where equals is the method of kotlin.Any.
fun box():String{
val x = null
val y = null
if ((x != y) == checkNotEquals(x, y)) {
return "OK"
}
return "NOK"
}
fun checkNotEquals(A: Any?, B: Any?): Boolean {
return !((A as? Any)?.equals(B) ?: (B === null))
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -0,0 +1,45 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, equality-expressions, value-equality-expressions -> paragraph 2 -> sentence 2
* NUMBER: 5
* DESCRIPTION: check value-equality-expression
*/
//A != B is exactly the same as !((A as? Any)?.equals(B) ?: (B === null)) where equals is the method of kotlin.Any.
fun box():String{
val x = A(true)
val y : Any = ""
if ((x != y) == checkNotEquals(x, y)) {
if (x.isEqualsCalled)
return "OK"
}
return "NOK"
}
fun checkNotEquals(A: Any?, B: Any?): Boolean {
return !((A as? Any)?.equals(B) ?: (B === null))
}
data class A(val a: Boolean) {
var isEqualsCalled = false
override operator fun equals(anObject: Any?): Boolean {
isEqualsCalled = true
if (this === anObject) {
return true
}
if (anObject is A) {
if (anObject.a == a)
return true
}
return false
}
}
@@ -1,17 +1,63 @@
{
"2": {
"neg": {
"1": [
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
}
]
},
"pos": {
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
@@ -24,6 +70,34 @@
"3": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/equality-expressions/value-equality-expressions/p-2/pos/1.2.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/equality-expressions/value-equality-expressions/p-2/pos/1.3.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/equality-expressions/value-equality-expressions/p-2/pos/1.4.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "check value-equality-expression",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/equality-expressions/value-equality-expressions/p-2/pos/1.5.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,