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,25 @@
// WITH_STDLIB
// TARGET_BACKEND: JS_IR
// FILE: main.js
Math.trunc = function trunc(x) {
trunc.called = true;
if (isNaN(x)) {
return NaN;
}
if (x > 0) {
return Math.floor(x);
}
return Math.ceil(x);
}
// FILE: main.kt
import kotlin.math.truncate
fun box(): String {
val result = truncate(1.188)
assertEquals(result, 1)
assertEquals(js("Math.trunc.called"), true)
return "OK"
}
@@ -0,0 +1,16 @@
// WITH_STDLIB
// TARGET_BACKEND: JS_IR
// FILE: main.js
Math.trunc = undefined;
// FILE: main.kt
import kotlin.math.truncate
fun box(): String {
val result = truncate(1.188)
assertEquals(result, 1)
assertEquals(js("Math.trunc.called"), js("undefined"))
return "OK"
}