[K/N] Convert and enable some tests using System.out?.println()
^KT-59057 Merge-request: KT-MR-10546 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
67b00f86b7
commit
1e05cb308c
+1
-8
@@ -1,15 +1,8 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: Enable for JS when it supports Java class library.
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
class List<T>(val head: T, val tail: List<T>? = null)
|
||||
|
||||
fun <T> List<T>.mapHead(f: (T)-> T): List<T> = List<T>(f(head), null)
|
||||
|
||||
fun box() : String {
|
||||
val a: Int = List<Int>(1).mapHead{it * 2}.head
|
||||
System.out?.println(a)
|
||||
return "OK"
|
||||
return if (a == 2) "OK" else a.toString()
|
||||
}
|
||||
|
||||
+4
-11
@@ -1,18 +1,11 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
fun main(args: Array<String>?) {
|
||||
val y: Unit = Unit //do not compile
|
||||
A<Unit>() //do not compile
|
||||
C<Unit>(Unit) //do not compile
|
||||
//do not compile
|
||||
System.out?.println(fff<Unit>(Unit)) //do not compile
|
||||
System.out?.println(id<Unit>(y)) //do not compile
|
||||
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(arrayOfNulls<Int>(0) as Array<Int>,{ e : Int -> }))) //do not compile
|
||||
fff<Unit>(Unit) //do not compile
|
||||
id<Unit>(y) //do not compile
|
||||
fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(arrayOfNulls<Int>(0) as Array<Int>,{ e : Int -> })) //do not compile
|
||||
}
|
||||
class A<T>()
|
||||
|
||||
@@ -41,7 +34,7 @@ fun box() : String {
|
||||
a[0] = 0
|
||||
a[1] = 1
|
||||
a[2] = 2
|
||||
foreach(a, { el : Int -> System.out?.println(el) })
|
||||
foreach(a, { el : Int -> el })
|
||||
almostFilter(a, { el : Int -> el })
|
||||
main(null)
|
||||
return "OK"
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
package w_range
|
||||
|
||||
fun box() : String {
|
||||
@@ -13,6 +6,5 @@ fun box() : String {
|
||||
1 -> i--
|
||||
else -> { i = 2 }
|
||||
}
|
||||
System.out?.println(i)
|
||||
return "OK"
|
||||
return if (i == 2) "OK" else i.toString()
|
||||
}
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
package kt606
|
||||
|
||||
//KT-606 wrong resolved call
|
||||
@@ -21,9 +14,11 @@ interface ChannelPipeline {
|
||||
fun print(any: Any)
|
||||
}
|
||||
|
||||
var result = "FAIL"
|
||||
|
||||
class DefaultChannelPipeline : ChannelPipeline {
|
||||
override fun print(any: Any) {
|
||||
System.out?.println(any)
|
||||
result = any as String
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,5 +29,5 @@ interface ChannelPipelineFactory {
|
||||
|
||||
fun box() : String {
|
||||
StandardPipelineFactory({ print("OK") }).getPipeline()
|
||||
return "OK"
|
||||
return result
|
||||
}
|
||||
|
||||
+2
-10
@@ -1,10 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
class Identifier<T>(t : T?, myHasDollar : Boolean) {
|
||||
private val myT : T?
|
||||
|
||||
@@ -22,7 +15,6 @@ class Identifier<T>(t : T?, myHasDollar : Boolean) {
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
var i3 : Identifier<String?>? = Identifier.init<String?>("name")
|
||||
System.out?.println(i3?.getName())
|
||||
return "OK"
|
||||
var i3 : Identifier<String?>? = Identifier.init<String?>("OK")
|
||||
return i3?.getName() ?: "FAIL"
|
||||
}
|
||||
|
||||
+2
-9
@@ -1,10 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
package bitwise_demo
|
||||
|
||||
fun Long?.shl(bits : Int?) : Long = this!!.shl(bits!!)
|
||||
@@ -13,6 +6,6 @@ fun box() : String {
|
||||
val x : Long? = 10
|
||||
val y : Int? = 12
|
||||
|
||||
System.out?.println(x.shl(y))
|
||||
return "OK"
|
||||
val result = x.shl(y)
|
||||
return if (result == 40960L) "OK" else result.toString()
|
||||
}
|
||||
|
||||
+5
-9
@@ -1,10 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
package demo_range
|
||||
|
||||
operator fun Int?.unaryPlus() : Int = this!!.unaryPlus()
|
||||
@@ -14,6 +7,9 @@ operator fun Int?.unaryMinus() : Int = this!!.unaryMinus()
|
||||
|
||||
fun box() : String {
|
||||
val x : Int? = 10
|
||||
System.out?.println(x?.inv())// * x?.unaryPlus() * x?.dec() * x?.unaryMinus() as Number)
|
||||
return "OK"
|
||||
val result = x?.inv()
|
||||
if (result == -11)// * x?.unaryPlus() * x?.dec() * x?.unaryMinus() as Number)
|
||||
return "OK"
|
||||
else
|
||||
return result.toString()
|
||||
}
|
||||
|
||||
+2
-9
@@ -1,16 +1,9 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
package demo_long
|
||||
|
||||
fun Long?.inv() : Long = this!!.inv()
|
||||
|
||||
fun box() : String {
|
||||
val x : Long? = 10
|
||||
System.out?.println(x.inv())
|
||||
return if(x.inv() == -11.toLong()) "OK" else "fail"
|
||||
val result = x.inv()
|
||||
return if(result == -11.toLong()) "OK" else result.toString()
|
||||
}
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_STDLIB
|
||||
|
||||
fun s0() : Boolean {
|
||||
@@ -41,7 +34,6 @@ fun t1() : Boolean {
|
||||
foo()
|
||||
|
||||
x += "bbb"
|
||||
System.out?.println(x)
|
||||
return x == "4511122aaabbb"
|
||||
}
|
||||
|
||||
@@ -56,7 +48,6 @@ fun t2() : Boolean {
|
||||
}
|
||||
foo()
|
||||
x -= 55
|
||||
System.out?.println(x)
|
||||
return x == 200
|
||||
}
|
||||
|
||||
@@ -79,7 +70,6 @@ fun t4() : Boolean {
|
||||
Unit
|
||||
}
|
||||
foo()
|
||||
System.out?.println(x)
|
||||
return x == 440.toFloat()
|
||||
}
|
||||
|
||||
@@ -92,7 +82,6 @@ fun t5() : Boolean {
|
||||
Unit
|
||||
}
|
||||
foo()
|
||||
System.out?.println(x)
|
||||
return x == 400.toDouble()
|
||||
}
|
||||
|
||||
@@ -106,7 +95,6 @@ fun t6() : Boolean {
|
||||
Unit
|
||||
}
|
||||
foo()
|
||||
System.out?.println(x)
|
||||
return x == 83.toByte()
|
||||
}
|
||||
|
||||
@@ -117,7 +105,6 @@ fun t7() : Boolean {
|
||||
Unit
|
||||
}
|
||||
foo()
|
||||
System.out?.println(x)
|
||||
return x == 'b'
|
||||
}
|
||||
|
||||
@@ -171,19 +158,6 @@ fun t11(x0: Int) : Int {
|
||||
return x
|
||||
}
|
||||
|
||||
fun t12(x: Int) : Int {
|
||||
var y = x
|
||||
val runnable = object : Runnable {
|
||||
override fun run () {
|
||||
y = y + 1
|
||||
}
|
||||
}
|
||||
while(y < 100) {
|
||||
runnable.run()
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (!s0()) return "s0 fail"
|
||||
if (!s1()) return "s1 fail"
|
||||
@@ -198,7 +172,6 @@ fun box(): String {
|
||||
if (!t9(0)) return "t9 fail"
|
||||
if (!t10()) return "t10 fail"
|
||||
if (t11(1) != 101) return "t11 fail"
|
||||
if (t12(0) != 100) return "t12 fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
|
||||
fun t12(x: Int) : Int {
|
||||
var y = x
|
||||
val runnable = object : Runnable {
|
||||
override fun run () {
|
||||
y = y + 1
|
||||
}
|
||||
}
|
||||
while(y < 100) {
|
||||
runnable.run()
|
||||
}
|
||||
return y
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = t12(0)
|
||||
return if (result == 100) "OK" else result.toString()
|
||||
}
|
||||
@@ -1,12 +1,4 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
operator fun Int.plus(s: String) : String {
|
||||
System.out?.println("Int.plus(s: String) called")
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user