use of antlr.CommonHiddenStreamToken in project checkstyle by checkstyle.
the class ThrowsCountCheckTest method testWrongTokenType.
@Test
public void testWrongTokenType() {
final ThrowsCountCheck obj = new ThrowsCountCheck();
final DetailAST ast = new DetailAST();
ast.initialize(new CommonHiddenStreamToken(TokenTypes.CLASS_DEF, "class"));
try {
obj.visitToken(ast);
fail("IllegalStateException is expected");
} catch (IllegalStateException ex) {
assertEquals(ast.toString(), ex.getMessage());
}
}
use of antlr.CommonHiddenStreamToken in project checkstyle by checkstyle.
the class RequireThisCheckTest method testDefaultSwitch.
@Test
public void testDefaultSwitch() {
final RequireThisCheck check = new RequireThisCheck();
final DetailAST ast = new DetailAST();
ast.initialize(new CommonHiddenStreamToken(TokenTypes.ENUM, "ENUM"));
check.visitToken(ast);
}
use of antlr.CommonHiddenStreamToken in project checkstyle by checkstyle.
the class VisibilityModifierCheckTest method testWrongTokenType.
@Test
public void testWrongTokenType() {
final VisibilityModifierCheck obj = new VisibilityModifierCheck();
final DetailAST ast = new DetailAST();
ast.initialize(new CommonHiddenStreamToken(TokenTypes.CLASS_DEF, "class"));
try {
obj.visitToken(ast);
fail("exception expected");
} catch (IllegalArgumentException ex) {
assertEquals("Unexpected token type: class", ex.getMessage());
}
}
use of antlr.CommonHiddenStreamToken in project checkstyle by checkstyle.
the class MutableExceptionCheckTest method testWrongTokenType.
@Test
public void testWrongTokenType() {
final MutableExceptionCheck obj = new MutableExceptionCheck();
final DetailAST ast = new DetailAST();
ast.initialize(new CommonHiddenStreamToken(TokenTypes.INTERFACE_DEF, "interface"));
try {
obj.visitToken(ast);
fail("IllegalStateException is expected");
} catch (IllegalStateException ex) {
//expected
}
}
use of antlr.CommonHiddenStreamToken in project checkstyle by checkstyle.
the class ExecutableStatementCountCheckTest method testVisitTokenWithWrongTokenType.
@Test
public void testVisitTokenWithWrongTokenType() {
final ExecutableStatementCountCheck checkObj = new ExecutableStatementCountCheck();
final DetailAST ast = new DetailAST();
ast.initialize(new CommonHiddenStreamToken(TokenTypes.ENUM, "ENUM"));
try {
checkObj.visitToken(ast);
fail("exception expected");
} catch (IllegalStateException ex) {
assertEquals("ENUM[0x-1]", ex.getMessage());
}
}
Aggregations