feat: add polyfills insertion for ES Next used features

This commit is contained in:
Artem Kobzar
2022-02-16 10:49:11 +00:00
committed by Space
parent 76ff717091
commit 804eb61bf0
80 changed files with 8769 additions and 6552 deletions
@@ -0,0 +1,18 @@
// WITH_STDLIB
// TARGET_BACKEND: JS_IR
// FILE: main.js
ArrayBuffer.isView = function isView(a) {
isView.called = true;
return a != null && a.__proto__ != null && a.__proto__.__proto__ === Int8Array.prototype.__proto__;
}
// FILE: main.kt
fun box(): String {
val intArr = intArrayOf(5, 4, 3, 2, 1)
val result = IntArray(5).apply { intArr.copyInto(this) }
assertEquals(result.joinToString(","), intArr.joinToString(","))
assertEquals(js("ArrayBuffer.isView.called"), true)
return "OK"
}
@@ -0,0 +1,15 @@
// WITH_STDLIB
// TARGET_BACKEND: JS_IR
// FILE: main.js
ArrayBuffer.isView = undefined;
// FILE: main.kt
fun box(): String {
val intArr = intArrayOf(5, 4, 3, 2, 1)
val result = IntArray(5).apply { intArr.copyInto(this) }
assertEquals(result.joinToString(","), intArr.joinToString(","))
assertEquals(js("ArrayBuffer.isView.called"), js("undefined"))
return "OK"
}