use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testReverse.
@Test
public void testReverse() throws IOException {
String path = "tests/reverse.html";
String src = readFile(path);
JapidTemplate bt = new JapidTemplate(path, src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
assertTrue("invalid java code", JavaSyntaxTool.isValid(srccode));
assertTrue(srccode.contains("p(lookupStatic(\"/x/y.html\"))"));
assertTrue(srccode.contains("p(lookupStatic(\"/a/b/c.html\"))"));
assertTrue(srccode.contains("p(lookup(\"com.action\", \"ad\"))"));
}
use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testOpenIfCommand.
@Test
public void testOpenIfCommand() throws IOException {
String src = readFile("JapidSample/app/japidviews/Application/ifs2.html");
JapidTemplate bt = new JapidTemplate("Application/ifs2.html", src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testRecursiveTags.
@Test
public void testRecursiveTags() throws IOException {
String srcFile = "tests/recursiveTagging.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate("tests/recursiveTagging.html", src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
String code = bt.javaSource;
System.out.println(code);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
assertTrue(code.contains("new recursiveTagging(recursiveTagging.this).render"));
}
use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testNamedParams.
@Test
public void testNamedParams() throws IOException, ParseException {
String srcFile = "tests/namedParam.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate("tests/namedParam.html", src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
assertTrue(bt.javaSource.contains("new person(namedParam.this).render(named(\"name\", \"Bing\"), named(\"age\", foo(18)))"));
// assertTrue(bt.javaSource.contains("@Override protected void title() {"));
}
use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testAnotherLayout.
@Test
public void testAnotherLayout() throws IOException, ParseException {
String src = readFile("JapidSample/app/japidviews/_layouts/TagLayout.html");
JapidTemplate bt = new JapidTemplate("japidviews/_layouts/TagLayout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
CompilationUnit cu = JavaSyntaxTool.parse(srccode);
assertTrue(srccode.contains("package japidviews._layouts;"));
assertTrue(srccode.contains("public abstract class TagLayout extends cn.bran.play.JapidTemplateBase"));
assertTrue(srccode.contains("protected abstract void doLayout();"));
assertTrue(srccode.contains("@Override public void layout()"));
}
Aggregations