JS: add tests for two libraries and js-file with two modules

This commit is contained in:
Michael Nedzelsky
2015-04-17 16:07:06 +03:00
parent 5daf79d2de
commit 3dce96e01c
11 changed files with 165 additions and 0 deletions
@@ -0,0 +1,18 @@
OUT:
Buildfile: [TestData]/build.xml
build:
[mkdir] Created dir: [Temp]/lib
[kotlin2js] Compiling [[TestData]/jslib-example1] => [[Temp]/lib/jslib-example1.js]
[kotlin2js] Compiling [[TestData]/jslib-example2] => [[Temp]/lib/jslib-example2.js]
[delete] Deleting: [Temp]/lib/jslib-example1.js
[delete] Deleting: [Temp]/lib/jslib-example2.js
[delete] Deleting: [Temp]/lib/jslib-example1.meta.js
[delete] Deleting: [Temp]/lib/jslib-example2.meta.js
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
[copy] Copying 1 file to [Temp]
BUILD SUCCESSFUL
Total time: [time]
Return code: 0
@@ -0,0 +1,40 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<property name="library.path1" value="${test.data}/jslib-example1"/>
<property name="library.path2" value="${test.data}/jslib-example2"/>
<property name="temp.library.path" value="${temp}/lib"/>
<target name="build">
<mkdir dir="${temp.library.path}"/>
<kotlin2js src="${library.path1}" output="${temp.library.path}/jslib-example1.js" metaInfo="${temp.library.path}/jslib-example1.meta.js"/>
<kotlin2js src="${library.path2}" output="${temp.library.path}/jslib-example2.js" metaInfo="${temp.library.path}/jslib-example2.meta.js">
<library>
<pathelement path="${temp.library.path}/jslib-example1.meta.js"/>
</library>
</kotlin2js>
<concat destfile="${temp.library.path}/jslib-example.js">
<fileset file="${temp.library.path}/jslib-example1.js"/>
<fileset file="${temp.library.path}/jslib-example2.js"/>
<fileset file="${temp.library.path}/jslib-example1.meta.js"/>
<fileset file="${temp.library.path}/jslib-example2.meta.js"/>
</concat>
<delete file="${temp.library.path}/jslib-example1.js"/>
<delete file="${temp.library.path}/jslib-example2.js"/>
<delete file="${temp.library.path}/jslib-example1.meta.js"/>
<delete file="${temp.library.path}/jslib-example2.meta.js"/>
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call">
<library>
<pathelement path="${temp.library.path}/jslib-example.js"/>
</library>
</kotlin2js>
<copy todir="${temp}">
<fileset dir="${temp.library.path}">
<include name="**/*.js"/>
<exclude name="META-INF/**"/>
</fileset>
</copy>
</target>
</project>
@@ -0,0 +1,9 @@
package library.sample
import kotlin.js.Date
public class ClassA() {
val value: Int = 100
}
public fun Date.extFun(): String = "Date.extFun"
@@ -0,0 +1,3 @@
package library.sample
public fun ClassA.extFun(): String = "ClassA.extFun"
@@ -0,0 +1,15 @@
package foo
import library.sample.*
import kotlin.js.Date
var ok = "FAIL"
fun main(args: Array<String>) {
val x = ClassA().value
if (x == 100 && Date().extFun() == "Date.extFun" && ClassA().extFun() == "ClassA.extFun") {
ok = "OK"
}
}
fun box(): String = ok