From 804d2b2d8c216c3fd4fc2671f667bc2d9a7378fe Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 9 Apr 2019 05:26:40 +0300 Subject: [PATCH] Helper utilities to execute test code on particular platforms --- libraries/stdlib/common/test/testUtils.kt | 5 ++++- libraries/stdlib/js/test/core/testUtils.kt | 6 +++++- libraries/stdlib/jvm/test/testUtilsJVM.kt | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libraries/stdlib/common/test/testUtils.kt b/libraries/stdlib/common/test/testUtils.kt index 10d38a32136..ee11d89a8dc 100644 --- a/libraries/stdlib/common/test/testUtils.kt +++ b/libraries/stdlib/common/test/testUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -10,3 +10,6 @@ public expect fun assertTypeEquals(expected: Any?, actual: Any?) internal expect fun String.removeLeadingPlusOnJava6(): String internal expect inline fun testOnNonJvm6And7(f: () -> Unit) + +public expect fun testOnJvm(action: () -> Unit) +public expect fun testOnJs(action: () -> Unit) \ No newline at end of file diff --git a/libraries/stdlib/js/test/core/testUtils.kt b/libraries/stdlib/js/test/core/testUtils.kt index 66b141e6f85..fdbd9bac25d 100644 --- a/libraries/stdlib/js/test/core/testUtils.kt +++ b/libraries/stdlib/js/test/core/testUtils.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -17,3 +17,7 @@ internal actual inline fun String.removeLeadingPlusOnJava6(): String = this internal actual inline fun testOnNonJvm6And7(f: () -> Unit) { f() } + + +public actual fun testOnJvm(action: () -> Unit) { } +public actual fun testOnJs(action: () -> Unit) = action() \ No newline at end of file diff --git a/libraries/stdlib/jvm/test/testUtilsJVM.kt b/libraries/stdlib/jvm/test/testUtilsJVM.kt index 2246955adbf..3d65aa70485 100644 --- a/libraries/stdlib/jvm/test/testUtilsJVM.kt +++ b/libraries/stdlib/jvm/test/testUtilsJVM.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -24,4 +24,6 @@ internal actual inline fun testOnNonJvm6And7(f: () -> Unit) { if (isJava8AndAbove) { f() } -} \ No newline at end of file +} +public actual fun testOnJvm(action: () -> Unit) = action() +public actual fun testOnJs(action: () -> Unit) {} \ No newline at end of file