From 729e7084fa1174f474a30da28afc43b1559967d8 Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Sun, 9 Nov 2014 02:57:35 +0300 Subject: [PATCH] new ant test for kotlin javascript library support --- build.xml | 31 --------------- .../org/jetbrains/kotlin/AntTaskJsTest.java | 32 ++++++++++++--- .../build.log.expected | 11 ++++++ .../simpleWithStdlibAndAnotherLib/build.xml | 17 ++++++++ .../jslib-example.jar | Bin 0 -> 1498 bytes .../root1/foo.kt | 14 +++++++ .../build.log.expected | 11 ++++++ .../build.xml | 17 ++++++++ .../jslib-example/LibraryExample.kt | 8 ++++ .../jslib-example/META-INF/MANIFEST.MF | 9 +++++ .../jslib-example/ReadMe.md | 6 +++ .../jslib-example/jslib-example.js | 37 ++++++++++++++++++ .../root1/foo.kt | 14 +++++++ compiler/testData/cli/js/withFolderAsLib.args | 2 +- compiler/testData/cli/js/withLib.args | 2 +- 15 files changed, 173 insertions(+), 38 deletions(-) create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.log.expected create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.xml create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/root1/foo.kt create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.log.expected create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.xml create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/ReadMe.md create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/jslib-example.js create mode 100644 compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/root1/foo.kt diff --git a/build.xml b/build.xml index 9b0d02963b6..c962fba9534 100644 --- a/build.xml +++ b/build.xml @@ -307,37 +307,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - fileNames = new ArrayList(Arrays.asList(jsFiles)); + fileNames.add(JS_OUT_FILE); + + List filePaths = ContainerUtil.map(fileNames, new Function() { + @Override + public String fun(String s) { + return getOutputFileByName(s).getAbsolutePath(); + } + }); + + RhinoUtils.runRhinoTest(filePaths, new RhinoFunctionResultChecker("out", "foo", "box", "OK")); } private void doJsAntTestForPostfixPrefix(@Nullable String prefix, @Nullable String postfix) throws Exception { @@ -90,6 +102,16 @@ public class AntTaskJsTest extends AntTaskBaseTest { doJsAntTest(); } + @Test + public void simpleWithStdlibAndAnotherLib() throws Exception { + doJsAntTest("jslib-example.js"); + } + + @Test + public void simpleWithStdlibAndFolderAsAnotherLib() throws Exception { + doJsAntTest("jslib-example.js"); + } + @Test public void simpleWithMainFQArgs() throws Exception { doJsAntTest(); diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.log.expected b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.log.expected new file mode 100644 index 00000000000..ef2906cf7b6 --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.log.expected @@ -0,0 +1,11 @@ +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + [unzip] Expanding: [TestData]/jslib-example.jar into [Temp] + +BUILD SUCCESSFUL +Total time: [time] + +Return code: 0 diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.xml b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.xml new file mode 100644 index 00000000000..a4bb60f224f --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/build.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar new file mode 100644 index 0000000000000000000000000000000000000000..9ab9caad358789fe738d0534695a599d4b63319a GIT binary patch literal 1498 zcmWIWW@h1HVBlb2Fj&*-%76qo8CV#6T|*poJ^kGD|D9rB2!JZ(V9*CD-OQv|yAP;b zh>?Lo1W3b``a1e~y1532==r+Up4;7b$UuPg!o5lV52}jvaX2}7yRYC_ucRGiQmB?R zAvyY6!-MzNZMxQGyq~k$+PdIMa#HP)87FqPYIS#tcz@TAWHU$)u{?cz{-P;KqJk3E zv9|N-;(Yu*ugp6=Q%Y7zqC4wp@&`eS@5h5e!Z-anWLhNJ7&9r!mZh87s&3_;XIAq2 zyU*L7bo59+A7sMF`!(g>gXuROIpx|!7p-cOHc<;o*t#^Vt9;FCxA!&WTUUHHNU8Ol z7S&r`(dVgnR3719gK4dtAPGI4#a{$?30;Plvq^hT9KGrkdvyHUDDfQ$alzq z$MyT1L&@AL*jF%g^0s-!9Q2J5NenveH=*kHvNf?1|NiIysA~GxtIyQ8c#+=Rhwd}x zOg1X|Vlb7ZDKKBr4G&WPo9gEH7)!g-*h-mz(Bde zZS&je`IZyR;!{>=ei7bsZY{#0TUNKa%B|TGHy`LgHDJVW0_mXC#1!9Dz1)^fL+s47b4wbJW(Jh#1zFFGzVWT2kMZc?jDr=)cWz$3`q(R1Wu8~xl3vpw zn~C#w^2Q&ER&sbNWdFkdy8iJx7gq1olY&uAseLa*7^~IS?rJgGz?1#K<-+IOaA#yo56kjCx_l?A-f`x zD?eU*GIC%nFuU%Oe=PIc%QISPB^(TGYebKmJBRqj$#XggF0&7`nr;1Xj)lB)ICJQi zM+_!W%UM@s9o(|-8)NWW!LY*z(Z$C)n7Es zJ`eV1k zytnkXE7nA?Ty*uQ`)l*5sv%?h#2d!eSs9BzE6FyzYZFO7sZ>*@Xi?ewPPJ6#^P8JL zEdMm@KO~T*JmcquyAMmhzTO|;&B!FejJr?*rUoDoV0h~YqT%HZq=8(G=RX8 zMr|Mo*NRkRAuQ)$z?SX7+QBAB15+nPA%LtMTV_OPKLXSa&zi{Eu%&*4wk{^jyb$2c R$_7%w3WSD0V<)qKcmUC%Ku!Pv literal 0 HcmV?d00001 diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/root1/foo.kt b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/root1/foo.kt new file mode 100644 index 00000000000..c6da571924b --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/root1/foo.kt @@ -0,0 +1,14 @@ +package foo + +import library.sample.* + +var ok = "FAIL" + +fun main(args: Array) { + val p = Pair(10, 20) + val x = pairAdd(p) + ok = "OK" + println("x=$x") +} + +fun box(): String = ok diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.log.expected b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.log.expected new file mode 100644 index 00000000000..f1a7a8e9413 --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.log.expected @@ -0,0 +1,11 @@ +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + [copy] Copying 1 file to [Temp] + +BUILD SUCCESSFUL +Total time: [time] + +Return code: 0 diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.xml b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.xml new file mode 100644 index 00000000000..7c2815d2bb2 --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt new file mode 100644 index 00000000000..28569346084 --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt @@ -0,0 +1,8 @@ +package library.sample + +public fun pairAdd(p: Pair): Int = p.first + p.second + +public fun pairMul(p: Pair): Int = p.first * p.second + +public data class IntHolder(val value: Int) + diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..00281ee90c5 --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.9.1 +Created-By: 1.7.0_72-b14 (Oracle Corporation) +Built-By: JetBrains +Implementation-Vendor: JetBrains +Implementation-Version: snapshot +Specification-Title: Kotlin JavaScript Lib +Kotlin-JS-Module-Name: jslib-example + diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/ReadMe.md b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/ReadMe.md new file mode 100644 index 00000000000..6c269930b08 --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/ReadMe.md @@ -0,0 +1,6 @@ +# jslib-example + +Path to sources: compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example + +The archive compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar should be updated after +changing some files in source folder. \ No newline at end of file diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/jslib-example.js b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/jslib-example.js new file mode 100644 index 00000000000..8fb2ce81d48 --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/jslib-example.js @@ -0,0 +1,37 @@ +(function (Kotlin) { + 'use strict'; + var _ = Kotlin.defineRootPackage(null, /** @lends _ */ { + library: Kotlin.definePackage(null, /** @lends _.library */ { + sample: Kotlin.definePackage(null, /** @lends _.library.sample */ { + pairAdd_bunuun$: function (p) { + return p.first + p.second; + }, + pairMul_bunuun$: function (p) { + return p.first * p.second; + }, + IntHolder: Kotlin.createClass(null, function (value) { + this.value = value; + }, /** @lends _.library.sample.IntHolder.prototype */ { + component1: function () { + return this.value; + }, + copy_za3lpa$: function (value) { + return new _.library.sample.IntHolder(value === void 0 ? this.value : value); + }, + toString: function () { + return 'IntHolder(value=' + Kotlin.toString(this.value) + ')'; + }, + hashCode: function () { + var result = 0; + result = result * 31 + Kotlin.hashCode(this.value) | 0; + return result; + }, + equals_za3rmp$: function (other) { + return this === other || (other !== null && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value))); + } + }) + }) + }) + }); + Kotlin.defineModule('jslib-example', _); +}(Kotlin)); diff --git a/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/root1/foo.kt b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/root1/foo.kt new file mode 100644 index 00000000000..c6da571924b --- /dev/null +++ b/compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/root1/foo.kt @@ -0,0 +1,14 @@ +package foo + +import library.sample.* + +var ok = "FAIL" + +fun main(args: Array) { + val p = Pair(10, 20) + val x = pairAdd(p) + ok = "OK" + println("x=$x") +} + +fun box(): String = ok diff --git a/compiler/testData/cli/js/withFolderAsLib.args b/compiler/testData/cli/js/withFolderAsLib.args index 0dcea39b299..7052021ee8b 100644 --- a/compiler/testData/cli/js/withFolderAsLib.args +++ b/compiler/testData/cli/js/withFolderAsLib.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/withLib.kt -library-files -dist/jslib-example +compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/withLib.args b/compiler/testData/cli/js/withLib.args index ae65dafb653..f9b2ba58947 100644 --- a/compiler/testData/cli/js/withLib.args +++ b/compiler/testData/cli/js/withLib.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/withLib.kt -library-files -dist/jslib-example.jar +compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar -output $TEMP_DIR$/out.js