From bb44fdda88cad7de0224b8b41a6a1643d5f3267e Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Wed, 25 Jul 2018 17:49:45 +0300 Subject: [PATCH] New stdlib tests - Unzip from the same test-data archive - Add actual declarations --- backend.native/tests/build.gradle | 16 ++++++++++++++-- .../jsCollectionFactoriesActuals.kt | 11 +++++++++++ backend.native/tests/stdlib_external/utils.kt | 15 +++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 backend.native/tests/stdlib_external/jsCollectionFactoriesActuals.kt create mode 100644 backend.native/tests/stdlib_external/utils.kt diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 1dd9a8d2383..cd00aae3b1c 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -123,7 +123,7 @@ task update_external_tests() { // from(zipTree(it)) { from(zipTree(file('/Users/ppunegov/ws/kotlin/dist/kotlin-test-data.zip'))) { - include 'compiler/**' + include('compiler/**', 'stdlib/**') } into(temporaryDir) } @@ -141,6 +141,16 @@ task update_external_tests() { include 'compileKotlinAgainstKotlin/**' } + externalStdlibTestsDir.mkdirs() + delete("${externalStdlibTestsDir.canonicalPath}/common") + delete("${externalStdlibTestsDir.canonicalPath}/test") + copy { + from temporaryDir.absolutePath + "/stdlib" + into(externalStdlibTestsDir) + include 'common/**' + include 'test/**' + } + //clean tmp dir. delete temporaryDir } @@ -2930,7 +2940,9 @@ task runKonanRegexTests(type: RunKonanTest) { task buildKonanStdlibTests(type: BuildKonanTest) { outputSourceSetName = "testOutputStdlib" - compileList = [ "stdlib_external", "testUtils.kt" ] + flags = [ "-Xmulti-platform" ] + compileList = [ "stdlib_external/test", "stdlib_external/common", + "stdlib_external/utils.kt", "stdlib_external/jsCollectionFactoriesActuals.kt" ] } task runStdlibTests(type: RunStdlibTest) { diff --git a/backend.native/tests/stdlib_external/jsCollectionFactoriesActuals.kt b/backend.native/tests/stdlib_external/jsCollectionFactoriesActuals.kt new file mode 100644 index 00000000000..0ded9141b73 --- /dev/null +++ b/backend.native/tests/stdlib_external/jsCollectionFactoriesActuals.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package test.collections.js + +actual fun stringMapOf(vararg pairs: Pair): HashMap = hashMapOf(*pairs) +actual fun linkedStringMapOf(vararg pairs: Pair): LinkedHashMap = linkedMapOf(*pairs) +actual fun stringSetOf(vararg elements: String): HashSet = hashSetOf(*elements) +actual fun linkedStringSetOf(vararg elements: String): LinkedHashSet = linkedSetOf(*elements) \ No newline at end of file diff --git a/backend.native/tests/stdlib_external/utils.kt b/backend.native/tests/stdlib_external/utils.kt new file mode 100644 index 00000000000..7ad94d22702 --- /dev/null +++ b/backend.native/tests/stdlib_external/utils.kt @@ -0,0 +1,15 @@ +package test + +import kotlin.test.* + +public actual fun assertTypeEquals(expected: Any?, actual: Any?) { + if (expected != null && actual != null) { + assertEquals(expected::class, actual::class) + } else { + assertTrue(expected == null && actual == null) + } +} + +public actual fun randomInt(limit: Int): Int = kotlin.random.Random.nextInt(limit) + +internal actual fun String.removeLeadingPlusOnJava6(): String = this \ No newline at end of file