fix main function detection to rely on actually resolved types

This commit is contained in:
Ladislav Thon
2014-02-16 02:24:17 +01:00
committed by Evgeny Gerashchenko
parent a2f6b99862
commit 36bc7580aa
21 changed files with 242 additions and 84 deletions
@@ -125,6 +125,16 @@ public class AntTaskTest extends KotlinIntegrationTestBase {
doJsAntTest();
}
@Test
public void k2jsWithMainFQArgs() throws Exception {
doJsAntTest();
}
@Test
public void k2jsWithMainVarargs() throws Exception {
doJsAntTest();
}
@Test
public void k2jsManySources() throws Exception {
doJsAntTest();
@@ -32,6 +32,22 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
}
@Test
public void compileAndRunHelloAppFQMain() throws Exception {
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar));
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
}
@Test
public void compileAndRunHelloAppVarargMain() throws Exception {
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar));
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
}
@Test
public void compileAndRunModule() throws Exception {
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
@@ -0,0 +1,5 @@
package Hello
fun main(args: kotlin.Array<kotlin.String>) {
System.out.println("Hello from fully qualified main!")
}
@@ -0,0 +1,4 @@
OUT:
Hello from fully qualified main!
Return code: 0
@@ -0,0 +1,5 @@
package Hello
fun main(vararg args: kotlin.String) {
System.out.println("Hello from vararg main!")
}
@@ -0,0 +1,4 @@
OUT:
Hello from vararg main!
Return code: 0
@@ -0,0 +1,10 @@
OUT:
Buildfile: [TestData]/build.xml
build:
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
BUILD SUCCESSFUL
Total time: [time]
Return code: 0
@@ -0,0 +1,7 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<target name="build">
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call"/>
</target>
</project>
@@ -0,0 +1,9 @@
package foo
var ok = "FAIL"
fun main(args: kotlin.Array<kotlin.String>) {
ok = "OK"
}
fun box(): String = ok
@@ -0,0 +1,10 @@
OUT:
Buildfile: [TestData]/build.xml
build:
[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js]
BUILD SUCCESSFUL
Total time: [time]
Return code: 0
@@ -0,0 +1,7 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<target name="build">
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call"/>
</target>
</project>
@@ -0,0 +1,9 @@
package foo
var ok = "FAIL"
fun main(vararg args: kotlin.String) {
ok = "OK"
}
fun box(): String = ok