Fix error codes in unit tests
This commit is contained in:
parent
5fd8b223b6
commit
78fcc134cd
|
@ -24,8 +24,8 @@ public class TestAttributeChecks extends BaseTest {
|
|||
"d : ;\n";
|
||||
|
||||
String[] membersChecks = {
|
||||
"$a", "error(29): A.g4:2:11: unknown attribute reference a in $a\n",
|
||||
"$a.y", "error(29): A.g4:2:11: unknown attribute reference a in $a.y\n",
|
||||
"$a", "error(63): A.g4:2:11: unknown attribute reference a in $a\n",
|
||||
"$a.y", "error(63): A.g4:2:11: unknown attribute reference a in $a.y\n",
|
||||
};
|
||||
|
||||
String[] initChecks = {
|
||||
|
@ -36,8 +36,8 @@ public class TestAttributeChecks extends BaseTest {
|
|||
"$lab.e", "",
|
||||
"$ids", "",
|
||||
|
||||
"$c", "error(29): A.g4:4:8: unknown attribute reference c in $c\n",
|
||||
"$a.q", "error(31): A.g4:4:10: unknown attribute q for rule a in $a.q\n",
|
||||
"$c", "error(63): A.g4:4:8: unknown attribute reference c in $c\n",
|
||||
"$a.q", "error(65): A.g4:4:10: unknown attribute q for rule a in $a.q\n",
|
||||
};
|
||||
|
||||
String[] inlineChecks = {
|
||||
|
@ -58,19 +58,19 @@ public class TestAttributeChecks extends BaseTest {
|
|||
};
|
||||
|
||||
String[] bad_inlineChecks = {
|
||||
"$lab", "error(33): A.g4:6:4: missing attribute access on rule reference lab in $lab\n",
|
||||
"$q", "error(29): A.g4:6:4: unknown attribute reference q in $q\n",
|
||||
"$q.y", "error(29): A.g4:6:4: unknown attribute reference q in $q.y\n",
|
||||
"$q = 3", "error(29): A.g4:6:4: unknown attribute reference q in $q\n",
|
||||
"$q = 3;", "error(29): A.g4:6:4: unknown attribute reference q in $q = 3;\n",
|
||||
"$q.y = 3;", "error(29): A.g4:6:4: unknown attribute reference q in $q.y = 3;\n",
|
||||
"$q = $blort;", "error(29): A.g4:6:4: unknown attribute reference q in $q = $blort;\n" +
|
||||
"error(29): A.g4:6:9: unknown attribute reference blort in $blort\n",
|
||||
"$a.ick", "error(31): A.g4:6:6: unknown attribute ick for rule a in $a.ick\n",
|
||||
"$a.ick = 3;", "error(31): A.g4:6:6: unknown attribute ick for rule a in $a.ick = 3;\n",
|
||||
"$b.d", "error(30): A.g4:6:6: cannot access rule d's parameter: $b.d\n", // can't see rule ref's arg
|
||||
"$d.text", "error(29): A.g4:6:4: unknown attribute reference d in $d.text\n", // valid rule, but no ref
|
||||
"$lab.d", "error(30): A.g4:6:8: cannot access rule d's parameter: $lab.d\n",
|
||||
"$lab", "error(67): A.g4:6:4: missing attribute access on rule reference lab in $lab\n",
|
||||
"$q", "error(63): A.g4:6:4: unknown attribute reference q in $q\n",
|
||||
"$q.y", "error(63): A.g4:6:4: unknown attribute reference q in $q.y\n",
|
||||
"$q = 3", "error(63): A.g4:6:4: unknown attribute reference q in $q\n",
|
||||
"$q = 3;", "error(63): A.g4:6:4: unknown attribute reference q in $q = 3;\n",
|
||||
"$q.y = 3;", "error(63): A.g4:6:4: unknown attribute reference q in $q.y = 3;\n",
|
||||
"$q = $blort;", "error(63): A.g4:6:4: unknown attribute reference q in $q = $blort;\n" +
|
||||
"error(63): A.g4:6:9: unknown attribute reference blort in $blort\n",
|
||||
"$a.ick", "error(65): A.g4:6:6: unknown attribute ick for rule a in $a.ick\n",
|
||||
"$a.ick = 3;", "error(65): A.g4:6:6: unknown attribute ick for rule a in $a.ick = 3;\n",
|
||||
"$b.d", "error(64): A.g4:6:6: cannot access rule d's parameter: $b.d\n", // can't see rule ref's arg
|
||||
"$d.text", "error(63): A.g4:6:4: unknown attribute reference d in $d.text\n", // valid rule, but no ref
|
||||
"$lab.d", "error(64): A.g4:6:8: cannot access rule d's parameter: $lab.d\n",
|
||||
};
|
||||
|
||||
String[] finallyChecks = {
|
||||
|
@ -84,20 +84,20 @@ public class TestAttributeChecks extends BaseTest {
|
|||
"$id.text", "",
|
||||
"$ids", "",
|
||||
|
||||
"$lab", "error(33): A.g4:9:14: missing attribute access on rule reference lab in $lab\n",
|
||||
"$q", "error(29): A.g4:9:14: unknown attribute reference q in $q\n",
|
||||
"$q.y", "error(29): A.g4:9:14: unknown attribute reference q in $q.y\n",
|
||||
"$q = 3", "error(29): A.g4:9:14: unknown attribute reference q in $q\n",
|
||||
"$q = 3;", "error(29): A.g4:9:14: unknown attribute reference q in $q = 3;\n",
|
||||
"$q.y = 3;", "error(29): A.g4:9:14: unknown attribute reference q in $q.y = 3;\n",
|
||||
"$q = $blort;", "error(29): A.g4:9:14: unknown attribute reference q in $q = $blort;\n" +
|
||||
"error(29): A.g4:9:19: unknown attribute reference blort in $blort\n",
|
||||
"$a.ick", "error(31): A.g4:9:16: unknown attribute ick for rule a in $a.ick\n",
|
||||
"$a.ick = 3;", "error(31): A.g4:9:16: unknown attribute ick for rule a in $a.ick = 3;\n",
|
||||
"$b.e", "error(29): A.g4:9:14: unknown attribute reference b in $b.e\n", // can't see rule refs outside alts
|
||||
"$b.d", "error(29): A.g4:9:14: unknown attribute reference b in $b.d\n",
|
||||
"$c.text", "error(29): A.g4:9:14: unknown attribute reference c in $c.text\n",
|
||||
"$lab.d", "error(30): A.g4:9:18: cannot access rule d's parameter: $lab.d\n",
|
||||
"$lab", "error(67): A.g4:9:14: missing attribute access on rule reference lab in $lab\n",
|
||||
"$q", "error(63): A.g4:9:14: unknown attribute reference q in $q\n",
|
||||
"$q.y", "error(63): A.g4:9:14: unknown attribute reference q in $q.y\n",
|
||||
"$q = 3", "error(63): A.g4:9:14: unknown attribute reference q in $q\n",
|
||||
"$q = 3;", "error(63): A.g4:9:14: unknown attribute reference q in $q = 3;\n",
|
||||
"$q.y = 3;", "error(63): A.g4:9:14: unknown attribute reference q in $q.y = 3;\n",
|
||||
"$q = $blort;", "error(63): A.g4:9:14: unknown attribute reference q in $q = $blort;\n" +
|
||||
"error(63): A.g4:9:19: unknown attribute reference blort in $blort\n",
|
||||
"$a.ick", "error(65): A.g4:9:16: unknown attribute ick for rule a in $a.ick\n",
|
||||
"$a.ick = 3;", "error(65): A.g4:9:16: unknown attribute ick for rule a in $a.ick = 3;\n",
|
||||
"$b.e", "error(63): A.g4:9:14: unknown attribute reference b in $b.e\n", // can't see rule refs outside alts
|
||||
"$b.d", "error(63): A.g4:9:14: unknown attribute reference b in $b.d\n",
|
||||
"$c.text", "error(63): A.g4:9:14: unknown attribute reference c in $c.text\n",
|
||||
"$lab.d", "error(64): A.g4:9:18: cannot access rule d's parameter: $lab.d\n",
|
||||
};
|
||||
|
||||
String[] dynMembersChecks = {
|
||||
|
|
|
@ -50,18 +50,18 @@ public class TestBasicSemanticErrors extends BaseTest {
|
|||
"b : ( options { ick=bar; greedy=true; } : ID )+ ;\n" +
|
||||
"c : ID<blue> ID<x=y> ;",
|
||||
// YIELDS
|
||||
"warning(48): U.g4:2:10: illegal option foo\n" +
|
||||
"warning(48): U.g4:2:19: illegal option k\n" +
|
||||
"error(26): U.g4:4:8: token names must start with an uppercase letter: f\n" +
|
||||
"error(25): U.g4:4:8: can't assign string value to token name f in non-combined grammar\n" +
|
||||
"error(25): U.g4:5:8: can't assign string value to token name S in non-combined grammar\n" +
|
||||
"warning(48): U.g4:8:10: illegal option x\n" +
|
||||
"error(20): U.g4:8:0: repeated grammar prequel spec (option, token, or import); please merge\n" +
|
||||
"error(20): U.g4:7:0: repeated grammar prequel spec (option, token, or import); please merge\n" +
|
||||
"warning(48): U.g4:11:10: illegal option blech\n" +
|
||||
"warning(48): U.g4:11:21: illegal option greedy\n" +
|
||||
"warning(48): U.g4:14:16: illegal option ick\n" +
|
||||
"warning(48): U.g4:15:16: illegal option x\n",
|
||||
"warning(83): U.g4:2:10: illegal option foo\n" +
|
||||
"warning(83): U.g4:2:19: illegal option k\n" +
|
||||
"error(60): U.g4:4:8: token names must start with an uppercase letter: f\n" +
|
||||
"error(59): U.g4:4:8: can't assign string value to token name f in non-combined grammar\n" +
|
||||
"error(59): U.g4:5:8: can't assign string value to token name S in non-combined grammar\n" +
|
||||
"warning(83): U.g4:8:10: illegal option x\n" +
|
||||
"error(54): U.g4:8:0: repeated grammar prequel spec (option, token, or import); please merge\n" +
|
||||
"error(54): U.g4:7:0: repeated grammar prequel spec (option, token, or import); please merge\n" +
|
||||
"warning(83): U.g4:11:10: illegal option blech\n" +
|
||||
"warning(83): U.g4:11:21: illegal option greedy\n" +
|
||||
"warning(83): U.g4:14:16: illegal option ick\n" +
|
||||
"warning(83): U.g4:15:16: illegal option x\n",
|
||||
};
|
||||
|
||||
@Test public void testU() { super.testErrors(U, false); }
|
||||
|
|
|
@ -20,9 +20,9 @@ public class TestSymbolIssues extends BaseTest {
|
|||
"\n" +
|
||||
"ID : 'a'..'z'+ ID ;",
|
||||
// YIELDS
|
||||
"warning(48): A.g4:2:10: illegal option opt\n" +
|
||||
"warning(48): A.g4:2:21: illegal option k\n" +
|
||||
"error(59): A.g4:7:1: redefinition of header action\n" +
|
||||
"warning(83): A.g4:2:10: illegal option opt\n" +
|
||||
"warning(83): A.g4:2:21: illegal option k\n" +
|
||||
"error(94): A.g4:7:1: redefinition of header action\n" +
|
||||
"warning(51): A.g4:2:10: illegal option opt\n" +
|
||||
"error(19): A.g4:11:0: rule a redefinition\n" +
|
||||
"error(60): A.g4:5:1: redefinition of members action\n" +
|
||||
|
@ -42,11 +42,11 @@ public class TestSymbolIssues extends BaseTest {
|
|||
"\n" +
|
||||
"s : FOO ;",
|
||||
// YIELDS
|
||||
"error(25): B.g4:2:9: can't assign string value to token name X in non-combined grammar\n" +
|
||||
"error(35): B.g4:4:4: label s conflicts with rule with same name\n" +
|
||||
"error(35): B.g4:4:9: label b conflicts with rule with same name\n" +
|
||||
"error(36): B.g4:4:15: label X conflicts with token with same name\n" +
|
||||
"error(40): B.g4:6:9: label x type mismatch with previous definition: TOKEN_LIST_LABEL!=TOKEN_LABEL\n"
|
||||
"error(59): B.g4:2:9: can't assign string value to token name X in non-combined grammar\n" +
|
||||
"error(69): B.g4:4:4: label s conflicts with rule with same name\n" +
|
||||
"error(69): B.g4:4:9: label b conflicts with rule with same name\n" +
|
||||
"error(70): B.g4:4:15: label X conflicts with token with same name\n" +
|
||||
"error(75): B.g4:6:9: label x type mismatch with previous definition: TOKEN_LIST_LABEL!=TOKEN_LABEL\n"
|
||||
};
|
||||
|
||||
static String[] D = {
|
||||
|
@ -61,8 +61,8 @@ public class TestSymbolIssues extends BaseTest {
|
|||
" : ID ;",
|
||||
|
||||
// YIELDS
|
||||
"error(37): D.g4:3:21: label j conflicts with rule a's return value or parameter with same name\n" +
|
||||
"error(41): D.g4:5:0: rule b's argument i conflicts a return value with same name\n"
|
||||
"error(72): D.g4:3:21: label j conflicts with rule a's return value or parameter with same name\n" +
|
||||
"error(76): D.g4:5:0: rule b's argument i conflicts a return value with same name\n"
|
||||
};
|
||||
|
||||
static String[] E = {
|
||||
|
@ -78,10 +78,10 @@ public class TestSymbolIssues extends BaseTest {
|
|||
"a : A ;\n",
|
||||
|
||||
// YIELDS
|
||||
"error(73): E.g4:4:8: cannot redefine B; token name already defined\n" +
|
||||
"error(73): E.g4:5:4: cannot redefine C; token name already defined\n" +
|
||||
"error(73): E.g4:6:8: cannot redefine D; token name already defined\n" +
|
||||
"error(72): E.g4:7:8: cannot alias X='e'; string already assigned to E\n"
|
||||
"error(108): E.g4:4:8: cannot redefine B; token name already defined\n" +
|
||||
"error(108): E.g4:5:4: cannot redefine C; token name already defined\n" +
|
||||
"error(108): E.g4:6:8: cannot redefine D; token name already defined\n" +
|
||||
"error(107): E.g4:7:8: cannot alias X='e'; string already assigned to E\n"
|
||||
};
|
||||
|
||||
@Test public void testA() { super.testErrors(A, false); }
|
||||
|
|
|
@ -8,37 +8,37 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"grammar A;\n" +
|
||||
"",
|
||||
// YIELDS
|
||||
"error(64): A.g4::: grammar A has no rules\n",
|
||||
"error(99): A.g4::: grammar A has no rules\n",
|
||||
|
||||
"A;",
|
||||
"error(16): <string>:1:0: 'A' came as a complete surprise to me\n",
|
||||
"error(50): <string>:1:0: 'A' came as a complete surprise to me\n",
|
||||
|
||||
"grammar ;",
|
||||
"error(16): <string>:1:8: ';' came as a complete surprise to me while looking for an identifier\n",
|
||||
"error(50): <string>:1:8: ';' came as a complete surprise to me while looking for an identifier\n",
|
||||
|
||||
"grammar A\n" +
|
||||
"a : ID ;\n",
|
||||
"error(16): <string>:2:0: missing SEMI at 'a'\n",
|
||||
"error(50): <string>:2:0: missing SEMI at 'a'\n",
|
||||
|
||||
"grammar A;\n" +
|
||||
"a : ID ;;\n"+
|
||||
"b : B ;",
|
||||
"error(16): A.g4:2:8: ';' came as a complete surprise to me\n",
|
||||
"error(50): A.g4:2:8: ';' came as a complete surprise to me\n",
|
||||
|
||||
"grammar A;;\n" +
|
||||
"a : ID ;\n",
|
||||
"error(16): A;.g4:1:10: ';' came as a complete surprise to me\n",
|
||||
"error(50): A;.g4:1:10: ';' came as a complete surprise to me\n",
|
||||
|
||||
"grammar A;\n" +
|
||||
"a @init : ID ;\n",
|
||||
"error(16): A.g4:2:8: mismatched input ':' expecting ACTION while matching rule preamble\n",
|
||||
"error(50): A.g4:2:8: mismatched input ':' expecting ACTION while matching rule preamble\n",
|
||||
|
||||
"grammar A;\n" +
|
||||
"a ( A | B ) D ;\n" +
|
||||
"b : B ;",
|
||||
"error(16): A.g4:2:3: '(' came as a complete surprise to me while matching rule preamble\n" +
|
||||
"error(16): A.g4:2:11: mismatched input ')' expecting SEMI while matching a rule\n" +
|
||||
"error(16): A.g4:2:15: mismatched input ';' expecting COLON while matching a lexer rule\n",
|
||||
"error(50): A.g4:2:3: '(' came as a complete surprise to me while matching rule preamble\n" +
|
||||
"error(50): A.g4:2:11: mismatched input ')' expecting SEMI while matching a rule\n" +
|
||||
"error(50): A.g4:2:15: mismatched input ';' expecting COLON while matching a lexer rule\n",
|
||||
};
|
||||
|
||||
@Test public void testA() { super.testErrors(A, true); }
|
||||
|
@ -48,7 +48,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"grammar A;\n" +
|
||||
"a : : A ;\n" +
|
||||
"b : B ;",
|
||||
"error(16): A.g4:2:4: ':' came as a complete surprise to me while matching alternative\n",
|
||||
"error(50): A.g4:2:4: ':' came as a complete surprise to me while matching alternative\n",
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"grammar A;\n" +
|
||||
"a : A \n" +
|
||||
"b : B ;",
|
||||
"error(16): A.g4:3:0: unterminated rule (missing ';') detected at 'b :' while looking for rule element\n",
|
||||
"error(50): A.g4:3:0: unterminated rule (missing ';') detected at 'b :' while looking for rule element\n",
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"lexer grammar A;\n" +
|
||||
"A : 'a' \n" +
|
||||
"B : 'b' ;",
|
||||
"error(16): A.g4:3:0: unterminated rule (missing ';') detected at 'B :' while looking for lexer rule element\n",
|
||||
"error(50): A.g4:3:0: unterminated rule (missing ';') detected at 'B :' while looking for lexer rule element\n",
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"grammar A;\n" +
|
||||
"a : A \n" +
|
||||
"b[int i] returns [int y] : B ;",
|
||||
"error(16): A.g4:3:9: unterminated rule (missing ';') detected at 'returns int y' while looking for rule element\n"
|
||||
"error(50): A.g4:3:9: unterminated rule (missing ';') detected at 'returns int y' while looking for rule element\n"
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
" catch [Exception e] {...}\n" +
|
||||
"b : B ;\n",
|
||||
|
||||
"error(16): A.g4:2:4: unterminated rule (missing ';') detected at 'b catch' while looking for rule element\n"
|
||||
"error(50): A.g4:2:4: unterminated rule (missing ';') detected at 'b catch' while looking for rule element\n"
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"a : A \n" +
|
||||
" catch [Exception e] {...}\n",
|
||||
|
||||
"error(16): A.g4:2:4: unterminated rule (missing ';') detected at 'A catch' while looking for rule element\n"
|
||||
"error(50): A.g4:2:4: unterminated rule (missing ';') detected at 'A catch' while looking for rule element\n"
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"a @ options {k=1;} : A ;\n" +
|
||||
"b : B ;",
|
||||
|
||||
"error(16): A.g4:2:4: 'options {' came as a complete surprise to me while looking for an identifier\n"
|
||||
"error(50): A.g4:2:4: 'options {' came as a complete surprise to me while looking for an identifier\n"
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"a } : A ;\n" +
|
||||
"b : B ;",
|
||||
|
||||
"error(16): A.g4:2:2: '}' came as a complete surprise to me while matching rule preamble\n"
|
||||
"error(50): A.g4:2:2: '}' came as a complete surprise to me while matching rule preamble\n"
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ public class TestToolSyntaxErrors extends BaseTest {
|
|||
"mode foo;\n" +
|
||||
"b : B ;",
|
||||
|
||||
"error(16): A.g4:4:0: 'b' came as a complete surprise to me\n" +
|
||||
"error(16): A.g4:4:6: mismatched input ';' expecting COLON while matching a lexer rule\n"
|
||||
"error(50): A.g4:4:0: 'b' came as a complete surprise to me\n" +
|
||||
"error(50): A.g4:4:6: mismatched input ';' expecting COLON while matching a lexer rule\n"
|
||||
};
|
||||
super.testErrors(pair, true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue