kotlin-test: extract from JS library, convert to multiplatform
This commit is contained in:
@@ -488,7 +488,7 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="kotlin-js-stdlib" depends="js-stdlib,pack-js-stdlib-sources"/>
|
||||
<target name="kotlin-js-stdlib" depends="js-stdlib,js-kotlin-test,pack-js-stdlib-sources"/>
|
||||
|
||||
<target name="preloader">
|
||||
<cleandir dir="${output}/classes/preloader"/>
|
||||
@@ -1061,18 +1061,34 @@
|
||||
</target>
|
||||
|
||||
<target name="kotlin-test">
|
||||
<new-kotlinc output="${output}/classes/kotlin-test" moduleName="kotlin-test">
|
||||
<src>
|
||||
<include name="libraries/kotlin.test/shared/src/main/kotlin" />
|
||||
<include name="libraries/kotlin.test/shared/src/main/kotlin.jvm" />
|
||||
<include name="libraries/kotlin.test/junit/src/main/kotlin" />
|
||||
</src>
|
||||
<class-path>
|
||||
<pathelement path="${output}/classes/builtins"/>
|
||||
<pathelement path="libraries/lib/junit-4.11.jar"/>
|
||||
<pathelement path="${output}/builtins"/>
|
||||
</class-path>
|
||||
</new-kotlinc>
|
||||
<path id="kotlin-test-compile-classpath">
|
||||
<pathelement location="${output}/classes/builtins"/>
|
||||
<pathelement location="${output}/builtins"/>
|
||||
</path>
|
||||
|
||||
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
|
||||
<classpath>
|
||||
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
|
||||
</classpath>
|
||||
<assertions>
|
||||
<enable/>
|
||||
</assertions>
|
||||
<arg value="-cp"/>
|
||||
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
|
||||
<arg value="org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"/>
|
||||
<arg value="-d"/>
|
||||
<arg value="${output}/classes/kotlin-test"/>
|
||||
<arg value="-version"/>
|
||||
<arg value="-no-stdlib"/>
|
||||
<arg value="-classpath"/>
|
||||
<arg value="${toString:kotlin-test-compile-classpath}"/>
|
||||
<arg value="-module-name"/>
|
||||
<arg value="kotlin-test"/>
|
||||
<arg value="-Xallow-kotlin-package"/>
|
||||
<arg value="-Xmulti-platform"/>
|
||||
<arg value="libraries/kotlin.test/shared/src/main/kotlin"/>
|
||||
<arg value="libraries/kotlin.test/jvm/src/main/kotlin"/>
|
||||
</java>
|
||||
|
||||
<pack-runtime-jar jar-name="kotlin-test.jar" implementation-title="${manifest.impl.title.kotlin.test}" runtime-component="Test">
|
||||
<jar-content>
|
||||
@@ -1080,6 +1096,35 @@
|
||||
</jar-content>
|
||||
</pack-runtime-jar>
|
||||
</target>
|
||||
|
||||
<target name="js-kotlin-test">
|
||||
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
|
||||
<classpath>
|
||||
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
|
||||
</classpath>
|
||||
<assertions>
|
||||
<enable/>
|
||||
</assertions>
|
||||
<arg value="-cp"/>
|
||||
<arg value="${kotlin-home}/lib/kotlin-compiler.jar"/>
|
||||
<arg value="org.jetbrains.kotlin.cli.js.K2JSCompiler"/>
|
||||
<arg value="-output"/>
|
||||
<arg value="${output}/classes/kotlin-test-js/kotlin-test.js"/>
|
||||
<arg value="-version"/>
|
||||
<arg value="-meta-info"/>
|
||||
<arg value="-kjsm"/>
|
||||
<arg line="-main noCall"/>
|
||||
<arg line="-module-kind umd"/>
|
||||
<arg value="-Xmulti-platform"/>
|
||||
<arg value="libraries/kotlin.test/shared/src/main/kotlin"/>
|
||||
<arg value="libraries/kotlin.test/js/src/main/kotlin"/>
|
||||
</java>
|
||||
<pack-runtime-jar jar-name="kotlin-test-js.jar" implementation-title="${manifest.impl.title.kotlin.test}" runtime-component="TestJs">
|
||||
<jar-content>
|
||||
<fileset dir="${output}/classes/kotlin-test-js" includes="**/*" excludes="kotlin/internal/OnlyInputTypes*,kotlin/internal/InlineOnly*,kotlin/internal"/>
|
||||
</jar-content>
|
||||
</pack-runtime-jar>
|
||||
</target>
|
||||
|
||||
<target name="core">
|
||||
<new-kotlinc output="${output}/classes/core" moduleName="kotlin-core">
|
||||
|
||||
@@ -48,6 +48,9 @@ public interface KotlinPaths {
|
||||
@NotNull
|
||||
File getJsStdLibSrcJarPath();
|
||||
|
||||
@NotNull
|
||||
File getJsKotlinTestJarPath();
|
||||
|
||||
@NotNull
|
||||
File getAllOpenPluginJarPath();
|
||||
|
||||
|
||||
@@ -82,6 +82,12 @@ public class KotlinPathsFromHomeDir implements KotlinPaths {
|
||||
return getLibraryFile(PathUtil.JS_LIB_SRC_JAR_NAME);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getJsKotlinTestJarPath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_TEST_JS_JAR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getAllOpenPluginJarPath() {
|
||||
|
||||
@@ -36,6 +36,7 @@ public class PathUtil {
|
||||
public static final String KOTLIN_JAVA_REFLECT_JAR = "kotlin-reflect.jar";
|
||||
public static final String KOTLIN_JAVA_SCRIPT_RUNTIME_JAR = "kotlin-script-runtime.jar";
|
||||
public static final String KOTLIN_TEST_JAR = "kotlin-test.jar";
|
||||
public static final String KOTLIN_TEST_JS_JAR = "kotlin-test-js.jar";
|
||||
public static final String KOTLIN_JAVA_RUNTIME_SRC_JAR = "kotlin-runtime-sources.jar";
|
||||
public static final String KOTLIN_COMPILER_JAR = "kotlin-compiler.jar";
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@ public class LibrarySourcesConfig extends JsConfig {
|
||||
public static final List<String> JS_STDLIB =
|
||||
Collections.singletonList(getKotlinPathsForDistDirectory().getJsStdLibJarPath().getAbsolutePath());
|
||||
|
||||
public static final List<String> JS_KOTLIN_TEST =
|
||||
Collections.singletonList(getKotlinPathsForDistDirectory().getJsKotlinTestJarPath().getAbsolutePath());
|
||||
|
||||
public static final Key<String> EXTERNAL_MODULE_NAME = Key.create("externalModule");
|
||||
public static final String UNKNOWN_EXTERNAL_MODULE_NAME = "<unknown>";
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package org.junit
|
||||
|
||||
public annotation class Test(val name: String = "")
|
||||
@@ -256,7 +256,7 @@ abstract class BasicBoxTest(
|
||||
|
||||
configuration.put(CommonConfigurationKeys.DISABLE_INLINE, module.inliningDisabled)
|
||||
|
||||
configuration.put(JSConfigurationKeys.LIBRARY_FILES, LibrarySourcesConfig.JS_STDLIB + dependencies)
|
||||
configuration.put(JSConfigurationKeys.LIBRARY_FILES, LibrarySourcesConfig.JS_STDLIB + LibrarySourcesConfig.JS_KOTLIN_TEST + dependencies)
|
||||
|
||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, module.name.removeSuffix(OLD_MODULE_SUFFIX))
|
||||
configuration.put(JSConfigurationKeys.MODULE_KIND, module.moduleKind)
|
||||
|
||||
@@ -65,6 +65,7 @@ import java.util.Map;
|
||||
import static org.jetbrains.kotlin.js.test.rhino.RhinoUtils.runRhinoTest;
|
||||
import static org.jetbrains.kotlin.js.test.utils.JsTestUtils.convertFileNameToDotJsFile;
|
||||
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isDirectiveDefined;
|
||||
import static org.jetbrains.kotlin.utils.PathUtil.getKotlinPathsForDistDirectory;
|
||||
|
||||
public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||
// predictable order of ecma version in tests
|
||||
@@ -319,6 +320,8 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||
if (libraries != null) {
|
||||
librariesWithStdlib.addAll(libraries);
|
||||
}
|
||||
librariesWithStdlib.add(getKotlinPathsForDistDirectory().getJsKotlinTestJarPath().getAbsolutePath());
|
||||
|
||||
configuration.put(JSConfigurationKeys.LIBRARY_FILES, librariesWithStdlib);
|
||||
|
||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, moduleName);
|
||||
|
||||
@@ -153,6 +153,8 @@ public final class RhinoUtils {
|
||||
// System.out.print(problems);
|
||||
//}
|
||||
}
|
||||
|
||||
finishScope(scope);
|
||||
checker.runChecks(context, scope);
|
||||
}
|
||||
finally {
|
||||
@@ -162,7 +164,16 @@ public final class RhinoUtils {
|
||||
|
||||
@NotNull
|
||||
private static Scriptable getScope(@NotNull EcmaVersion version, @NotNull Context context, @NotNull List<String> jsLibraries) {
|
||||
return context.newObject(getParentScope(version, context, jsLibraries));
|
||||
Scriptable parentScope = getParentScope(version, context, jsLibraries);
|
||||
Scriptable scope = context.newObject(parentScope);
|
||||
|
||||
scope.put("kotlin-test", scope, parentScope.get("kotlin-test", parentScope));
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
||||
private static void finishScope(@NotNull Scriptable scope) {
|
||||
scope.delete("kotlin-test");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -180,6 +191,8 @@ public final class RhinoUtils {
|
||||
ScriptableObject scope = context.initStandardObjects();
|
||||
try {
|
||||
runFileWithRhino(DIST_DIR_JS_PATH + "kotlin.js", context, scope);
|
||||
runFileWithRhino(DIST_DIR_JS_PATH + "../classes/kotlin-test-js/kotlin-test.js", context, scope);
|
||||
|
||||
//runFileWithRhino(pathToTestFilesRoot() + "jshint.js", context, scope);
|
||||
for (String jsLibrary : jsLibraries) {
|
||||
runFileWithRhino(jsLibrary, context, scope);
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package kotlin.test
|
||||
|
||||
val init = run {
|
||||
asserter = JsTestsAsserter()
|
||||
_asserter = JsTestsAsserter()
|
||||
}
|
||||
|
||||
public class JsTestsAsserter() : Asserter {
|
||||
|
||||
@@ -11,78 +11,84 @@
|
||||
|
||||
<artifactId>kotlin-test-js</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>unpack-dependencies</goal>
|
||||
</goals>
|
||||
<phase>generate-test-resources</phase>
|
||||
<configuration>
|
||||
<includeScope>test</includeScope>
|
||||
<includeTypes>jar</includeTypes>
|
||||
<outputDirectory>${project.basedir}/target/test-js</outputDirectory>
|
||||
<includes>*.js</includes>
|
||||
<excludes>*.meta.js</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install node and npm</id>
|
||||
<!--<phase>generate-test-resources</phase>-->
|
||||
<phase>none</phase>
|
||||
<goals>
|
||||
<goal>install-node-and-npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>npm install</id>
|
||||
<!--<phase>generate-test-resources</phase>-->
|
||||
<phase>none</phase>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<!-- Optional configuration which provides for running any npm command -->
|
||||
<configuration>
|
||||
<arguments>install</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>javascript tests</id>
|
||||
<goals>
|
||||
<goal>karma</goal>
|
||||
</goals>
|
||||
<!-- disable js tests -->
|
||||
<phase>none</phase>
|
||||
<configuration>
|
||||
<karmaConfPath>${project.basedir}/src/test/karma/karma.conf.js</karmaConfPath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
|
||||
<configuration>
|
||||
<nodeVersion>v0.12.7</nodeVersion>
|
||||
<npmVersion>2.14.4</npmVersion>
|
||||
<args>
|
||||
<!--<arg>-Xallow-kotlin-package</arg>-->
|
||||
<arg>-Xmulti-platform</arg>
|
||||
</args>
|
||||
<moduleKind>umd</moduleKind>
|
||||
<kjsm>true</kjsm>
|
||||
<metaInfo>true</metaInfo>
|
||||
</configuration>
|
||||
|
||||
<workingDirectory>${project.basedir}/src/test/karma</workingDirectory>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
<!--<execution>-->
|
||||
<!--<id>test-compile</id>-->
|
||||
<!--<phase>test-compile</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>test-compile</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--<configuration>-->
|
||||
<!--<sourceDirs>-->
|
||||
<!--<dir>${project.basedir}/src/test/kotlin</dir>-->
|
||||
<!--<dir>${project.basedir}/src/test/kotlin.jvm</dir>-->
|
||||
<!--</sourceDirs>-->
|
||||
<!--</configuration>-->
|
||||
<!--</execution>-->
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<forceCreation>true</forceCreation>
|
||||
<classesDirectory>${project.build.directory}/js</classesDirectory>
|
||||
<includes>
|
||||
<include>**/*.js</include>
|
||||
<include>**/*.js.map</include>
|
||||
<include>**/*.kjsm</include>
|
||||
<include>**/*.kotlin_classes</include>
|
||||
<include>**/*.kotlin_string_table</include>
|
||||
<include>**/*.kotlin_file_table</include>
|
||||
</includes>
|
||||
<archive>
|
||||
<forced />
|
||||
<manifestEntries>
|
||||
<Built-By>${user.name}</Built-By>
|
||||
|
||||
<Implementation-Vendor>JetBrains s.r.o.</Implementation-Vendor>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package kotlin.test
|
||||
|
||||
impl fun AssertionError(message: String): Throwable = kotlin.AssertionError(message)
|
||||
impl fun AssertionError(): Throwable = kotlin.AssertionError()
|
||||
+12
-9
@@ -20,7 +20,7 @@ package kotlin.test
|
||||
* Comments out a block of test code until it is implemented while keeping a link to the code
|
||||
* to implement in your unit test output
|
||||
*/
|
||||
public fun todo(block: () -> Any) {
|
||||
fun todo(block: () -> Any) {
|
||||
// println("TODO at " + (Exception() as java.lang.Throwable).getStackTrace()?.get(1) + " for " + block)
|
||||
println("TODO at " + block)
|
||||
}
|
||||
@@ -28,30 +28,33 @@ public fun todo(block: () -> Any) {
|
||||
/** Asserts that a [block] fails with a specific exception of type [T] being thrown.
|
||||
* Since inline method doesn't allow to trace where it was invoked, it is required to pass a [message] to distinguish this method call from others.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
inline fun <reified T : Throwable> assertFailsWith(message: String? = null, noinline block: () -> Unit): T {
|
||||
val exception = assertFails(message, block)
|
||||
assertTrue(exception is T, (message?.let { "$it. " } ?: "") + "An exception thrown is not of the expected type: $exception")
|
||||
val messagePrefix = if (message == null) "" else "$message. "
|
||||
|
||||
assertTrue(exception is T, "${messagePrefix}An exception thrown is not of the expected type: $exception")
|
||||
return exception as T
|
||||
}
|
||||
|
||||
var _asserter: Asserter = QUnitAsserter()
|
||||
|
||||
/**
|
||||
* Provides the JS implementation of asserter using [QUnit](http://QUnitjs.com/)
|
||||
*/
|
||||
public var asserter: Asserter = QUnitAsserter()
|
||||
internal impl fun lookupAsserter(): Asserter = _asserter
|
||||
|
||||
public class QUnitAsserter() : Asserter {
|
||||
class QUnitAsserter : Asserter {
|
||||
|
||||
public override fun assertTrue(lazyMessage: () -> String?, actual: Boolean) {
|
||||
override fun assertTrue(lazyMessage: () -> String?, actual: Boolean) {
|
||||
assertTrue(actual, lazyMessage())
|
||||
}
|
||||
|
||||
public override fun assertTrue(message: String?, actual: Boolean) {
|
||||
override fun assertTrue(message: String?, actual: Boolean) {
|
||||
QUnit.ok(actual, message)
|
||||
if (!actual) failWithMessage(message)
|
||||
}
|
||||
|
||||
public override fun fail(message: String?): Nothing {
|
||||
override fun fail(message: String?): Nothing {
|
||||
QUnit.ok(false, message)
|
||||
failWithMessage(message)
|
||||
}
|
||||
@@ -62,4 +65,4 @@ public class QUnitAsserter() : Asserter {
|
||||
else
|
||||
throw AssertionError(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package QUnit
|
||||
|
||||
/**
|
||||
* The [QUnit](http://qunitjs.com/) API
|
||||
*/
|
||||
|
||||
external fun ok(actual: Boolean, message: String?): Unit = noImpl
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package kotlin.internal
|
||||
|
||||
|
||||
/**
|
||||
* The value of this type parameter should be mentioned in input types (argument types, receiver type or expected type).
|
||||
// */
|
||||
//@Target(AnnotationTarget.TYPE_PARAMETER)
|
||||
//@Retention(AnnotationRetention.BINARY)
|
||||
//internal impl annotation class OnlyInputTypes
|
||||
|
||||
/**
|
||||
* Specifies that this function should not be called directly without inlining
|
||||
*/
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal impl annotation class InlineOnly
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.junit
|
||||
|
||||
@Suppress("IMPLEMENTATION_WITHOUT_HEADER")
|
||||
impl annotation class Test(val name: String = "")
|
||||
@@ -18,15 +18,9 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<!--suppress KotlinTestJUnit -->
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -86,12 +80,6 @@
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/main/kotlin</dir>
|
||||
<dir>${project.basedir}/src/main/kotlin.jvm</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
@@ -100,12 +88,6 @@
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/test/kotlin</dir>
|
||||
<dir>${project.basedir}/src/test/kotlin.jvm</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>kotlin-test-parent</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-runtime</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xallow-kotlin-package</arg>
|
||||
<arg>-Xmulti-platform</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
<!--<execution>-->
|
||||
<!--<id>test-compile</id>-->
|
||||
<!--<phase>test-compile</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>test-compile</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--<configuration>-->
|
||||
<!--<sourceDirs>-->
|
||||
<!--<dir>${project.basedir}/src/test/kotlin</dir>-->
|
||||
<!--<dir>${project.basedir}/src/test/kotlin.jvm</dir>-->
|
||||
<!--</sourceDirs>-->
|
||||
<!--</configuration>-->
|
||||
<!--</execution>-->
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
+2
@@ -8,6 +8,8 @@ private val inited = AtomicBoolean()
|
||||
private val lock = ReentrantLock()
|
||||
private val contributors = ArrayList<AsserterContributor>()
|
||||
|
||||
internal impl fun lookupAsserter(): Asserter = lookup()
|
||||
|
||||
internal fun lookup(): Asserter {
|
||||
initContributorsIfNeeded()
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.test
|
||||
|
||||
impl fun AssertionError(message: String): Throwable = java.lang.AssertionError(message)
|
||||
impl fun AssertionError(): Throwable = java.lang.AssertionError()
|
||||
|
||||
+26
-12
@@ -1,7 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("AssertionsKt")
|
||||
package kotlin.test
|
||||
|
||||
import kotlin.internal.*
|
||||
import kotlin.reflect.*
|
||||
|
||||
/** Asserts that a [block] fails with a specific exception being thrown. */
|
||||
@@ -13,9 +30,13 @@ private fun <T : Throwable> assertFailsWithImpl(exceptionClass: Class<T>, messag
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return e as T
|
||||
}
|
||||
asserter.fail((message?.let { "$it. " } ?: "") + "Expected an exception of type $exceptionClass to be thrown, but was $e")
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER")
|
||||
asserter.fail(messagePrefix(message) + "Expected an exception of type $exceptionClass to be thrown, but was $e")
|
||||
}
|
||||
val msg = message?.let { "$it. " } ?: ""
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER")
|
||||
val msg = messagePrefix(message)
|
||||
asserter.fail(msg + "Expected an exception of type $exceptionClass to be thrown, but was completed successfully.")
|
||||
}
|
||||
|
||||
@@ -28,7 +49,7 @@ fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?,
|
||||
/** Asserts that a [block] fails with a specific exception of type [T] being thrown.
|
||||
* Since inline method doesn't allow to trace where it was invoked, it is required to pass a [message] to distinguish this method call from others.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
@InlineOnly
|
||||
inline fun <reified T : Throwable> assertFailsWith(message: String? = null, noinline block: () -> Unit): T = assertFailsWith(T::class, message, block)
|
||||
|
||||
|
||||
@@ -36,7 +57,7 @@ inline fun <reified T : Throwable> assertFailsWith(message: String? = null, noin
|
||||
* Comments out a [block] of test code until it is implemented while keeping a link to the code
|
||||
* to implement in your unit test output
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
@InlineOnly
|
||||
inline fun todo(@Suppress("UNUSED_PARAMETER") block: () -> Unit) {
|
||||
System.out.println("TODO at " + currentStackTrace()[0])
|
||||
}
|
||||
@@ -47,13 +68,6 @@ inline fun todo(@Suppress("UNUSED_PARAMETER") block: () -> Unit) {
|
||||
* stack, which is the place where [currentStackTrace] function was called from.
|
||||
*/
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
@kotlin.internal.InlineOnly
|
||||
@InlineOnly
|
||||
inline fun currentStackTrace() = (java.lang.Exception() as java.lang.Throwable).stackTrace
|
||||
|
||||
/**
|
||||
* The active implementation of [Asserter]. An implementation of [Asserter] can be provided
|
||||
* using the [Java service loader](http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html) mechanism.
|
||||
*/
|
||||
val asserter: Asserter
|
||||
get() = lookup()
|
||||
|
||||
+16
-1
@@ -1,5 +1,20 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("DEPRECATION")
|
||||
package kotlin.test
|
||||
|
||||
import java.util.*
|
||||
@@ -0,0 +1,16 @@
|
||||
package kotlin.internal
|
||||
|
||||
|
||||
/**
|
||||
* The value of this type parameter should be mentioned in input types (argument types, receiver type or expected type).
|
||||
*/
|
||||
@Target(AnnotationTarget.TYPE_PARAMETER)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class OnlyInputTypes
|
||||
|
||||
/**
|
||||
* Specifies that this function should not be called directly without inlining
|
||||
*/
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class InlineOnly
|
||||
@@ -14,7 +14,8 @@
|
||||
<modules>
|
||||
<module>shared</module>
|
||||
<module>junit</module>
|
||||
<!--<module>js</module>--> <!-- TODO enable back when js build fixed -->
|
||||
<module>jvm</module>
|
||||
<module>js</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,13 +7,42 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<artifactId>kotlin-test-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.jetbrains.kotlin</groupId>-->
|
||||
<!--<artifactId>kotlin-stdlib-common</artifactId>-->
|
||||
<!--<version>${project.version}</version>-->
|
||||
<!--</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xallow-kotlin-package</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<goals>
|
||||
<goal>metadata</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
@@ -30,147 +59,88 @@
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>kotlin/internal/OnlyInputTypes*</exclude>
|
||||
<exclude>kotlin/internal/InlineOnly*</exclude>
|
||||
<exclude>kotlin/internal</exclude>
|
||||
</excludes>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>kotlin-js</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<!--<profile>-->
|
||||
<!--<id>kotlin-jvm</id>-->
|
||||
<!--<activation>-->
|
||||
<!--<activeByDefault>false</activeByDefault>-->
|
||||
<!--</activation>-->
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-js-library
|
||||
</artifactId> <!-- TODO including this causes compilation to fail due to resolution ambiguity -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!--<dependencies>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>org.jetbrains.kotlin</groupId>-->
|
||||
<!--<artifactId>kotlin-runtime</artifactId>-->
|
||||
<!--</dependency>-->
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>junit</groupId>-->
|
||||
<!--<artifactId>junit</artifactId>-->
|
||||
<!--<scope>test</scope>-->
|
||||
<!--</dependency>-->
|
||||
<!--</dependencies>-->
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<!--<build>-->
|
||||
<!--<plugins>-->
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>org.jetbrains.kotlin</groupId>-->
|
||||
<!--<artifactId>kotlin-maven-plugin</artifactId>-->
|
||||
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xallow-kotlin-package</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
<!--<configuration>-->
|
||||
<!--<args>-->
|
||||
<!--<arg>-Xallow-kotlin-package</arg>-->
|
||||
<!--</args>-->
|
||||
<!--</configuration>-->
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test-compile-js</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-js</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/test/kotlin</dir>
|
||||
<dir>${project.basedir}/src/test/kotlin.js</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--<executions>-->
|
||||
<!--<execution>-->
|
||||
<!--<id>compile</id>-->
|
||||
<!--<phase>compile</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>compile</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--<configuration>-->
|
||||
<!--<sourceDirs>-->
|
||||
<!--<dir>${project.basedir}/src/main/kotlin</dir>-->
|
||||
<!--<dir>${project.basedir}/src/main/kotlin.jvm</dir>-->
|
||||
<!--</sourceDirs>-->
|
||||
<!--</configuration>-->
|
||||
<!--</execution>-->
|
||||
|
||||
<execution>
|
||||
<id>js-compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>js</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputFile>${project.build.outputDirectory}/${project.artifactId}.js</outputFile>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/main/kotlin</dir>
|
||||
<dir>${project.basedir}/src/main/kotlin.js</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>kotlin-jvm</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-runtime</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
|
||||
<configuration>
|
||||
<args>
|
||||
<arg>-Xallow-kotlin-package</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/main/kotlin</dir>
|
||||
<dir>${project.basedir}/src/main/kotlin.jvm</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<dir>${project.basedir}/src/test/kotlin</dir>
|
||||
<dir>${project.basedir}/src/test/kotlin.jvm</dir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>kotlin/internal/OnlyInputTypes*</exclude>
|
||||
<exclude>kotlin/internal/InlineOnly*</exclude>
|
||||
<exclude>kotlin/internal</exclude>
|
||||
</excludes>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<!--<execution>-->
|
||||
<!--<id>test-compile</id>-->
|
||||
<!--<phase>test-compile</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>test-compile</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--<configuration>-->
|
||||
<!--<sourceDirs>-->
|
||||
<!--<dir>${project.basedir}/src/test/kotlin</dir>-->
|
||||
<!--<dir>${project.basedir}/src/test/kotlin.jvm</dir>-->
|
||||
<!--</sourceDirs>-->
|
||||
<!--</configuration>-->
|
||||
<!--</execution>-->
|
||||
<!--</executions>-->
|
||||
<!--</plugin>-->
|
||||
<!--</plugins>-->
|
||||
<!--</build>-->
|
||||
<!--</profile>-->
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package kotlin.jvm
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the name for the Java class or method
|
||||
* which is generated from this element.
|
||||
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/java-interop.html#handling-signature-clashes-with-platformname)
|
||||
* for more information.
|
||||
* @property name the name of the element.
|
||||
*/
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.FILE)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@MustBeDocumented
|
||||
internal annotation class JvmName(public val name: String)
|
||||
|
||||
/**
|
||||
* Instructs the Kotlin compiler to generate a multifile class with top-level functions and properties declared in this file as one of its parts.
|
||||
* Name of the corresponding multifile class is provided by the [JvmName] annotation.
|
||||
*/
|
||||
@Target(AnnotationTarget.FILE)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@MustBeDocumented
|
||||
internal annotation class JvmMultifileClass
|
||||
|
||||
|
||||
@@ -4,13 +4,15 @@ package kotlin.internal
|
||||
/**
|
||||
* The value of this type parameter should be mentioned in input types (argument types, receiver type or expected type).
|
||||
*/
|
||||
@Suppress("HEADER_WITHOUT_IMPLEMENTATION")
|
||||
@Target(AnnotationTarget.TYPE_PARAMETER)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class OnlyInputTypes
|
||||
internal header annotation class OnlyInputTypes
|
||||
|
||||
/**
|
||||
* Specifies that this function should not be called directly without inlining
|
||||
*/
|
||||
@Suppress("HEADER_WITHOUT_IMPLEMENTATION")
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
internal annotation class InlineOnly
|
||||
internal header annotation class InlineOnly
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package kotlin.jvm
|
||||
|
||||
@Suppress("HEADER_WITHOUT_IMPLEMENTATION")
|
||||
@Target(AnnotationTarget.FILE)
|
||||
internal header annotation class JvmMultifileClass
|
||||
|
||||
@Suppress("HEADER_WITHOUT_IMPLEMENTATION")
|
||||
@Target(AnnotationTarget.FILE)
|
||||
internal header annotation class JvmName(val name: String)
|
||||
+12
-9
@@ -14,16 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("AssertionsKt")
|
||||
|
||||
/**
|
||||
* A number of helper methods for writing unit tests.
|
||||
*/
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("AssertionsKt")
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
package kotlin.test
|
||||
|
||||
import kotlin.internal.*
|
||||
|
||||
val asserter: Asserter
|
||||
get() = lookupAsserter()
|
||||
|
||||
/** Asserts that the given [block] returns `true`. */
|
||||
fun assertTrue(message: String? = null, block: () -> Boolean): Unit = assertTrue(block(), message)
|
||||
|
||||
@@ -95,8 +99,7 @@ fun assertFails(message: String?, block: () -> Unit): Throwable {
|
||||
} catch (e: Throwable) {
|
||||
return e
|
||||
}
|
||||
val msg = message?.let { "$it. " } ?: ""
|
||||
asserter.fail(msg + "Expected an exception to be thrown, but was completed successfully.")
|
||||
asserter.fail(messagePrefix(message) + "Expected an exception to be thrown, but was completed successfully.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +140,7 @@ interface Asserter {
|
||||
* @param message the message to report if the assertion fails.
|
||||
*/
|
||||
fun assertEquals(message: String?, expected: Any?, actual: Any?): Unit {
|
||||
assertTrue({ (message?.let { "$it. " } ?: "") + "Expected <$expected>, actual <$actual>." }, actual == expected)
|
||||
assertTrue({ messagePrefix(message) + "Expected <$expected>, actual <$actual>." }, actual == expected)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +149,7 @@ interface Asserter {
|
||||
* @param message the message to report if the assertion fails.
|
||||
*/
|
||||
fun assertNotEquals(message: String?, illegal: Any?, actual: Any?): Unit {
|
||||
assertTrue({ (message?.let { "$it. " } ?: "") + "Illegal value: <$actual>." }, actual != illegal)
|
||||
assertTrue({ messagePrefix(message) + "Illegal value: <$actual>." }, actual != illegal)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +158,7 @@ interface Asserter {
|
||||
* @param message the message to report if the assertion fails.
|
||||
*/
|
||||
fun assertNull(message: String?, actual: Any?): Unit {
|
||||
assertTrue({ (message?.let { "$it. " } ?: "") + "Expected value to be null, but was: <$actual>." }, actual == null)
|
||||
assertTrue({ messagePrefix(message) + "Expected value to be null, but was: <$actual>." }, actual == null)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +167,7 @@ interface Asserter {
|
||||
* @param message the message to report if the assertion fails.
|
||||
*/
|
||||
fun assertNotNull(message: String?, actual: Any?): Unit {
|
||||
assertTrue({ (message?.let { "$it. " } ?: "") + "Expected value to be not null." }, actual != null)
|
||||
assertTrue({ messagePrefix(message) + "Expected value to be not null." }, actual != null)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,4 +11,7 @@ class DefaultAsserter() : Asserter {
|
||||
else
|
||||
throw AssertionError(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
header fun AssertionError(message: String): Throwable
|
||||
header fun AssertionError(): Throwable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package kotlin.test
|
||||
|
||||
internal fun <T, R> T.let(block: (T) -> R): R = block(this)
|
||||
|
||||
internal fun messagePrefix(message: String?) = if (message == null) "" else "$message. "
|
||||
internal header fun lookupAsserter(): Asserter
|
||||
@@ -0,0 +1,4 @@
|
||||
package org.junit
|
||||
|
||||
@Suppress("HEADER_WITHOUT_IMPLEMENTATION")
|
||||
header annotation class Test
|
||||
@@ -21,6 +21,11 @@
|
||||
<artifactId>kotlin-js-library</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
@@ -109,6 +114,13 @@
|
||||
<outputDirectory>${project.build.directory}/js/lib</outputDirectory>
|
||||
<includes>*.js</includes>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-js</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<outputDirectory>${project.build.directory}/js/lib</outputDirectory>
|
||||
<includes>*.js</includes>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<script src="qunit.js"></script>
|
||||
|
||||
<script src="../../../target/js/lib/kotlin.js"></script>
|
||||
<script src="../../../target/js/lib/kotlin-test-js.js"</script>
|
||||
<script src="../../../target/js/kotlin-js-tests.js"></script>
|
||||
|
||||
<script src="deepEqual.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user