[Spec tests] Fix test cases structure
This commit is contained in:
+5
-4
@@ -11,12 +11,11 @@
|
||||
* DESCRIPTION: check the type of jump expressions is Nothing and code placed on the left side of expression will never be executed
|
||||
*/
|
||||
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
|
||||
fun case1() {
|
||||
var name: Any? = null
|
||||
val men = arrayListOf(Person("Phill"), Person(), Person("Bob"))
|
||||
val men = arrayListOf(Person1("Phill"), Person1(), Person1("Bob"))
|
||||
for (k in men) {
|
||||
k.name
|
||||
loop@ for (i in men) {
|
||||
@@ -31,13 +30,13 @@ fun case1() {
|
||||
val a = 1
|
||||
}
|
||||
|
||||
class Person(var name: String? = null) {}
|
||||
class Person1(var name: String? = null) {}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
|
||||
fun case2() {
|
||||
var name: Any? = null
|
||||
val men = arrayListOf(Person("Phill"), Person(), Person("Bob"))
|
||||
val men = arrayListOf(Person2("Phill"), Person2(), Person2("Bob"))
|
||||
for (k in men) {
|
||||
loop@ for (i in men) {
|
||||
i.name
|
||||
@@ -51,6 +50,8 @@ fun case2() {
|
||||
val a = 1
|
||||
}
|
||||
|
||||
class Person2(var name: String? = null) {}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
|
||||
fun case3() {
|
||||
|
||||
+6
-2
@@ -42,11 +42,11 @@ fun case2() {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
interface Processable<T> {
|
||||
interface ProcessableCase3<T> {
|
||||
fun process(): T
|
||||
}
|
||||
|
||||
class Processor : Processable<Unit> {
|
||||
class Processor : ProcessableCase3<Unit> {
|
||||
override fun process() {
|
||||
val proc = "case 3"
|
||||
}
|
||||
@@ -58,6 +58,10 @@ fun case3() {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
interface Processable<T> {
|
||||
fun process(): T
|
||||
}
|
||||
|
||||
fun case4() {
|
||||
val p2 = object : Processable<Unit> {
|
||||
override fun process() {
|
||||
|
||||
Vendored
+41
-15
@@ -14,28 +14,38 @@
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
|
||||
class A(val a: Int) {
|
||||
var isCompared = false
|
||||
operator fun compareTo(other: A): Int = run {
|
||||
isCompared = true
|
||||
this.a - other.a
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case1() {
|
||||
val a1 = A(-1)
|
||||
val a2 = A(-3)
|
||||
val a1 = A1(-1)
|
||||
val a2 = A1(-3)
|
||||
|
||||
val x = a1 < a2
|
||||
|
||||
x checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
class A1(val a: Int) {
|
||||
var isCompared = false
|
||||
operator fun compareTo(other: A1): Int = run {
|
||||
isCompared = true
|
||||
this.a - other.a
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
class A2(val a: Int) {
|
||||
var isCompared = false
|
||||
operator fun compareTo(other: A2): Int = run {
|
||||
isCompared = true
|
||||
this.a - other.a
|
||||
}
|
||||
}
|
||||
|
||||
fun case2() {
|
||||
val a1 = A(-1)
|
||||
val a2 = A(-3)
|
||||
val a1 = A2(-1)
|
||||
val a2 = A2(-3)
|
||||
|
||||
val x = a1 > a2
|
||||
|
||||
@@ -44,20 +54,36 @@ fun case2() {
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun case3() {
|
||||
val a1 = A(-1)
|
||||
val a2 = A(-3)
|
||||
val a1 = A3(-1)
|
||||
val a2 = A3(-3)
|
||||
|
||||
val x = a1 <= a2
|
||||
|
||||
x checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
class A3(val a: Int) {
|
||||
var isCompared = false
|
||||
operator fun compareTo(other: A3): Int = run {
|
||||
isCompared = true
|
||||
this.a - other.a
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
fun case4() {
|
||||
val a1 = A(-1)
|
||||
val a2 = A(-3)
|
||||
val a1 = A4(-1)
|
||||
val a2 = A4(-3)
|
||||
|
||||
val x = a1 >= a2
|
||||
|
||||
x checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
class A4(val a: Int) {
|
||||
var isCompared = false
|
||||
operator fun compareTo(other: A4): Int = run {
|
||||
isCompared = true
|
||||
this.a - other.a
|
||||
}
|
||||
}
|
||||
+7
@@ -13,6 +13,8 @@
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
|
||||
// FILE: TestCases.kt
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
|
||||
fun case1() {
|
||||
@@ -59,7 +61,12 @@ interface `true`{}
|
||||
interface `false`{}
|
||||
|
||||
|
||||
// FILE: TestCase7.kt
|
||||
// TESTCASE NUMBER: 7
|
||||
package testPackCase7c
|
||||
|
||||
interface `true`{}
|
||||
interface `false`{}
|
||||
|
||||
fun case7() {
|
||||
class `true` : `false`{}
|
||||
|
||||
+5
-2
@@ -13,7 +13,6 @@
|
||||
* DESCRIPTION: Value equality expressions always have type kotlin.Boolean as does the equals method in kotlin.Any
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
data class A(val a: Boolean)
|
||||
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
@@ -22,12 +21,16 @@ fun case1() {
|
||||
x checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
data class A(val a: Boolean)
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
fun case2() {
|
||||
val x = A(false) == A(false)
|
||||
val x = A1(false) == A1(false)
|
||||
x checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
data class A1(val a: Boolean)
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun case3() {
|
||||
val x = true == false
|
||||
|
||||
Vendored
+5
-2
@@ -12,6 +12,8 @@
|
||||
* DESCRIPTION: check he type of jump expressions is the kotlin.Nothing
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
|
||||
fun case1() {
|
||||
@@ -27,14 +29,13 @@ fun case1() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>s<!>
|
||||
}
|
||||
}
|
||||
|
||||
class Person(var name: String? = null) {}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
|
||||
fun case2() {
|
||||
var name: Any? = null
|
||||
val men = arrayListOf(Person("Phill"), Person(), Person("Bob"))
|
||||
val men = arrayListOf(Person2("Phill"), Person2(), Person2("Bob"))
|
||||
for (k in men) {
|
||||
loop@ for (i in men) {
|
||||
val val1 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>continue@loop<!>
|
||||
@@ -45,6 +46,8 @@ fun case2() {
|
||||
}
|
||||
}
|
||||
|
||||
class Person2(var name: String? = null) {}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
|
||||
fun case3() {
|
||||
|
||||
+19
-8
@@ -11,14 +11,7 @@
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: check unsafe prefix decrement expression call for an assignable expression
|
||||
*/
|
||||
class A() {
|
||||
var i = 0
|
||||
|
||||
operator fun dec(): A {
|
||||
this.i--
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
|
||||
@@ -32,6 +25,15 @@ class Case1() {
|
||||
var a: A = A()
|
||||
}
|
||||
|
||||
class A() {
|
||||
var i = 0
|
||||
|
||||
operator fun dec(): A {
|
||||
this.i--
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
|
||||
fun case2() {
|
||||
@@ -40,5 +42,14 @@ fun case2() {
|
||||
}
|
||||
|
||||
class Case2() {
|
||||
val a = A()
|
||||
val a = A2()
|
||||
}
|
||||
|
||||
class A2() {
|
||||
var i = 0
|
||||
|
||||
operator fun dec(): A2 {
|
||||
this.i--
|
||||
return this
|
||||
}
|
||||
}
|
||||
+17
-2
@@ -11,6 +11,12 @@
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: check unsafe prefix increment expression call for an assignable expression
|
||||
*/
|
||||
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 1
|
||||
package testPackCase1
|
||||
|
||||
class A() {
|
||||
var i = 0
|
||||
|
||||
@@ -20,8 +26,6 @@ class A() {
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
|
||||
fun case1() {
|
||||
var b: Case1? = Case1()
|
||||
<!UNSAFE_CALL!>++<!>b?.a
|
||||
@@ -32,7 +36,18 @@ class Case1() {
|
||||
var a: A = A()
|
||||
}
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 2
|
||||
package testPackCase2
|
||||
|
||||
class A() {
|
||||
var i = 0
|
||||
|
||||
operator fun inc(): A {
|
||||
this.i++
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
fun case2() {
|
||||
var b= Case2()
|
||||
|
||||
+37
-7
@@ -11,15 +11,22 @@
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: The type of the try-expression is the least upper bound of the types of the last expressions of the try body and the last expressions of all the catch blocks
|
||||
*/
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 1
|
||||
package testPackCase1
|
||||
|
||||
fun throwExceptionA(b: Boolean) = run { if (b) throw ExcA() }
|
||||
|
||||
class ExcA() : Exception()
|
||||
class ExcB() : Exception()
|
||||
|
||||
open class A<T>(var data: T) {
|
||||
fun foo(d: A<T>) {}
|
||||
}
|
||||
|
||||
class B<T>(data: T) : A<T>(data)
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
|
||||
fun case1() {
|
||||
val tryVal: B<String> =
|
||||
@@ -29,11 +36,24 @@ fun case1() {
|
||||
}<!> catch (e: Exception) {
|
||||
B("")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 2
|
||||
package testPackCase2
|
||||
|
||||
fun throwExceptionA(b: Boolean) = run { if (b) throw ExcA() }
|
||||
|
||||
class ExcA() : Exception()
|
||||
class ExcB() : Exception()
|
||||
|
||||
open class A<T>(var data: T) {
|
||||
fun foo(d: A<T>) {}
|
||||
}
|
||||
|
||||
class B<T>(data: T) : A<T>(data)
|
||||
|
||||
|
||||
|
||||
fun case2() {
|
||||
val tryVal: A<String> =
|
||||
@@ -45,10 +65,20 @@ fun case2() {
|
||||
}<!>
|
||||
}
|
||||
|
||||
/*
|
||||
* TESTCASE NUMBER: 3
|
||||
* ISSUES: KT-35494
|
||||
*/
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 3
|
||||
// ISSUES: KT-35494
|
||||
package testPackCase3
|
||||
|
||||
fun throwExceptionA(b: Boolean) = run { if (b) throw ExcA() }
|
||||
|
||||
open class A<T>(var data: T) {
|
||||
fun foo(d: A<T>) {}
|
||||
}
|
||||
|
||||
class B<T>(data: T) : A<T>(data)
|
||||
|
||||
fun case3() {
|
||||
val tryVal: A<Int> =
|
||||
try {
|
||||
|
||||
+64
-1
@@ -13,6 +13,13 @@
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 1
|
||||
package testPackCase1
|
||||
import checkType
|
||||
import check
|
||||
|
||||
class A(val a: Set<Any>) {
|
||||
operator fun contains(other: Any?): Boolean = run { this.a.contains(other) }
|
||||
|
||||
@@ -27,7 +34,6 @@ class C() {
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case1() {
|
||||
val b = A(mutableSetOf(1, C(), 3, false, 2, "azaza"))
|
||||
val c = C()
|
||||
@@ -35,14 +41,52 @@ fun case1() {
|
||||
a checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 2
|
||||
package testPackCase2
|
||||
import checkType
|
||||
import check
|
||||
|
||||
class A(val a: Set<Any>) {
|
||||
operator fun contains(other: Any?): Boolean = run { this.a.contains(other) }
|
||||
|
||||
fun throwException(b: Boolean): A { if (b) throw Exception() else return this }
|
||||
}
|
||||
|
||||
class C() {
|
||||
var isEvaluated: Boolean = false
|
||||
fun foo(): C {
|
||||
this.isEvaluated = true
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
fun case2() {
|
||||
val b = A(mutableSetOf(1, C(), 3, false, 2, "azaza"))
|
||||
val a = (null in b)
|
||||
a checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 3
|
||||
package testPackCase3
|
||||
import checkType
|
||||
import check
|
||||
|
||||
class A(val a: Set<Any>) {
|
||||
operator fun contains(other: Any?): Boolean = run { this.a.contains(other) }
|
||||
|
||||
fun throwException(b: Boolean): A { if (b) throw Exception() else return this }
|
||||
}
|
||||
|
||||
class C() {
|
||||
var isEvaluated: Boolean = false
|
||||
fun foo(): C {
|
||||
this.isEvaluated = true
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
fun case3() {
|
||||
val b = A(mutableSetOf(1, C(), 3, false, 2, "azaza"))
|
||||
val x = ""
|
||||
@@ -50,7 +94,26 @@ fun case3() {
|
||||
a checkType { check<Boolean>() }
|
||||
}
|
||||
|
||||
// FILE: TestCase.kt
|
||||
// TESTCASE NUMBER: 4
|
||||
package testPackCase4
|
||||
import checkType
|
||||
import check
|
||||
|
||||
class A(val a: Set<Any>) {
|
||||
operator fun contains(other: Any?): Boolean = run { this.a.contains(other) }
|
||||
|
||||
fun throwException(b: Boolean): A { if (b) throw Exception() else return this }
|
||||
}
|
||||
|
||||
class C() {
|
||||
var isEvaluated: Boolean = false
|
||||
fun foo(): C {
|
||||
this.isEvaluated = true
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
fun case4(nothing: Nothing) {
|
||||
val b = A(mutableSetOf(1, C(), 3, false, 2, "azaza"))
|
||||
val a = (nothing in b)
|
||||
|
||||
Reference in New Issue
Block a user