Examples of Antlr4Validator


Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    EList<PrequelConstruct> prequels = new BasicEList<PrequelConstruct>();

    Grammar grammar = createMock(Grammar.class);
    GrammarAction action1 = createMock(GrammarAction.class);
    GrammarAction action2 = createMock(GrammarAction.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getPrequels()).andReturn(prequels);

    expect(action1.getScope()).andReturn("lexer");
    expect(action1.getName()).andReturn("header");

    expect(action2.getScope()).andReturn("parser");
    expect(action2.getName()).andReturn("header");

    prequels.add(action1);
    prequels.add(action2);

    Object[] mocks = {grammar, validator, action1, action2 };

    replay(mocks);

    validator.checkActionRedefinition(grammar);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    Object[] mocks = {grammar, rule1, returns, locals, ruleBody, actionElement };

    replay(mocks);

    new Antlr4Validator().checkUnknownAttribute(grammar);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    String[] commands = {"skip", "more", "popMode", "type", "channel", "mode", "pushMode" };
    for (String comamndName : commands) {
      LexerCommand command = createMock(LexerCommand.class);
      expect(command.getName()).andReturn(comamndName);

      Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

      Object[] mocks = {command, validator };

      replay(mocks);

      validator.unsupported(command);

      verify(mocks);
    }
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    LexerCommand command = createMock(LexerCommand.class);
    expect(command.getName()).andReturn(commandName);
    expect(command.getArgs()).andReturn(null);
    expect(command.eClass()).andReturn(eClass);

    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    PowerMock.expectPrivate(validator, "error", "missing argument for lexer command '"
        + commandName + "' ", command, feature);

    Object[] mocks = {command, eClass, feature, validator };

    replay(mocks);

    validator.missingArgument(command);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    LexerCommand command = createMock(LexerCommand.class);
    expect(command.getName()).andReturn(commandName);
    expect(command.getArgs()).andReturn(args);
    expect(command.eClass()).andReturn(eClass);

    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    PowerMock.expectPrivate(validator, "error", "lexer command '" + commandName
        + "' does not take any arguments", command, feature);

    Object[] mocks = {command, eClass, feature, args, validator };

    replay(mocks);

    validator.noArgument(command);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    RuleRef ruleRef = createMock(RuleRef.class);
    ParserRule expr = createMock(ParserRule.class);
    ActionElement actionElement = createMock(ActionElement.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(null);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(null);

    expect(locals.getBody()).andReturn(null);

    ruleBodyList.add(ruleRef);
    ruleBodyList.add(actionElement);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(ruleRef.getReference()).andReturn(expr);

    expect(expr.getName()).andReturn("expr");

    expect(actionElement.getBody()).andReturn("{int v = $expr.v;}");

    rules.add(rule1);

    Object[] mocks = {grammar, validator, rule1, returns, locals, ruleBody, actionElement,
        ruleRef, expr };

    replay(mocks);

    validator.checkUnknownAttribute(grammar);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    ParserRule rule1 = createMock(ParserRule.class);
    Return returns = createMock(Return.class);
    LocalVars locals = createMock(LocalVars.class);
    RuleBlock ruleBody = createMock(RuleBlock.class);
    ActionElement actionElement = createMock(ActionElement.class);
    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    expect(grammar.getRules()).andReturn(rules);

    expect(rule1.getArgs()).andReturn(null);
    expect(rule1.getReturn()).andReturn(returns);
    expect(rule1.getLocals()).andReturn(locals);
    expect(rule1.getBody()).andReturn(ruleBody).times(2);

    expect(returns.getBody()).andReturn(null);

    expect(locals.getBody()).andReturn(null);

    ruleBodyList.add(actionElement);

    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));
    expect(ruleBody.eAllContents()).andReturn(newTreeIterator(ruleBodyList));

    expect(actionElement.getBody()).andReturn("{int v = $expr.v;}");

    PowerMock.expectPrivate(validator, "error", "unknown attribute reference 'expr' in '$expr'",
        actionElement, 9, 5);

    rules.add(rule1);

    Object[] mocks = {grammar, validator, rule1, returns, locals, ruleBody, actionElement };

    replay(mocks);

    validator.checkUnknownAttribute(grammar);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    LexerCommand command = createMock(LexerCommand.class);
    expect(command.getArgs()).andReturn(args);
    expect(command.eContainer()).andReturn(rule);

    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    Object[] mocks = {rule, command, args, ref, validator };

    replay(mocks);

    validator.commandWithUnrecognizedConstantValue(command);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    LexerCommand command = createMock(LexerCommand.class);
    expect(command.getArgs()).andReturn(args);
    expect(command.eContainer()).andReturn(rule);

    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "error");

    Object[] mocks = {rule, command, args, ref, validator };

    replay(mocks);

    validator.commandWithUnrecognizedConstantValue(command);

    verify(mocks);
  }
View Full Code Here

Examples of com.github.jknack.antlr4ide.validation.Antlr4Validator

    LexerCommand command = createMock(LexerCommand.class);
    expect(command.getArgs()).andReturn(args);
    expect(command.eContainer()).andReturn(rule);

    Antlr4Validator validator = PowerMock.createPartialMock(Antlr4Validator.class, "warning");

    PowerMock.expectPrivate(validator, "warning",
        "rule 'RULE' contains a lexer command with an unrecognized " +
            "constant value; lexer interpreters may produce incorrect output",
        args, feature);

    Object[] mocks = {rule, command, args, ref, eClass, feature, validator };

    replay(mocks);

    validator.commandWithUnrecognizedConstantValue(command);

    verify(mocks);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.