@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); }
protected String gentype(JstType type) { VjoGenerator writer = m_generatorCtx.getProvider().getTypeGenerator(); writer.writeVjo(type); logTime("Gen type"); return writer.getGeneratedText(); }
public String toVjo(final JstType type, CodeStyle style) { if (type == null) { return null; } m_generatorCtx.setStyle(style); String buffer = gentype(type); logCode( "\n============================== type ===============================\n" + buffer + "\n------------------------------------------------------------------"); return buffer.toString(); }
// // Constructor // public TestHelper(Class javaClass, final ITranslationInitializer initializer) { m_initializer = initializer; m_javaCls = javaClass; m_generatorCtx = new GeneratorCtx(CodeStyle.PRETTY); m_generatorCtx.setNewline(NEWLINE); }