Search in sources :

Example 26 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler 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() {"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 27 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testElvis.

@Test
public void testElvis() throws IOException, ParseException {
    String src = readFile("tests/elvis.html");
    JapidTemplate bt = new JapidTemplate("tests/elvis.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
    System.out.println(srcCode);
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 28 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testIfindef.

@Test
public void testIfindef() throws IOException, ParseException {
    String src = readFile("tests/ifindef.html");
    JapidTemplate bt = new JapidTemplate("tests/ifindef.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String srcCode = bt.javaSource;
    //		System.out.println(srcCode);
    assertTrue(!srcCode.contains("_if"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Example 29 with JapidTemplateCompiler

use of cn.bran.japid.compiler.JapidTemplateCompiler in project Japid by branaway.

the class CompilerTests method testActionInvocation.

@Test
public void testActionInvocation() throws IOException {
    String src = readFile("tests/actions.html");
    JapidTemplate bt = new JapidTemplate("tests/actions.html", src);
    JapidAbstractCompiler cp = new JapidTemplateCompiler();
    cp.compile(bt);
    String source = bt.javaSource;
    System.out.println(source);
    assertTrue("invalid java code", JavaSyntaxTool.isValid(source));
    assertTrue(source.contains("MyController.foo()"));
    assertTrue(source.contains("MyController.bar()"));
}
Also used : JapidAbstractCompiler(cn.bran.japid.compiler.JapidAbstractCompiler) JapidTemplate(cn.bran.japid.template.JapidTemplate) JapidTemplateCompiler(cn.bran.japid.compiler.JapidTemplateCompiler) Test(org.junit.Test)

Aggregations

JapidAbstractCompiler (cn.bran.japid.compiler.JapidAbstractCompiler)29 JapidTemplateCompiler (cn.bran.japid.compiler.JapidTemplateCompiler)29 JapidTemplate (cn.bran.japid.template.JapidTemplate)29 Test (org.junit.Test)29 CompilationUnit (japa.parser.ast.CompilationUnit)9