forked from jasder/antlr
Distinct error codes, added unit-test. fixes #1865.
This commit is contained in:
parent
f2ee752a58
commit
7dc17ace6e
|
@ -8,6 +8,7 @@ package org.antlr.v4.test.tool;
|
|||
|
||||
import org.antlr.v4.Tool;
|
||||
import org.antlr.v4.tool.ErrorType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -60,6 +61,16 @@ public class TestToolSyntaxErrors extends BaseJavaToolTest {
|
|||
super.testSetUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void AllErrorCodesDistinct() {
|
||||
ErrorType[] errorTypes = ErrorType.class.getEnumConstants();
|
||||
for (int i = 0; i < errorTypes.length; i++) {
|
||||
for (int j = i + 1; j < errorTypes.length; j++) {
|
||||
Assert.assertNotEquals(errorTypes[i].code, errorTypes[j].code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test public void testA() { super.testErrors(A, true); }
|
||||
|
||||
@Test public void testExtraColon() {
|
||||
|
|
|
@ -394,11 +394,11 @@ public enum ErrorType {
|
|||
*/
|
||||
IMPORT_NAME_CLASH(113, "<arg.typeString> grammar <arg.name> and imported <arg2.typeString> grammar <arg2.name> both generate <arg2.recognizerName>", ErrorSeverity.ERROR),
|
||||
/**
|
||||
* Compiler Error 160.
|
||||
* Compiler Error 114.
|
||||
*
|
||||
* <p>cannot find tokens file <em>filename</em></p>
|
||||
*/
|
||||
CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR(160, "cannot find tokens file <arg>", ErrorSeverity.ERROR),
|
||||
CANNOT_FIND_TOKENS_FILE_REFD_IN_GRAMMAR(114, "cannot find tokens file <arg>", ErrorSeverity.ERROR),
|
||||
/**
|
||||
* Compiler Warning 118.
|
||||
*
|
||||
|
@ -522,7 +522,7 @@ public enum ErrorType {
|
|||
*/
|
||||
USE_OF_BAD_WORD(134, "symbol <arg> conflicts with generated code in target language or runtime", ErrorSeverity.ERROR),
|
||||
/**
|
||||
* Compiler Error 134.
|
||||
* Compiler Error 183.
|
||||
*
|
||||
* <p>rule reference <em>rule</em> is not currently supported in a set</p>
|
||||
*
|
||||
|
@ -530,7 +530,7 @@ public enum ErrorType {
|
|||
* Note: This error has the same number as the unrelated error
|
||||
* {@link #USE_OF_BAD_WORD}.</p>
|
||||
*/
|
||||
UNSUPPORTED_REFERENCE_IN_LEXER_SET(134, "rule reference <arg> is not currently supported in a set", ErrorSeverity.ERROR),
|
||||
UNSUPPORTED_REFERENCE_IN_LEXER_SET(183, "rule reference <arg> is not currently supported in a set", ErrorSeverity.ERROR),
|
||||
/**
|
||||
* Compiler Error 135.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue