kotlin-test: extract from JS library, convert to multiplatform
This commit is contained in:
@@ -488,7 +488,7 @@
|
|||||||
</jar>
|
</jar>
|
||||||
</target>
|
</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">
|
<target name="preloader">
|
||||||
<cleandir dir="${output}/classes/preloader"/>
|
<cleandir dir="${output}/classes/preloader"/>
|
||||||
@@ -1061,18 +1061,34 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="kotlin-test">
|
<target name="kotlin-test">
|
||||||
<new-kotlinc output="${output}/classes/kotlin-test" moduleName="kotlin-test">
|
<path id="kotlin-test-compile-classpath">
|
||||||
<src>
|
<pathelement location="${output}/classes/builtins"/>
|
||||||
<include name="libraries/kotlin.test/shared/src/main/kotlin" />
|
<pathelement location="${output}/builtins"/>
|
||||||
<include name="libraries/kotlin.test/shared/src/main/kotlin.jvm" />
|
</path>
|
||||||
<include name="libraries/kotlin.test/junit/src/main/kotlin" />
|
|
||||||
</src>
|
<java classname="org.jetbrains.kotlin.preloading.Preloader" failonerror="true" fork="true" maxmemory="${max.heap.size.for.forked.jvm}">
|
||||||
<class-path>
|
<classpath>
|
||||||
<pathelement path="${output}/classes/builtins"/>
|
<pathelement location="${kotlin-home}/lib/kotlin-preloader.jar"/>
|
||||||
<pathelement path="libraries/lib/junit-4.11.jar"/>
|
</classpath>
|
||||||
<pathelement path="${output}/builtins"/>
|
<assertions>
|
||||||
</class-path>
|
<enable/>
|
||||||
</new-kotlinc>
|
</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">
|
<pack-runtime-jar jar-name="kotlin-test.jar" implementation-title="${manifest.impl.title.kotlin.test}" runtime-component="Test">
|
||||||
<jar-content>
|
<jar-content>
|
||||||
@@ -1080,6 +1096,35 @@
|
|||||||
</jar-content>
|
</jar-content>
|
||||||
</pack-runtime-jar>
|
</pack-runtime-jar>
|
||||||
</target>
|
</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">
|
<target name="core">
|
||||||
<new-kotlinc output="${output}/classes/core" moduleName="kotlin-core">
|
<new-kotlinc output="${output}/classes/core" moduleName="kotlin-core">
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ public interface KotlinPaths {
|
|||||||
@NotNull
|
@NotNull
|
||||||
File getJsStdLibSrcJarPath();
|
File getJsStdLibSrcJarPath();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
File getJsKotlinTestJarPath();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
File getAllOpenPluginJarPath();
|
File getAllOpenPluginJarPath();
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,12 @@ public class KotlinPathsFromHomeDir implements KotlinPaths {
|
|||||||
return getLibraryFile(PathUtil.JS_LIB_SRC_JAR_NAME);
|
return getLibraryFile(PathUtil.JS_LIB_SRC_JAR_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public File getJsKotlinTestJarPath() {
|
||||||
|
return getLibraryFile(PathUtil.KOTLIN_TEST_JS_JAR);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public File getAllOpenPluginJarPath() {
|
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_REFLECT_JAR = "kotlin-reflect.jar";
|
||||||
public static final String KOTLIN_JAVA_SCRIPT_RUNTIME_JAR = "kotlin-script-runtime.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_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_JAVA_RUNTIME_SRC_JAR = "kotlin-runtime-sources.jar";
|
||||||
public static final String KOTLIN_COMPILER_JAR = "kotlin-compiler.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 =
|
public static final List<String> JS_STDLIB =
|
||||||
Collections.singletonList(getKotlinPathsForDistDirectory().getJsStdLibJarPath().getAbsolutePath());
|
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 Key<String> EXTERNAL_MODULE_NAME = Key.create("externalModule");
|
||||||
public static final String UNKNOWN_EXTERNAL_MODULE_NAME = "<unknown>";
|
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(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(CommonConfigurationKeys.MODULE_NAME, module.name.removeSuffix(OLD_MODULE_SUFFIX))
|
||||||
configuration.put(JSConfigurationKeys.MODULE_KIND, module.moduleKind)
|
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.rhino.RhinoUtils.runRhinoTest;
|
||||||
import static org.jetbrains.kotlin.js.test.utils.JsTestUtils.convertFileNameToDotJsFile;
|
import static org.jetbrains.kotlin.js.test.utils.JsTestUtils.convertFileNameToDotJsFile;
|
||||||
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isDirectiveDefined;
|
import static org.jetbrains.kotlin.test.InTextDirectivesUtils.isDirectiveDefined;
|
||||||
|
import static org.jetbrains.kotlin.utils.PathUtil.getKotlinPathsForDistDirectory;
|
||||||
|
|
||||||
public abstract class BasicTest extends KotlinTestWithEnvironment {
|
public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||||
// predictable order of ecma version in tests
|
// predictable order of ecma version in tests
|
||||||
@@ -319,6 +320,8 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
if (libraries != null) {
|
if (libraries != null) {
|
||||||
librariesWithStdlib.addAll(libraries);
|
librariesWithStdlib.addAll(libraries);
|
||||||
}
|
}
|
||||||
|
librariesWithStdlib.add(getKotlinPathsForDistDirectory().getJsKotlinTestJarPath().getAbsolutePath());
|
||||||
|
|
||||||
configuration.put(JSConfigurationKeys.LIBRARY_FILES, librariesWithStdlib);
|
configuration.put(JSConfigurationKeys.LIBRARY_FILES, librariesWithStdlib);
|
||||||
|
|
||||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, moduleName);
|
configuration.put(CommonConfigurationKeys.MODULE_NAME, moduleName);
|
||||||
|
|||||||
@@ -153,6 +153,8 @@ public final class RhinoUtils {
|
|||||||
// System.out.print(problems);
|
// System.out.print(problems);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finishScope(scope);
|
||||||
checker.runChecks(context, scope);
|
checker.runChecks(context, scope);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -162,7 +164,16 @@ public final class RhinoUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static Scriptable getScope(@NotNull EcmaVersion version, @NotNull Context context, @NotNull List<String> jsLibraries) {
|
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
|
@NotNull
|
||||||
@@ -180,6 +191,8 @@ public final class RhinoUtils {
|
|||||||
ScriptableObject scope = context.initStandardObjects();
|
ScriptableObject scope = context.initStandardObjects();
|
||||||
try {
|
try {
|
||||||
runFileWithRhino(DIST_DIR_JS_PATH + "kotlin.js", context, scope);
|
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);
|
//runFileWithRhino(pathToTestFilesRoot() + "jshint.js", context, scope);
|
||||||
for (String jsLibrary : jsLibraries) {
|
for (String jsLibrary : jsLibraries) {
|
||||||
runFileWithRhino(jsLibrary, context, scope);
|
runFileWithRhino(jsLibrary, context, scope);
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package kotlin.test
|
package kotlin.test
|
||||||
|
|
||||||
val init = run {
|
val init = run {
|
||||||
asserter = JsTestsAsserter()
|
_asserter = JsTestsAsserter()
|
||||||
}
|
}
|
||||||
|
|
||||||
public class JsTestsAsserter() : Asserter {
|
public class JsTestsAsserter() : Asserter {
|
||||||
|
|||||||
@@ -11,78 +11,84 @@
|
|||||||
|
|
||||||
<artifactId>kotlin-test-js</artifactId>
|
<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>
|
<build>
|
||||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<version>2.10</version>
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
<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>
|
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<nodeVersion>v0.12.7</nodeVersion>
|
<args>
|
||||||
<npmVersion>2.14.4</npmVersion>
|
<!--<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>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</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
|
* 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
|
* 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 " + (Exception() as java.lang.Throwable).getStackTrace()?.get(1) + " for " + block)
|
||||||
println("TODO at " + 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.
|
/** 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.
|
* 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 {
|
inline fun <reified T : Throwable> assertFailsWith(message: String? = null, noinline block: () -> Unit): T {
|
||||||
val exception = assertFails(message, block)
|
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
|
return exception as T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _asserter: Asserter = QUnitAsserter()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the JS implementation of asserter using [QUnit](http://QUnitjs.com/)
|
* 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())
|
assertTrue(actual, lazyMessage())
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun assertTrue(message: String?, actual: Boolean) {
|
override fun assertTrue(message: String?, actual: Boolean) {
|
||||||
QUnit.ok(actual, message)
|
QUnit.ok(actual, message)
|
||||||
if (!actual) failWithMessage(message)
|
if (!actual) failWithMessage(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun fail(message: String?): Nothing {
|
override fun fail(message: String?): Nothing {
|
||||||
QUnit.ok(false, message)
|
QUnit.ok(false, message)
|
||||||
failWithMessage(message)
|
failWithMessage(message)
|
||||||
}
|
}
|
||||||
@@ -62,4 +65,4 @@ public class QUnitAsserter() : Asserter {
|
|||||||
else
|
else
|
||||||
throw AssertionError(message)
|
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>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<!--suppress KotlinTestJUnit -->
|
||||||
<artifactId>kotlin-test</artifactId>
|
<artifactId>kotlin-test</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
|
||||||
<artifactId>kotlin-js-library</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@@ -86,12 +80,6 @@
|
|||||||
<goals>
|
<goals>
|
||||||
<goal>compile</goal>
|
<goal>compile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
|
||||||
<sourceDirs>
|
|
||||||
<dir>${project.basedir}/src/main/kotlin</dir>
|
|
||||||
<dir>${project.basedir}/src/main/kotlin.jvm</dir>
|
|
||||||
</sourceDirs>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
</execution>
|
||||||
|
|
||||||
<execution>
|
<execution>
|
||||||
@@ -100,12 +88,6 @@
|
|||||||
<goals>
|
<goals>
|
||||||
<goal>test-compile</goal>
|
<goal>test-compile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
|
||||||
<sourceDirs>
|
|
||||||
<dir>${project.basedir}/src/test/kotlin</dir>
|
|
||||||
<dir>${project.basedir}/src/test/kotlin.jvm</dir>
|
|
||||||
</sourceDirs>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</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 lock = ReentrantLock()
|
||||||
private val contributors = ArrayList<AsserterContributor>()
|
private val contributors = ArrayList<AsserterContributor>()
|
||||||
|
|
||||||
|
internal impl fun lookupAsserter(): Asserter = lookup()
|
||||||
|
|
||||||
internal fun lookup(): Asserter {
|
internal fun lookup(): Asserter {
|
||||||
initContributorsIfNeeded()
|
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.JvmMultifileClass
|
||||||
@file:kotlin.jvm.JvmName("AssertionsKt")
|
@file:kotlin.jvm.JvmName("AssertionsKt")
|
||||||
package kotlin.test
|
package kotlin.test
|
||||||
|
|
||||||
|
import kotlin.internal.*
|
||||||
import kotlin.reflect.*
|
import kotlin.reflect.*
|
||||||
|
|
||||||
/** Asserts that a [block] fails with a specific exception being thrown. */
|
/** 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")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return e as T
|
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.")
|
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.
|
/** 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.
|
* 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)
|
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
|
* 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
|
* to implement in your unit test output
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@InlineOnly
|
||||||
inline fun todo(@Suppress("UNUSED_PARAMETER") block: () -> Unit) {
|
inline fun todo(@Suppress("UNUSED_PARAMETER") block: () -> Unit) {
|
||||||
System.out.println("TODO at " + currentStackTrace()[0])
|
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.
|
* stack, which is the place where [currentStackTrace] function was called from.
|
||||||
*/
|
*/
|
||||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||||
@kotlin.internal.InlineOnly
|
@InlineOnly
|
||||||
inline fun currentStackTrace() = (java.lang.Exception() as java.lang.Throwable).stackTrace
|
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
|
package kotlin.test
|
||||||
|
|
||||||
import java.util.*
|
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>
|
<modules>
|
||||||
<module>shared</module>
|
<module>shared</module>
|
||||||
<module>junit</module>
|
<module>junit</module>
|
||||||
<!--<module>js</module>--> <!-- TODO enable back when js build fixed -->
|
<module>jvm</module>
|
||||||
|
<module>js</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -7,13 +7,42 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<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>
|
<build>
|
||||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||||
|
|
||||||
<plugins>
|
<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>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
@@ -30,147 +59,88 @@
|
|||||||
</descriptors>
|
</descriptors>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
<profile>
|
<!--<profile>-->
|
||||||
<id>kotlin-js</id>
|
<!--<id>kotlin-jvm</id>-->
|
||||||
<activation>
|
<!--<activation>-->
|
||||||
<activeByDefault>false</activeByDefault>
|
<!--<activeByDefault>false</activeByDefault>-->
|
||||||
</activation>
|
<!--</activation>-->
|
||||||
|
|
||||||
<dependencies>
|
<!--<dependencies>-->
|
||||||
<dependency>
|
<!--<dependency>-->
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<!--<groupId>org.jetbrains.kotlin</groupId>-->
|
||||||
<artifactId>kotlin-js-library
|
<!--<artifactId>kotlin-runtime</artifactId>-->
|
||||||
</artifactId> <!-- TODO including this causes compilation to fail due to resolution ambiguity -->
|
<!--</dependency>-->
|
||||||
</dependency>
|
<!--<dependency>-->
|
||||||
</dependencies>
|
<!--<groupId>junit</groupId>-->
|
||||||
|
<!--<artifactId>junit</artifactId>-->
|
||||||
|
<!--<scope>test</scope>-->
|
||||||
|
<!--</dependency>-->
|
||||||
|
<!--</dependencies>-->
|
||||||
|
|
||||||
<build>
|
<!--<build>-->
|
||||||
<plugins>
|
<!--<plugins>-->
|
||||||
<plugin>
|
<!--<plugin>-->
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<!--<groupId>org.jetbrains.kotlin</groupId>-->
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
<!--<artifactId>kotlin-maven-plugin</artifactId>-->
|
||||||
|
|
||||||
<configuration>
|
<!--<configuration>-->
|
||||||
<args>
|
<!--<args>-->
|
||||||
<arg>-Xallow-kotlin-package</arg>
|
<!--<arg>-Xallow-kotlin-package</arg>-->
|
||||||
</args>
|
<!--</args>-->
|
||||||
</configuration>
|
<!--</configuration>-->
|
||||||
|
|
||||||
<executions>
|
<!--<executions>-->
|
||||||
<execution>
|
<!--<execution>-->
|
||||||
<id>test-compile-js</id>
|
<!--<id>compile</id>-->
|
||||||
<phase>test-compile</phase>
|
<!--<phase>compile</phase>-->
|
||||||
<goals>
|
<!--<goals>-->
|
||||||
<goal>test-js</goal>
|
<!--<goal>compile</goal>-->
|
||||||
</goals>
|
<!--</goals>-->
|
||||||
<configuration>
|
<!--<configuration>-->
|
||||||
<sourceDirs>
|
<!--<sourceDirs>-->
|
||||||
<dir>${project.basedir}/src/test/kotlin</dir>
|
<!--<dir>${project.basedir}/src/main/kotlin</dir>-->
|
||||||
<dir>${project.basedir}/src/test/kotlin.js</dir>
|
<!--<dir>${project.basedir}/src/main/kotlin.jvm</dir>-->
|
||||||
</sourceDirs>
|
<!--</sourceDirs>-->
|
||||||
</configuration>
|
<!--</configuration>-->
|
||||||
</execution>
|
<!--</execution>-->
|
||||||
|
|
||||||
<execution>
|
<!--<execution>-->
|
||||||
<id>js-compile</id>
|
<!--<id>test-compile</id>-->
|
||||||
<phase>compile</phase>
|
<!--<phase>test-compile</phase>-->
|
||||||
<goals>
|
<!--<goals>-->
|
||||||
<goal>js</goal>
|
<!--<goal>test-compile</goal>-->
|
||||||
</goals>
|
<!--</goals>-->
|
||||||
<configuration>
|
<!--<configuration>-->
|
||||||
<outputFile>${project.build.outputDirectory}/${project.artifactId}.js</outputFile>
|
<!--<sourceDirs>-->
|
||||||
<sourceDirs>
|
<!--<dir>${project.basedir}/src/test/kotlin</dir>-->
|
||||||
<dir>${project.basedir}/src/main/kotlin</dir>
|
<!--<dir>${project.basedir}/src/test/kotlin.jvm</dir>-->
|
||||||
<dir>${project.basedir}/src/main/kotlin.js</dir>
|
<!--</sourceDirs>-->
|
||||||
</sourceDirs>
|
<!--</configuration>-->
|
||||||
</configuration>
|
<!--</execution>-->
|
||||||
</execution>
|
<!--</executions>-->
|
||||||
</executions>
|
<!--</plugin>-->
|
||||||
</plugin>
|
<!--</plugins>-->
|
||||||
</plugins>
|
<!--</build>-->
|
||||||
</build>
|
<!--</profile>-->
|
||||||
</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>
|
|
||||||
</profiles>
|
</profiles>
|
||||||
</project>
|
</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).
|
* 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)
|
@Target(AnnotationTarget.TYPE_PARAMETER)
|
||||||
@Retention(AnnotationRetention.BINARY)
|
@Retention(AnnotationRetention.BINARY)
|
||||||
internal annotation class OnlyInputTypes
|
internal header annotation class OnlyInputTypes
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies that this function should not be called directly without inlining
|
* Specifies that this function should not be called directly without inlining
|
||||||
*/
|
*/
|
||||||
|
@Suppress("HEADER_WITHOUT_IMPLEMENTATION")
|
||||||
@Target(AnnotationTarget.FUNCTION)
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
@Retention(AnnotationRetention.BINARY)
|
@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.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@file:kotlin.jvm.JvmMultifileClass
|
|
||||||
@file:kotlin.jvm.JvmName("AssertionsKt")
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A number of helper methods for writing unit tests.
|
* 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
|
package kotlin.test
|
||||||
|
|
||||||
import kotlin.internal.*
|
import kotlin.internal.*
|
||||||
|
|
||||||
|
val asserter: Asserter
|
||||||
|
get() = lookupAsserter()
|
||||||
|
|
||||||
/** Asserts that the given [block] returns `true`. */
|
/** Asserts that the given [block] returns `true`. */
|
||||||
fun assertTrue(message: String? = null, block: () -> Boolean): Unit = assertTrue(block(), message)
|
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) {
|
} catch (e: Throwable) {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
val msg = message?.let { "$it. " } ?: ""
|
asserter.fail(messagePrefix(message) + "Expected an exception to be thrown, but was completed successfully.")
|
||||||
asserter.fail(msg + "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.
|
* @param message the message to report if the assertion fails.
|
||||||
*/
|
*/
|
||||||
fun assertEquals(message: String?, expected: Any?, actual: Any?): Unit {
|
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.
|
* @param message the message to report if the assertion fails.
|
||||||
*/
|
*/
|
||||||
fun assertNotEquals(message: String?, illegal: Any?, actual: Any?): Unit {
|
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.
|
* @param message the message to report if the assertion fails.
|
||||||
*/
|
*/
|
||||||
fun assertNull(message: String?, actual: Any?): Unit {
|
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.
|
* @param message the message to report if the assertion fails.
|
||||||
*/
|
*/
|
||||||
fun assertNotNull(message: String?, actual: Any?): Unit {
|
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
|
else
|
||||||
throw AssertionError(message)
|
throw AssertionError(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header fun AssertionError(message: String): Throwable
|
||||||
|
header fun AssertionError(): Throwable
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package kotlin.test
|
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>
|
<artifactId>kotlin-js-library</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-js</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -109,6 +114,13 @@
|
|||||||
<outputDirectory>${project.build.directory}/js/lib</outputDirectory>
|
<outputDirectory>${project.build.directory}/js/lib</outputDirectory>
|
||||||
<includes>*.js</includes>
|
<includes>*.js</includes>
|
||||||
</artifactItem>
|
</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>
|
</artifactItems>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<script src="qunit.js"></script>
|
<script src="qunit.js"></script>
|
||||||
|
|
||||||
<script src="../../../target/js/lib/kotlin.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="../../../target/js/kotlin-js-tests.js"></script>
|
||||||
|
|
||||||
<script src="deepEqual.js"></script>
|
<script src="deepEqual.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user