Alexey Andreev 2014-12-09 16:42:26 +04:00
parent 844da6760c
commit 11f270e3ef
5 changed files with 90 additions and 2 deletions

View File

@ -34,10 +34,51 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<version>${project.version}</version> <version>${project.version}</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.teavm</groupId>
<artifactId>teavm-maven-plugin</artifactId>
<version>${project.version}</version>
<dependencies>
<dependency>
<groupId>org.teavm</groupId>
<artifactId>teavm-classlib</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-javascript-tests</id>
<goals>
<goal>build-test-javascript</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<minifying>false</minifying>
<properties>
<java.util.Locale.available>en, en_US, en_GB, ru, ru_RU</java.util.Locale.available>
</properties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**</exclude>
</excludes>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>

View File

@ -74,10 +74,10 @@ public class JSNativeGenerator implements Injector, DependencyPlugin {
writer.append(')'); writer.append(')');
break; break;
case "instantiate": case "instantiate":
writer.append("(new "); writer.append("(new (");
context.writeExpr(context.getArgument(0)); context.writeExpr(context.getArgument(0));
renderProperty(context.getArgument(1), context); renderProperty(context.getArgument(1), context);
writer.append('('); writer.append(")(");
for (int i = 2; i < context.argumentCount(); ++i) { for (int i = 2; i < context.argumentCount(); ++i) {
if (i > 2) { if (i > 2) {
writer.append(',').ws(); writer.append(',').ws();

View File

@ -0,0 +1,21 @@
package org.teavm.jso.test;
import static org.junit.Assert.*;
import org.junit.Test;
import org.teavm.jso.JS;
/**
*
* @author Alexey Andreev
*/
public class JSOTest {
@Test
public void complexConstructorParenthesized() {
RegExp regexp = getWindow().createRegExp(".");
assertEquals(".", regexp.getSource());
}
private static Window getWindow() {
return (Window)JS.getGlobal();
}
}

View File

@ -0,0 +1,13 @@
package org.teavm.jso.test;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
/**
*
* @author Alexey Andreev
*/
public interface RegExp extends JSObject {
@JSProperty
String getSource();
}

View File

@ -0,0 +1,13 @@
package org.teavm.jso.test;
import org.teavm.jso.JSConstructor;
import org.teavm.jso.JSObject;
/**
*
* @author Alexey Andreev
*/
public interface Window extends JSObject {
@JSConstructor("RegExp")
RegExp createRegExp(String regex);
}