[JS IR] Add stdlib regression tests
This commit is contained in:
+33
@@ -6745,6 +6745,39 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
public void testTmpInsidePrimaryConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/tmpInsidePrimaryConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/regression/stdlibTestSnippets")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class StdlibTestSnippets extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInStdlibTestSnippets() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/regression/stdlibTestSnippets"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayTest_plusInference.kt")
|
||||
public void testArrayTest_plusInference() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/arrayTest_plusInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("iterableChunked.kt")
|
||||
public void testIterableChunked() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/iterableChunked.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("json.kt")
|
||||
public void testJson() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/json.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwable.kt")
|
||||
public void testThrowable() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/throwable.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/reified")
|
||||
|
||||
+33
@@ -6780,6 +6780,39 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
public void testTmpInsidePrimaryConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/tmpInsidePrimaryConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/regression/stdlibTestSnippets")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class StdlibTestSnippets extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInStdlibTestSnippets() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/regression/stdlibTestSnippets"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayTest_plusInference.kt")
|
||||
public void testArrayTest_plusInference() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/arrayTest_plusInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("iterableChunked.kt")
|
||||
public void testIterableChunked() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/iterableChunked.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("json.kt")
|
||||
public void testJson() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/json.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwable.kt")
|
||||
public void testThrowable() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/stdlibTestSnippets/throwable.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/reified")
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1273
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
// Copy of stdlib test test.collections.ArraysTest.plusInference
|
||||
|
||||
fun box(): String {
|
||||
val arrayOfArrays: Array<Array<out Any>> = arrayOf(arrayOf<Any>("s") as Array<out Any>)
|
||||
val elementArray = arrayOf<Any>("a") as Array<out Any>
|
||||
val arrayPlusElement: Array<Array<out Any>> = arrayOfArrays.plusElement(elementArray)
|
||||
assertEquals("a", arrayPlusElement[1][0])
|
||||
|
||||
val arrayOfStringArrays = arrayOf(arrayOf("s"))
|
||||
val arrayPlusArray = arrayOfStringArrays + arrayOfStringArrays
|
||||
assertEquals("s", arrayPlusArray[1][0])
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1750
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
fun box(): String {
|
||||
val size = 2
|
||||
val a = Array(size) { "$it" }
|
||||
val data = Iterable { a.iterator() }
|
||||
|
||||
val dataChunked = data.chunked(size).single()
|
||||
val expectedSingleChunk = data.toList()
|
||||
if (expectedSingleChunk != dataChunked)
|
||||
return "Fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1274
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
import kotlin.js.json
|
||||
|
||||
fun box(): String {
|
||||
var obj = json(Pair("firstName", "John"), Pair("lastName", "Doe"), Pair("age", 30))
|
||||
assertEquals("John", obj["firstName"], "firstName")
|
||||
assertEquals("Doe", obj["lastName"], "lastName")
|
||||
assertEquals(30, obj["age"], "age")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1279
|
||||
// Snippet from stdlib test test.exceptions.ExceptionTest
|
||||
|
||||
private val cause = Exception("cause")
|
||||
|
||||
fun assertSame(x: Any?, y: Any?) {
|
||||
if (x !== y) {
|
||||
error("Assertion failed")
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T : Throwable> testCreateException(
|
||||
noarg: () -> T,
|
||||
fromMessage: (String?) -> T,
|
||||
fromCause: ((Throwable?) -> T)? = null,
|
||||
fromMessageCause: ((String?, Throwable?) -> T)? = null
|
||||
) {
|
||||
noarg().let { e ->
|
||||
assertEquals(null, e.message)
|
||||
assertEquals(null, e.cause)
|
||||
}
|
||||
|
||||
fromMessage("message").let { e ->
|
||||
assertEquals("message", e.message)
|
||||
assertEquals(null, e.cause)
|
||||
}
|
||||
|
||||
fromMessage(null).let { e ->
|
||||
assertTrue(e.message == null || e.message == "null")
|
||||
}
|
||||
|
||||
fromMessageCause?.run {
|
||||
invoke("message", cause).let { e ->
|
||||
assertEquals("message", e.message)
|
||||
assertSame(cause, e.cause)
|
||||
}
|
||||
invoke(null, null).let { e ->
|
||||
assertEquals(null, e.message)
|
||||
assertEquals(null, e.cause)
|
||||
}
|
||||
}
|
||||
|
||||
fromCause?.invoke(cause)?.let { e ->
|
||||
assertSame(cause, e.cause)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
testCreateException(::Throwable, ::Throwable, ::Throwable, ::Throwable)
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user