Package org.stringtemplate.v4.compiler

Examples of org.stringtemplate.v4.compiler.Compiler


    assertEquals(stringsExpected, stringsResult);
  }

  @Test public void testRotMap() throws Exception {
    String template = "<name:bold(),italics()>";
    CompiledST code = new Compiler().compile(template);
    String asmExpected =
      "load_attr 0, null, new 1 1, null, new 2 1, rot_map 2, write";
    String asmResult = code.instrs();
    assertEquals(asmExpected, asmResult);
    String stringsExpected = "[name, bold, italics]";
View Full Code Here


    assertEquals(stringsExpected, stringsResult);
  }

  @Test public void testRotMapArg() throws Exception {
    String template = "<name:bold(x),italics()>";
    CompiledST code = new Compiler().compile(template);
    String asmExpected =
      "load_attr 0, null, load_attr 1, new 2 2, null, new 3 1, rot_map 2, write";
    String asmResult = code.instrs();
    assertEquals(asmExpected, asmResult);
    String stringsExpected = "[name, x, bold, italics]";
View Full Code Here

    assertEquals(stringsExpected, stringsResult);
  }

  @Test public void testZipMap() throws Exception {
    String template = "<names,phones:bold()>";
    CompiledST code = new Compiler().compile(template);
    String asmExpected =
      "load_attr 0, load_attr 1, null, null, new 2 2, zip_map 2, write";
    String asmResult = code.instrs();
    assertEquals(asmExpected, asmResult);
    String stringsExpected = "[names, phones, bold]";
View Full Code Here

    assertEquals(stringsExpected, stringsResult);
  }

  @Test public void testZipMapArg() throws Exception {
    String template = "<names,phones:bold(x)>";
    CompiledST code = new Compiler().compile(template);
    String asmExpected =
      "load_attr 0, load_attr 1, null, null, load_attr 2, new 3 3, zip_map 2, write";
    String asmResult = code.instrs();
    assertEquals(asmExpected, asmResult);
    String stringsExpected = "[names, phones, x, bold]";
View Full Code Here

    assertEquals(stringsExpected, stringsResult);
  }

  @Test public void testAnonMap() throws Exception {
    String template = "<name:{n | <n>}>";
    CompiledST code = new Compiler().compile(template);
    String asmExpected =
      "load_attr 0, null, new 1 1, map, write";
    String asmResult = code.instrs();
    assertEquals(asmExpected, asmResult);
    String stringsExpected = "[name, _sub1]";
View Full Code Here

    assertEquals(stringsExpected, stringsResult);
  }

  @Test public void testAnonZipMap() throws Exception {
    String template = "<a,b:{x,y | <x><y>}>";
    CompiledST code = new Compiler().compile(template);
    String asmExpected =
      "load_attr 0, load_attr 1, null, null, new 2 2, zip_map 2, write";
    String asmResult = code.instrs();
    assertEquals(asmExpected, asmResult);
    String stringsExpected = "[a, b, _sub1]";
View Full Code Here

    assertEquals(stringsExpected, stringsResult);
  }

    @Test public void testIf() throws Exception {
        String template = "go: <if(name)>hi, foo<endif>";
        CompiledST code = new Compiler().compile(template);
        String asmExpected =
            "write_str 0, load_attr 1, brf 12, write_str 2";
        String asmResult = code.instrs();
        assertEquals(asmExpected, asmResult);
        String stringsExpected = "[go: , name, hi, foo]";
View Full Code Here

        assertEquals(stringsExpected, stringsResult);
    }

    @Test public void testIfElse() throws Exception {
        String template = "go: <if(name)>hi, foo<else>bye<endif>";
        CompiledST code = new Compiler().compile(template);
        String asmExpected =
            "write_str 0, " +
            "load_attr 1, " +
            "brf 15, " +
            "write_str 2, " +
View Full Code Here

        assertEquals(stringsExpected, stringsResult);
    }

    @Test public void testElseIf() throws Exception {
        String template = "go: <if(name)>hi, foo<elseif(user)>a user<endif>";
        CompiledST code = new Compiler().compile(template);
        String asmExpected =
            "write_str 0, " +
            "load_attr 1, " +
            "brf 15, " +
            "write_str 2, " +
View Full Code Here

        assertEquals(stringsExpected, stringsResult);
    }

    @Test public void testElseIfElse() throws Exception {
        String template = "go: <if(name)>hi, foo<elseif(user)>a user<else>bye<endif>";
        CompiledST code = new Compiler().compile(template);
        String asmExpected =
            "write_str 0, " +
            "load_attr 1, " +
            "brf 15, " +
            "write_str 2, " +
View Full Code Here

TOP

Related Classes of org.stringtemplate.v4.compiler.Compiler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.