Exemple #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);
  }
Exemple #2
0
  protected String gentype(JstType type) {

    VjoGenerator writer = m_generatorCtx.getProvider().getTypeGenerator();
    writer.writeVjo(type);
    logTime("Gen type");

    return writer.getGeneratedText();
  }