mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
back to snapshot mode + enum test added
- repo should alway be in snapshot mode - just wanted to make sure that enums are ok with modules
This commit is contained in:
parent
700b48a973
commit
794ea24503
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.jsweet</groupId>
|
||||
<artifactId>jsweet-transpiler</artifactId>
|
||||
<version>2.0.0-rc1</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<name>JSweet transpiler</name>
|
||||
<description>A Java to TypeScript/JavaScript Open Transpiler</description>
|
||||
<developers>
|
||||
|
||||
@ -27,15 +27,17 @@ import org.jsweet.transpiler.extension.StringEnumAdapter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import source.enums.EnumWithStatics;
|
||||
import source.enums.ComplexEnumWithAbstractMethods;
|
||||
import source.enums.ComplexEnums;
|
||||
import source.enums.ComplexEnumsWithInterface;
|
||||
import source.enums.ComplexInnerEnums;
|
||||
import source.enums.ComplexEnums;
|
||||
import source.enums.EnumInSamePackage;
|
||||
import source.enums.EnumWithStatics;
|
||||
import source.enums.Enums;
|
||||
import source.enums.ErasedEnum;
|
||||
import source.enums.MyComplexEnum2;
|
||||
import source.enums.StringEnums;
|
||||
import source.enums.other.ComplexEnumsAccess;
|
||||
import source.enums.other.EnumInOtherPackage;
|
||||
|
||||
public class EnumTests extends AbstractTest {
|
||||
@ -84,6 +86,15 @@ public class EnumTests extends AbstractTest {
|
||||
}, getSourceFile(ComplexEnums.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexEnumsAccess() {
|
||||
eval((logHandler, r) -> {
|
||||
logHandler.assertNoProblems();
|
||||
Assert.assertEquals(">2,--2--,ratio_2_1_5,true,true,true,true", r.get("trace2"));
|
||||
//Assert.assertEquals(">static,2,--2--,ratio_2_1_5,true,true,true,true,2,2", r.get("trace2"));
|
||||
}, getSourceFile(MyComplexEnum2.class), getSourceFile(ComplexEnumsAccess.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexInnerEnums() {
|
||||
eval((logHandler, r) -> {
|
||||
|
||||
@ -26,11 +26,11 @@ public class ComplexEnums {
|
||||
$export("trace", ">" + trace.join(","));
|
||||
}
|
||||
|
||||
static class A {
|
||||
static int i = 2;
|
||||
public static class A {
|
||||
public static int i = 2;
|
||||
}
|
||||
|
||||
static enum InnerEnum {
|
||||
public static enum InnerEnum {
|
||||
|
||||
E1(0x0),
|
||||
|
||||
|
||||
41
transpiler/src/test/java/source/enums/MyComplexEnum2.java
Normal file
41
transpiler/src/test/java/source/enums/MyComplexEnum2.java
Normal file
@ -0,0 +1,41 @@
|
||||
package source.enums;
|
||||
|
||||
import source.enums.other.ComplexEnumsAccess;
|
||||
|
||||
public enum MyComplexEnum2 {
|
||||
FREE_RATIO(null), VIEW_3D_RATIO(null), RATIO_4_3(4f / 3), RATIO_3_2(1.5f), RATIO_16_9(16f / 9), RATIO_2_1(
|
||||
2f / 1f), SQUARE_RATIO(1f);
|
||||
|
||||
private final Float value;
|
||||
|
||||
public String str;
|
||||
|
||||
public String otherName;
|
||||
|
||||
private MyComplexEnum2(Float value) {
|
||||
this.value = value;
|
||||
this.str = "--" + value.intValue() + "--";
|
||||
this.otherName = this.name().toLowerCase() + "_" + ordinal();
|
||||
aNonStaticMethod();
|
||||
this.aNonStaticMethod();
|
||||
aStaticMethod2();
|
||||
}
|
||||
|
||||
public Float getValue() {
|
||||
aNonStaticMethod();
|
||||
this.aNonStaticMethod();
|
||||
aStaticMethod2();
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void aStaticMethod() {
|
||||
ComplexEnumsAccess.trace2.push("static");
|
||||
}
|
||||
|
||||
public static void aStaticMethod2() {
|
||||
}
|
||||
|
||||
public void aNonStaticMethod() {
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package source.enums.other;
|
||||
|
||||
import static jsweet.util.Lang.$export;
|
||||
|
||||
import def.js.Array;
|
||||
import source.enums.MyComplexEnum2;
|
||||
|
||||
public class ComplexEnumsAccess {
|
||||
public static Array<String> trace2 = new Array<String>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO: this does not work with modules
|
||||
//MyComplexEnum2.aStaticMethod();
|
||||
trace2.push("" + MyComplexEnum2.RATIO_2_1.getValue());
|
||||
trace2.push("" + MyComplexEnum2.RATIO_2_1.str);
|
||||
trace2.push("" + MyComplexEnum2.RATIO_2_1.otherName);
|
||||
trace2.push("" + (MyComplexEnum2.RATIO_16_9 == MyComplexEnum2.RATIO_16_9));
|
||||
trace2.push("" + (MyComplexEnum2.RATIO_16_9.name() == MyComplexEnum2.RATIO_16_9.name()));
|
||||
trace2.push("" + (MyComplexEnum2.RATIO_16_9.ordinal() == MyComplexEnum2.RATIO_16_9.ordinal()));
|
||||
trace2.push("" + (MyComplexEnum2.RATIO_16_9 != (MyComplexEnum2) MyComplexEnum2.RATIO_3_2));
|
||||
|
||||
$export("trace2", ">" + trace2.join(","));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user