Exemplo n.º 1
0
  @Test
  @Category({P2, UNIT, FAST})
  @Ignore("jsdoc comments are not working correctly")
  @Description("Test generated js matches gold file.")
  public void testFormattingComments() throws IOException {
    //		File jsFile = new File(
    //				ResourceUtil.getResource(this.getClass(), "FormattingTest2.js.txt").getFile());
    //
    //		FileInputStream fis = new FileInputStream(jsFile);
    //		String goldString = FileUtils.readStream(fis);
    URL jsFile = ResourceUtil.getResource(this.getClass(), "FormattingTest2.js.txt");
    String goldString = JsPreGenHelper.url2String(jsFile);
    IJstType type =
        new VjoParser()
            .addLib(LibManager.getInstance().getJsNativeGlobalLib())
            .parse(null, jsFile)
            .getType();

    GeneratorCtx ctx = new GeneratorCtx(CodeStyle.PRETTY);
    ctx.setNewline(TestHelper.NEWLINE);
    ctx.getConfig().setAddCodeGenAnnotation(true);
    VjoGenerator writer = new VjoGenerator(ctx);
    writer.setNewline(TestHelper.NEWLINE);
    writer.writeVjo(type);
    String generatedVjo = writer.getGeneratedText();

    assertEquals(goldString, generatedVjo);
  }
Exemplo n.º 2
0
  @Test
  @Category({P3, UNIT, FAST})
  @Description("Correct parsing spaces in comments")
  public void testSpaceComment() throws Exception {

    String name = "vjospacecomment.txt";
    String file = FileUtils.getResourceAsString(ParsingTests.class, name);
    VjoParser p = new VjoParser();
    p.addLib(LibManager.getInstance().getJavaPrimitiveLib());
    p.addLib(LibManager.getInstance().getJsNativeGlobalLib());
    p.addLib(LibManager.getInstance().getBrowserTypesLib());

    IJstParseController c = new JstParseController(p);

    IJstType type = c.parse(name, name, file).getType();
    ParseUtils.printTree(type);
  }
Exemplo n.º 3
0
  @Test
  @Category({P1, UNIT, FAST})
  @Description("Parses and validates property declared public and final")
  public void testPublicFinal() throws Exception {

    String name = "vjopublicfinal.txt";
    String file = FileUtils.getResourceAsString(ParsingTests.class, name);
    VjoParser p = new VjoParser();
    p.addLib(LibManager.getInstance().getJavaPrimitiveLib());
    p.addLib(LibManager.getInstance().getJsNativeGlobalLib());
    p.addLib(LibManager.getInstance().getBrowserTypesLib());

    IJstParseController c = new JstParseController(p);

    IJstType type = c.parse(name, name, file).getType();
    ParseUtils.printTree(type);
  }