K2JS: add cli compiler tests for libraries
This commit is contained in:
@@ -307,6 +307,37 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="jslib-example">
|
||||
<property name="jslib-example-name" value="jslib-example" />
|
||||
<property name="jslib-example-dir" value="${basedir}/compiler/testData/cli/js" />
|
||||
|
||||
<kotlin2js output="${output}/${jslib-example-name}.js" main="noCall">
|
||||
<src>
|
||||
<fileset dir="${jslib-example-dir}">
|
||||
<include name="LibraryExample.kt" />
|
||||
</fileset>
|
||||
</src>
|
||||
</kotlin2js>
|
||||
|
||||
<jar jarfile="${output}/jslib-example.jar">
|
||||
<fileset dir="${jslib-example-dir}">
|
||||
<include name="LibraryExample.kt" />
|
||||
</fileset>
|
||||
<zipfileset file="${output}/${jslib-example-name}.js" prefix=""/>
|
||||
|
||||
<manifest>
|
||||
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
|
||||
|
||||
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${build.number}"/>
|
||||
<attribute name="Specification-Title" value="${manifest.spec.title.kotlin.javascript.lib}"/>
|
||||
<attribute name="Kotlin-JS-Module-Name" value="${jslib-example-name}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
|
||||
<unzip src="${output}/jslib-example.jar" dest="${output}/jslib-example" />
|
||||
</target>
|
||||
|
||||
<target name="preloader">
|
||||
<cleandir dir="${output}/classes/preloader"/>
|
||||
<javac2 destdir="${output}/classes/preloader" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package library.sample
|
||||
|
||||
public fun pairAdd(p: Pair<Int, Int>): Int = p.first + p.second
|
||||
|
||||
public fun pairMul(p: Pair<Int, Int>): Int = p.first * p.second
|
||||
|
||||
public data class IntHolder(val value: Int)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/withLib.kt
|
||||
-library-files
|
||||
dist/jslib-example
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/withLib.kt
|
||||
-library-files
|
||||
dist/jslib-example.jar
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
@@ -0,0 +1,8 @@
|
||||
import kotlin.Pair
|
||||
import library.sample.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val p = Pair(10, 20)
|
||||
val x = pairAdd(p)
|
||||
println("x=$x")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -203,5 +203,17 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/suppressAllWarningsJS.args");
|
||||
doJsTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withFolderAsLib.args")
|
||||
public void testWithFolderAsLib() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/withFolderAsLib.args");
|
||||
doJsTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withLib.args")
|
||||
public void testWithLib() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/withLib.args");
|
||||
doJsTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,4 +62,18 @@ public class K2JsCliTest extends CliBaseTest {
|
||||
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), "out.js").isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withLib() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), "out.js").isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withFolderAsLib() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), "out.js").isFile());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user