public void test_ClassicJavaForLoop1_FAILS() throws Exception { if (notYetImplemented()) return; // For statement contains unexpected tokens. Possible attempt to use unsupported Java-style for loop. // This syntax now replaced with closure list i.e. for (i=0;j=2;i<10;i++;j--) {... assertNotNull(compile("for (i = 0,j = 2;i < 10; i++, j--) {print i}")); // fails after parser }
public void testElist() throws Exception { assertEquals("println 2 + 2", pretty("println 2 + 2")); assertEquals("for (i = 0; j = 2; i < 10; i++; j--){print i}", pretty("for (i = 0;j = 2;i < 10; i++; j--) {print i}")); // fails after parser assertEquals("foo()", pretty("foo()")); // empty ELIST assertEquals("foo(bar, mooky)", pretty("foo( bar , mooky )")); }
public void testEsc_FAILS() throws Exception { if (notYetImplemented()) return; // dquote-tab-dquote assertEquals("println \"\\\"\t\\\"\"", pretty("println \"\\\"\t\\\"\"")); }
public void test_ContinueWithValueAllowedInLoops_FAILS() throws Exception { if (notYetImplemented()) return; // Unexpected node type: a numeric literal found when expecting type: an identifier assertNotNull(compile("for (i in 1..100) {continue 2}")); // fails after parser }
public void testExtendsClause() throws Exception { assertEquals("class Foo extends Bar {}", pretty("class Foo extends Bar {}")); assertEquals("interface Wibble extends Mooky{}", pretty("interface Wibble extends Mooky {}")); //todo spacing is odd, c.f. last space in class vs interface above }
public void testRegexpLiteral_FAILS() throws Exception { if (notYetImplemented()) return; // not in java //todo: these fail because regexp_literals are converted into string_literals on the antlr AST assertEquals("def x = /./", pretty("def x = /./")); // not in java assertEquals("def z = /blah\\s/", pretty("def z = /blah\\s/")); // actually: def z = /blah\s/ // not in java }
public void test_Threadsafe2_FAILS() throws Exception { if (notYetImplemented()) return; // Unknown type: "threadsafe" assertNotNull(compile("public static transient final native threadsafe synchronized volatile strictfp foo() {}")); // fails after parser }
public void testLiteralAs() throws Exception { // not in java assertEquals("import java.util.Date as MyDate", pretty("import java.util.Date as MyDate")); // not in java // todo suspicious spacing in the following assertion assertEquals("x = 12 as Long", pretty("x = 12 as Long")); // not in java }
public void test_SpreadExpressionInGString2_FAILS() throws Exception { if (notYetImplemented()) return; // BUG! exception in phase 'class generation' in source unit 'Script1.groovy' // SpreadExpression should not be visited here assertNotNull(compile("\"foo${*bar}\"")); // fails after parser }
public void testLiteralBreak() throws Exception { assertEquals("for (i in 1..100) {break }", pretty("for (i in 1..100) {break}")); assertEquals("switch (foo) {default:break }", pretty("switch(foo){default:break}")); assertEquals("def myMethod() {break }", pretty("def myMethod(){break}")); // fails after parser // deprecated -> assertEquals("for (i in 1..100) {break 2}", pretty("for (i in 1..100) {break 2}")); // fails after parser //todo should the colon be postfixed to the label? // deprecated -> assertEquals("for (i in 1..100) {break label1:}", pretty("for (i in 1..100) {break label1:}")); // fails after parser assertEquals("for (i in 1..100) {break label1}", pretty("for (i in 1..100) {break label1}")); }
public void test_EnumDef1_FAILS() throws Exception { if (notYetImplemented()) return; // Unknown type: ENUM_DEF assertNotNull(compile("enum Coin {PENNY(1), DIME(10), QUARTER(25)}")); // fails after parser }
public void testQuestion() throws Exception { assertEquals("foo == bar?10:20", pretty("foo==bar?10:20")); assertEquals("public boolean process(Set<? extends B> a) {println a}", pretty("public boolean process(Set<? extends B> a) {println a}")); assertEquals("public boolean process(Set<? extends B, ? super C> a) {println a}", pretty("public boolean process(Set<? extends B, ? super C> a) {println a}")); }
public void test_EnumDef2_FAILS() throws Exception { if (notYetImplemented()) return; // Unknown type: ENUM_DEF assertNotNull(compile("enum Season{WINTER,SPRING,SUMMER,AUTUMN}")); // fails after parser }
public void testSuperCtorCall() throws Exception { assertEquals("class Foo {Foo(int x) {super(12, 3)}}", pretty("class Foo{Foo(int x) {super(12, 3)}}")); assertEquals("class Foo {Foo(x) {super()}}", pretty("class Foo{Foo(x) {super()}}")); // todo: above is not quite the spacing I would expect, but good enough for now... // todo not yet implemented in parser: assertEquals("(new Outer()).super()", pretty("(new Outer()).super()")); }
public void test_ContinueAllowedInClosures_FAILS() throws Exception { if (notYetImplemented()) return; // the continue statement is only allowed inside loops assertNotNull(compile("[1,2,3].each{continue}")); // fails after parser }
public void testLiteralExtends() throws Exception { assertEquals("class Foo extends java.util.Date {}", pretty("class Foo extends java.util.Date {}")); assertEquals("class Foo extends Bar {}", pretty("class Foo extends Bar {}")); assertEquals("interface Wibble extends Mooky{}", pretty("interface Wibble extends Mooky {}")); //todo spacing is odd, c.f. last space in class vs interface above assertEquals("public boolean process(Set<? extends TypeElement> annotations) {println annotations}", pretty("public boolean process(Set<? extends TypeElement> annotations) {println annotations}")); }
public void test_BreakWithValueAllowedInLoops_FAILS() throws Exception { if (notYetImplemented()) return; // Unexpected node type: a numeric literal found when expecting type: an identifier assertNotNull(compile("for (i in 1..100) {break 2}")); // fails after parser }
public void testLiteralStatic() throws Exception { assertEquals("static void foo() {}", pretty("static void foo() {}")); //classes, interfaces, class/instance vars and methods assertEquals("static int bar = 1", pretty("static int bar = 1")); //todo: this should parse... assertEquals("private static <T> void foo(List<T> list){}", pretty("private static <T> void foo(List<T> list){}")); assertEquals("class Foo {static {bar = 1}}", pretty("class Foo{static {bar=1}}")); }
public void test_NativeMethods1_FAILS() throws Exception { if (notYetImplemented()) return; // You defined a method without body. Try adding a body, or declare it abstract assertNotNull(compile("public class R{public native void seek(long pos)}")); // fails after parser }
public void testType() throws Exception { assertEquals("def bar", pretty("def bar")); assertEquals("public bar", pretty("public bar")); assertEquals("public String bar", pretty("public String bar")); assertEquals("String bar", pretty("String bar")); }