Skip to content

Commit

Permalink
Merge pull request #13 from antlr/intermediate-test-generation
Browse files Browse the repository at this point in the history
Move to new testing mechanism
  • Loading branch information
parrt committed Jun 3, 2015
2 parents a90e294 + 8c2657b commit 345bd14
Show file tree
Hide file tree
Showing 19 changed files with 1,627 additions and 218 deletions.
2 changes: 1 addition & 1 deletion tool/src/org/antlr/v4/codegen/CSharpTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CSharpTarget(CodeGenerator gen) {

@Override
public String getVersion() {
return "4.5"; // crossing fingers that it's close enough.
return "4.5.1"; // crossing fingers that it's close enough.
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions tool/test/org/antlr/v4/test/rt/csharp/TestCompositeLexers.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.junit.Test;

public class TestCompositeLexers extends BaseTest {
public class TestCompositeLexers extends org.antlr.v4.test.runtime.csharp.BaseTest {

/* this file and method are generated, any edit will be overwritten by the next generation */
@Test
Expand All @@ -20,10 +20,10 @@ public void testLexerDelegatorInvokesDelegateRule() throws Exception {
sb.append("WS : (' '|'\\n') -> skip ;\n");
String grammar = sb.toString();
String found = execLexer("M.g4", grammar, "M", "abc", false);
assertEquals("S.A\n" +
"[@0,0:0='a',<3>,1:0]\n" +
"[@1,1:1='b',<1>,1:1]\n" +
"[@2,2:2='c',<4>,1:2]\n" +
assertEquals("S.A\n" +
"[@0,0:0='a',<3>,1:0]\n" +
"[@1,1:1='b',<1>,1:1]\n" +
"[@2,2:2='c',<4>,1:2]\n" +
"[@3,3:2='<EOF>',<-1>,1:3]\n", found);
assertNull(this.stderrDuringParse);
}
Expand All @@ -44,11 +44,11 @@ public void testLexerDelegatorRuleOverridesDelegate() throws Exception {
sb.append("WS : (' '|'\\n') -> skip ;\n");
String grammar = sb.toString();
String found = execLexer("M.g4", grammar, "M", "ab", false);
assertEquals("M.A\n" +
"[@0,0:1='ab',<1>,1:0]\n" +
assertEquals("M.A\n" +
"[@0,0:1='ab',<1>,1:0]\n" +
"[@1,2:1='<EOF>',<-1>,1:2]\n", found);
assertNull(this.stderrDuringParse);
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.antlr.v4.test.tool.ErrorQueue;
import org.antlr.v4.tool.Grammar;

public class TestCompositeParsers extends BaseTest {
public class TestCompositeParsers extends org.antlr.v4.test.runtime.csharp.BaseTest {

/* this file and method are generated, any edit will be overwritten by the next generation */
@Test
Expand Down Expand Up @@ -337,4 +337,4 @@ public void testImportLexerWithOnlyFragmentRules() throws Exception {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.junit.Test;

public class TestFullContextParsing extends BaseTest {
public class TestFullContextParsing extends org.antlr.v4.test.runtime.csharp.BaseTest {

/* this file and method are generated, any edit will be overwritten by the next generation */
@Test
Expand Down Expand Up @@ -222,4 +222,4 @@ public void testExprAmbiguity_2() throws Exception {
}


}
}
4 changes: 2 additions & 2 deletions tool/test/org/antlr/v4/test/rt/csharp/TestLeftRecursion.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.junit.Test;

public class TestLeftRecursion extends BaseTest {
public class TestLeftRecursion extends org.antlr.v4.test.runtime.csharp.BaseTest {

/* this file and method are generated, any edit will be overwritten by the next generation */
String testSimple(String input) throws Exception {
Expand Down Expand Up @@ -1161,4 +1161,4 @@ public void testReturnValueAndActionsList2_4() throws Exception {
}


}
}
26 changes: 13 additions & 13 deletions tool/test/org/antlr/v4/test/rt/csharp/TestLexerErrors.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.junit.Test;

public class TestLexerErrors extends BaseTest {
public class TestLexerErrors extends org.antlr.v4.test.runtime.csharp.BaseTest {

/* this file and method are generated, any edit will be overwritten by the next generation */
@Test
Expand All @@ -26,7 +26,7 @@ public void testStringsEmbeddedInActions_1() throws Exception {
sb.append("WS : [ \\t\\r\\n]+ -> skip;\n");
String grammar = sb.toString();
String found = execLexer("L.g4", grammar, "L", "[\"foo\"]", false);
assertEquals("[@0,0:6='[\"foo\"]',<1>,1:0]\n" +
assertEquals("[@0,0:6='[\"foo\"]',<1>,1:0]\n" +
"[@1,7:6='<EOF>',<-1>,1:7]\n", found);
assertNull(this.stderrDuringParse);
}
Expand Down Expand Up @@ -54,7 +54,7 @@ public void testEnforcedGreedyNestedBrances_1() throws Exception {
sb.append("WS : [ \\r\\n\\t]+ -> skip;\n");
String grammar = sb.toString();
String found = execLexer("L.g4", grammar, "L", "{ { } }", false);
assertEquals("[@0,0:6='{ { } }',<1>,1:0]\n" +
assertEquals("[@0,0:6='{ { } }',<1>,1:0]\n" +
"[@1,7:6='<EOF>',<-1>,1:7]\n", found);
assertNull(this.stderrDuringParse);
}
Expand All @@ -80,7 +80,7 @@ public void testInvalidCharAtStartAfterDFACache() throws Exception {
sb.append("A : 'a' 'b' ;\n");
String grammar = sb.toString();
String found = execLexer("L.g4", grammar, "L", "abx", false);
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
"[@1,3:2='<EOF>',<-1>,1:3]\n", found);
assertEquals("line 1:2 token recognition error at: 'x'\n", this.stderrDuringParse);
}
Expand All @@ -105,7 +105,7 @@ public void testInvalidCharInTokenAfterDFACache() throws Exception {
sb.append("A : 'a' 'b' ;\n");
String grammar = sb.toString();
String found = execLexer("L.g4", grammar, "L", "abax", false);
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
"[@1,4:3='<EOF>',<-1>,1:4]\n", found);
assertEquals("line 1:2 token recognition error at: 'ax'\n", this.stderrDuringParse);
}
Expand All @@ -119,8 +119,8 @@ public void testDFAToATNThatFailsBackToDFA() throws Exception {
sb.append("B : 'abc' ;\n");
String grammar = sb.toString();
String found = execLexer("L.g4", grammar, "L", "ababx", false);
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
"[@1,2:3='ab',<1>,1:2]\n" +
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
"[@1,2:3='ab',<1>,1:2]\n" +
"[@2,5:4='<EOF>',<-1>,1:5]\n", found);
assertEquals("line 1:4 token recognition error at: 'x'\n", this.stderrDuringParse);
}
Expand All @@ -135,8 +135,8 @@ public void testDFAToATNThatMatchesThenFailsInATN() throws Exception {
sb.append("C : 'abcd' ;\n");
String grammar = sb.toString();
String found = execLexer("L.g4", grammar, "L", "ababcx", false);
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
"[@1,2:4='abc',<2>,1:2]\n" +
assertEquals("[@0,0:1='ab',<1>,1:0]\n" +
"[@1,2:4='abc',<2>,1:2]\n" +
"[@2,6:5='<EOF>',<-1>,1:6]\n", found);
assertEquals("line 1:5 token recognition error at: 'x'\n", this.stderrDuringParse);
}
Expand Down Expand Up @@ -164,12 +164,12 @@ public void testLexerExecDFA() throws Exception {
sb.append("ID : [a-z]+;\n");
String grammar = sb.toString();
String found = execLexer("L.g4", grammar, "LLexer", "x : x", false);
assertEquals("[@0,0:0='x',<3>,1:0]\n" +
"[@1,2:2=':',<1>,1:2]\n" +
"[@2,4:4='x',<3>,1:4]\n" +
assertEquals("[@0,0:0='x',<3>,1:0]\n" +
"[@1,2:2=':',<1>,1:2]\n" +
"[@2,4:4='x',<3>,1:4]\n" +
"[@3,5:4='<EOF>',<-1>,1:5]\n", found);
assertEquals("line 1:1 token recognition error at: ' '\nline 1:3 token recognition error at: ' '\n", this.stderrDuringParse);
}


}
}
Loading

0 comments on commit 345bd14

Please sign in to comment.