Package com.google.javascript.jscomp.jsonml

Examples of com.google.javascript.jscomp.jsonml.JsonML


    Report report = compiler.getReport();
    assertFalse(report.isSuccessful());
  }

  private void testString(String jsonml) throws Exception {
    JsonML source = JsonMLUtil.parseString(jsonml);
    testSuccess(source);
  }
View Full Code Here


    JsonML source = JsonMLUtil.parseString(jsonml);
    testSuccess(source);
  }

  private void testInvalidString(String jsonml) throws Exception {
    JsonML source = JsonMLUtil.parseString(jsonml);
    testError(source);
  }
View Full Code Here

  public void setUp() {
    enableEcmaScript5(true);
  }

  private void testJsonMLToAstConversion(String js) throws Exception {
    JsonML jsonml = JsonMLParser.parse(js);
    Node root = parseExpectedJs(js);
    Node ast = root.getFirstChild();
    Preconditions.checkState(ast.getType() == Token.SCRIPT);

    testJsonMLToAstConversion(ast, jsonml, js);
View Full Code Here

       + "\n" + explanation, explanation);
  }

  private void testAstToJsonMLConverstion(Node astRoot, JsonML jsonmlRoot,
      String js) {
    JsonML resultJsonMLRoot = (new Writer()).processAst(astRoot);
    String explanation = JsonMLUtil.compare(resultJsonMLRoot, jsonmlRoot);
    assertNull("AST -> JsonML converter returned incorrect result for " + js +
        "\n" + explanation, explanation);
  }
View Full Code Here

    assertNull("AST -> JsonML converter returned incorrect result for " + js +
        "\n" + explanation, explanation);
  }

  private void testConversion(String js) throws Exception {
    JsonML jsonml = JsonMLParser.parse(js);
    Node root = parseExpectedJs(js);
    Node ast = root.getFirstChild();
    Preconditions.checkState(ast.getType() == Token.SCRIPT);

    testJsonMLToAstConversion(ast, jsonml, js);
View Full Code Here

*/
public class JsonMLValidationTest extends TestCase {

  // Used for correct statements - error message should be null
  private void testValidation(String jsonml) throws Exception {
    JsonML jsonMLRoot = JsonMLUtil.parseString(jsonml);
    String msg = Validator.validate(jsonMLRoot);
    if (msg != null) {
      String errorMsg = String.format(
          "Validation error for %s.\n Received: %s\n", jsonml, msg);
    }
View Full Code Here

    }
  }

  private void testValidation(String jsonml, String expected)
      throws Exception {
    JsonML jsonMLRoot = JsonMLUtil.parseString(jsonml);
    String msg = Validator.validate(jsonMLRoot);
    if (!msg.equals(expected)) {
      String errorMsg = String.format(
          "Validation error for %s.\n Received: %s\n Expected: %s\n",
          jsonml, msg, expected);
View Full Code Here

  }

  private void testExpression(String js, String jsonMLGolden)
      throws ParseException {
    Expression e = jsExpr(fromString(js));
    JsonML actual = ((JsonMLCompatible) e).toJsonML();
    checkJsonML(e, actual, jsonMLGolden, Expression.class);
  }
View Full Code Here

  private void testStatement(String js, String jsonMLGolden)
      throws ParseException {
    Block bl = js(fromString(js));
    assertEquals(1, bl.children().size());
    Statement s = bl.children().get(0);
    JsonML actual = s.toJsonML();
    checkJsonML(s, actual, jsonMLGolden, Statement.class);
  }
View Full Code Here

  }

  private void testProgram(String js, String jsonMLGolden)
      throws ParseException {
    Block program = "".equals(js) ? new Block() : js(fromString(js));
    JsonML actual = program.toJsonMLAsProgram();
    checkJsonML(program, actual, jsonMLGolden, Block.class);
  }
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.jsonml.JsonML

Copyright © 2018 www.massapicom. 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.