JS backend: testFiles -> testData
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package foo
|
||||
|
||||
class A
|
||||
|
||||
fun checkCastNullableToNotNull(): Boolean {
|
||||
val a = null
|
||||
try {
|
||||
val s = a as A
|
||||
}
|
||||
catch (e: Exception) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun checkCastNotNullToNotNull(): Boolean {
|
||||
val a = A()
|
||||
var s = a as A
|
||||
return s == a
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (!checkCastNullableToNotNull()) return "Failed when try cast Nullable to NotNull"
|
||||
if (!checkCastNotNullToNotNull()) return "Failed when try cast NotNull to NotNull"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package foo
|
||||
|
||||
class A
|
||||
|
||||
fun box(): String {
|
||||
val a = null
|
||||
val s = a as A?
|
||||
if (s != null) return "Failed when try cast Nullable with null value to Nullable"
|
||||
|
||||
val b: A? = A()
|
||||
val n = b as A?
|
||||
if (n != b) return "Failed when try cast Nullable with not null value to Nullable"
|
||||
|
||||
val c = A()
|
||||
val m = c as A?
|
||||
if (m != c) return "Failed when try cast NotNull to Nullable"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
fun foo(a: Int) = "A.foo($a)"
|
||||
}
|
||||
|
||||
fun Any.bar() = "Any.bar()"
|
||||
fun A.bar() = "A.bar()"
|
||||
|
||||
fun boo(a: Any) = "boo(Any)"
|
||||
fun boo(a: A) = "boo(A)"
|
||||
|
||||
fun assert<T>(expected: T, actual: T, caseName: String) {
|
||||
if (expected != actual) throw Exception("Filed on $caseName, expected: $expected, actual: $actual")
|
||||
}
|
||||
|
||||
fun Any.testInTopLevel() {
|
||||
assert(bar(), "Any.bar()", "bar()")
|
||||
assert(this.bar(), "Any.bar()", "this.bar()")
|
||||
assert(boo(this), "boo(Any)", "boo(this)")
|
||||
|
||||
if (this is A) {
|
||||
assert(foo(47), "A.foo(47)", "foo(47)")
|
||||
assert(bar(), "A.bar()", "bar()")
|
||||
|
||||
assert(this.foo(47), "A.foo(47)", "this.foo(47)")
|
||||
assert(this.bar(), "A.bar()", "this.bar()")
|
||||
|
||||
assert(boo(this), "boo(A)", "boo(this: A)")
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun Any.test() {
|
||||
assert(bar(), "Any.bar()", "bar()")
|
||||
assert(this.bar(), "Any.bar()", "this.bar()")
|
||||
assert(boo(this), "boo(Any)", "boo(this)")
|
||||
|
||||
if (this is A) {
|
||||
assert(foo(47), "A.foo(47)", "foo(47)")
|
||||
assert(bar(), "A.bar()", "bar()")
|
||||
|
||||
assert(this.foo(47), "A.foo(47)", "this.foo(47)")
|
||||
assert(this.bar(), "A.bar()", "this.bar()")
|
||||
|
||||
assert(boo(this), "boo(A)", "boo(this: A)")
|
||||
}
|
||||
}
|
||||
|
||||
fun testInClass() {
|
||||
A().test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
A().testInTopLevel()
|
||||
B().testInClass()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
fun foo(a: Int) = "A.foo($a)"
|
||||
}
|
||||
|
||||
fun Any.bar() = "Any.bar()"
|
||||
fun A.bar() = "A.bar()"
|
||||
|
||||
fun boo(a: Any) = "boo(Any)"
|
||||
fun boo(a: A) = "boo(A)"
|
||||
|
||||
fun assert<T>(expected: T, actual: T, caseName: String) {
|
||||
if (expected != actual) throw Exception("Filed on $caseName, expected: $expected, actual: $actual")
|
||||
}
|
||||
|
||||
fun testInTopLevel(a: Any) {
|
||||
assert(a.bar(), "Any.bar()", "bar()")
|
||||
assert(a.bar(), "Any.bar()", "this.bar()")
|
||||
assert(boo(a), "boo(Any)", "boo(this)")
|
||||
|
||||
if (a is A) {
|
||||
assert(a.foo(47), "A.foo(47)", "a.foo(47)")
|
||||
assert(a.bar(), "A.bar()", "a.bar()")
|
||||
assert(boo(a), "boo(A)", "boo(a: A)")
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
fun testInClass(a: Any) {
|
||||
assert(a.bar(), "Any.bar()", "bar()")
|
||||
assert(a.bar(), "Any.bar()", "this.bar()")
|
||||
assert(boo(a), "boo(Any)", "boo(this)")
|
||||
|
||||
if (a is A) {
|
||||
assert(a.foo(47), "A.foo(47)", "a.foo(47)")
|
||||
assert(a.bar(), "A.bar()", "a.bar()")
|
||||
assert(boo(a), "boo(A)", "boo(a: A)")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
testInTopLevel(A())
|
||||
B().testInClass(A())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user