fix unit tests

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9816]
This commit is contained in:
parrt 2012-01-04 15:47:52 -08:00
parent b2269a22f4
commit e29b11882d
3 changed files with 18 additions and 16 deletions

View File

@ -195,7 +195,7 @@ public class TestNonGreedyLoops extends BaseTest {
"\n" +
"Decision 1:\n" +
"s0-INT->:s1=>2\n", found); // resolves INT EOF to alt 1 from s since ambig 'tween a and b
assertEquals("line 1:2 reportAmbiguity d=0: {1..2}:[(1,1,[]), (1,2,[])],conflictingAlts={1..2}, input=34\n" +
assertEquals("line 1:2 reportAmbiguity d=0: ambigAlts={1..2}:[(1,1,[]), (1,2,[])],conflictingAlts={1..2}, input='34'\n" +
"line 1:0 extraneous input '34' expecting <EOF>\n",
this.stderrDuringParse);
}
@ -516,8 +516,8 @@ public class TestNonGreedyLoops extends BaseTest {
"s1-ID->s2\n" +
"s2-'>'->s3\n" +
"s2-ID->s2\n" +
"s3-EOF->:s6=>1\n" +
"s3-'<'->:s4=>1\n" +
"s3-EOF->s6^\n" +
"s3-'<'->s4^\n" +
"s3-ID->s3\n" +
"\n" +
"Decision 2:\n" +
@ -527,9 +527,11 @@ public class TestNonGreedyLoops extends BaseTest {
"Decision 3:\n" +
"s0-'>'->:s2=>2\n" +
"s0-ID->:s1=>1\n", found);
assertEquals("line 1:6 reportAmbiguity d=1: {1..2}:[(26,1,[14 6]), (33,1,[14 6]), (22,1,[14 6]), (20,1,[14 6]), (16,1,[6]), (1,1,[]), (22,2,[14 6]), (26,2,[14 6]), (33,2,[14 6]), (20,2,[14 6]), (16,2,[6]), (1,2,[])],conflictingAlts={1..2}, input=<a>foo<\n" +
"line 1:10 reportAmbiguity d=1: {1..2}:[(35,1,[]), (35,2,[])],conflictingAlts={1..2}, input=</a>\n" +
"line 1:7 reportAmbiguity d=2: {1..2}:[(26,1,[14 6]), (33,1,[14 6]), (26,2,[14 6]), (33,2,[14 6])],conflictingAlts={1..2}, input=/\n",
assertEquals("line 1:6 reportAttemptingFullContext d=1: [(20,1,[14 6]), (16,2,[6])], input='<a>foo<'\n" +
"line 1:6 reportAmbiguity d=1: ambigAlts={1..2}:[(26,1,[32 32 32 32 14 6]), (33,1,[14 6]), (22,1,[14 6 10 10]), (26,1,[14 6 10 10]), (33,1,[14 6 10 10]), (20,1,[14 6 10 10 10]), (16,1,[6 10 10 10]), (1,1,[]), (22,2,[14 6 10 10 10 10]), (26,2,[14 6 10 10 10 10]), (33,2,[14 6 10 10 10 10]), (20,2,[14 6 10 10 10 10 10]), (16,2,[6 10 10 10 10 10]), (1,2,[])],conflictingAlts={1..2}, input='<a>foo<'\n" +
"line 1:10 reportAttemptingFullContext d=1: [(20,1,[14 6]), (16,2,[6])], input='</a>'\n" +
"line 1:10 reportAmbiguity d=1: ambigAlts={1..2}:[(35,1,[]), (35,2,[])],conflictingAlts={1..2}, input='</a>'\n" +
"line 1:7 reportAmbiguity d=2: ambigAlts={1..2}:[(26,1,[]), (33,1,[]), (26,2,[]), (33,2,[])],conflictingAlts={1..2}, input='/'\n",
this.stderrDuringParse);
found = execParser("T.g", grammar, "TParser", "TLexer", "s",
@ -545,8 +547,8 @@ public class TestNonGreedyLoops extends BaseTest {
"s1-ID->s2\n" +
"s2-'>'->s3\n" +
"s2-ID->s2\n" +
"s3-EOF->:s5=>1\n" +
"s3-'<'->:s4=>1\n" +
"s3-EOF->s5^\n" +
"s3-'<'->s4^\n" +
"\n" +
"Decision 2:\n" +
"s0-'/'->:s2=>1\n" +
@ -572,8 +574,8 @@ public class TestNonGreedyLoops extends BaseTest {
"s2-ID->s2\n" +
"s2-STR->s2\n" +
"s2-INT->s2\n" +
"s3-EOF->:s5=>1\n" +
"s3-'<'->:s4=>1\n" +
"s3-EOF->s5^\n" +
"s3-'<'->s4^\n" +
"\n" +
"Decision 2:\n" +
"s0-'/'->:s1=>1\n" +

View File

@ -77,7 +77,7 @@ public class TestParseErrors extends BaseTest {
"grammar T;\n" +
"a : 'a' x='b' {System.out.println(\"conjured=\"+$x);} 'c' ;";
String result = execParser("T.g", grammar, "TParser", "TLexer", "a", "ac", false);
String expecting = "conjured=[@-1,0:0='<missing 'b'>',<3>,1:1]\n";
String expecting = "conjured=[@-1,-1:-1='<missing 'b'>',<3>,1:1]\n";
assertEquals(expecting, result);
}
@ -96,7 +96,7 @@ public class TestParseErrors extends BaseTest {
"grammar T;\n" +
"a : 'a' x=('b'|'c') {System.out.println(\"conjured=\"+$x);} 'd' ;";
String result = execParser("T.g", grammar, "TParser", "TLexer", "a", "ad", false);
String expecting = "conjured=[@-1,0:0='<missing 'b'>',<3>,1:1]\n";
String expecting = "conjured=[@-1,-1:-1='<missing 'b'>',<3>,1:1]\n";
assertEquals(expecting, result);
}

View File

@ -155,7 +155,7 @@ public class TestSemPredEvalParser extends BaseTest {
"alt 1\n" +
"alt 1\n";
assertEquals(expecting, found);
assertEquals("line 1:0 reportInsufficientPredicates d=0: {1..3}:[{-1:-1}?, {-1:-1}?, {-1:-1}?, {1:0}?], [(6,1,[],up=1), (1,1,[],up=1), (6,2,[],up=1), (1,2,[],up=1), (6,3,[],{1:0}?,up=1), (1,3,[],{1:0}?,up=1)],hasSemanticContext=true,conflictingAlts={1..3},dipsIntoOuterContext, input=x\n",
assertEquals("line 1:0 reportInsufficientPredicates d=0, decState=24, ambigAlts={1..3}:[{-1:-1}?, {-1:-1}?, {-1:-1}?, {1:0}?], [(6,1,[],up=1), (1,1,[],up=1), (6,2,[],up=1), (1,2,[],up=1), (6,3,[],{1:0}?,up=1), (1,3,[],{1:0}?,up=1)],hasSemanticContext=true,conflictingAlts={1..3},dipsIntoOuterContext, input='x'\n",
this.stderrDuringParse);
}
@ -186,7 +186,7 @@ public class TestSemPredEvalParser extends BaseTest {
"alt 2\n" +
"alt 2\n";
assertEquals(expecting, found);
assertEquals("line 1:4 reportInsufficientPredicates d=0: {2..4}:[{-1:-1}?, {-1:-1}?, {-1:-1}?, {-1:-1}?, {1:0}?], [(6,2,[],up=1), (10,2,[],up=1), (1,2,[],up=1), (6,3,[],up=1), (10,3,[],up=1), (1,3,[],up=1), (6,4,[],{1:0}?,up=1), (10,4,[],{1:0}?,up=1), (1,4,[],{1:0}?,up=1)],hasSemanticContext=true,conflictingAlts={2..4},dipsIntoOuterContext, input=x\n",
assertEquals("line 1:4 reportInsufficientPredicates d=0, decState=32, ambigAlts={2..4}:[{-1:-1}?, {-1:-1}?, {-1:-1}?, {-1:-1}?, {1:0}?], [(6,2,[],up=1), (10,2,[],up=1), (1,2,[],up=1), (6,3,[],up=1), (10,3,[],up=1), (1,3,[],up=1), (6,4,[],{1:0}?,up=1), (10,4,[],{1:0}?,up=1), (1,4,[],{1:0}?,up=1)],hasSemanticContext=true,conflictingAlts={2..4},dipsIntoOuterContext, input='x'\n",
this.stderrDuringParse);
}
@ -284,8 +284,8 @@ public class TestSemPredEvalParser extends BaseTest {
"grammar T;\n" +
"@members {int i=0;}\n" +
"s : ({i++; System.out.println(\"i=\"+i);} a)+ ;\n" +
"a : {i \\% 2 == 0}? ID {System.out.println(\"alt 1\");}\n" +
" | {i \\% 2 != 0}? ID {System.out.println(\"alt 2\");}\n" +
"a : {i % 2 == 0}? ID {System.out.println(\"alt 1\");}\n" +
" | {i % 2 != 0}? ID {System.out.println(\"alt 2\");}\n" +
" ;\n" +
"ID : 'a'..'z'+ ;\n" +
"INT : '0'..'9'+;\n" +