Search in sources :

Example 16 with CodeMaker

use of com.squarespace.template.CodeMaker in project template-compiler by Squarespace.

the class CorePredicatesTest method testGreaterThanOrEqual.

@Test
public void testGreaterThanOrEqual() throws CodeException {
    CodeMaker mk = maker();
    assertTrue(GREATER_THAN_OR_EQUAL, context("1"), mk.args(" 1"));
    assertTrue(GREATER_THAN_OR_EQUAL, context("3"), mk.args(" 1"));
    assertTrue(GREATER_THAN_OR_EQUAL, context("-17"), mk.args(" -18"));
    assertTrue(GREATER_THAN_OR_EQUAL, context("\"z\""), mk.args(" \"a\""));
    assertTrue(GREATER_THAN_OR_EQUAL, context("[]"), mk.args(" []"));
    assertTrue(GREATER_THAN_OR_EQUAL, context("{}"), mk.args(" 5 4"));
    assertTrue(GREATER_THAN_OR_EQUAL, context("{}"), mk.args(" 5 5"));
    assertFalse(GREATER_THAN_OR_EQUAL, context("-18"), mk.args(" -17"));
    assertFalse(GREATER_THAN_OR_EQUAL, context("\"a\""), mk.args(" \"z\""));
    assertFalse(GREATER_THAN_OR_EQUAL, context("{}"), mk.args(" 4 5"));
}
Also used : CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Example 17 with CodeMaker

use of com.squarespace.template.CodeMaker in project template-compiler by Squarespace.

the class CorePredicatesTest method testGreaterThan.

@Test
public void testGreaterThan() throws CodeException {
    CodeMaker mk = maker();
    assertTrue(GREATER_THAN, context("3"), mk.args(" 1"));
    assertTrue(GREATER_THAN, context("-17"), mk.args(" -18"));
    assertTrue(GREATER_THAN, context("\"z\""), mk.args(" \"a\""));
    assertTrue(GREATER_THAN, context("1"), mk.args(" 5 4"));
    assertFalse(GREATER_THAN, context("1"), mk.args(" 1"));
    assertFalse(GREATER_THAN, context("-18"), mk.args(" -17"));
    assertFalse(GREATER_THAN, context("\"a\""), mk.args(" \"z\""));
    assertFalse(GREATER_THAN, context("[]"), mk.args(" []"));
    assertFalse(GREATER_THAN, context("1"), mk.args(" 4 5"));
}
Also used : CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Example 18 with CodeMaker

use of com.squarespace.template.CodeMaker in project template-compiler by Squarespace.

the class CorePredicatesTest method testLessThan.

@Test
public void testLessThan() throws CodeException {
    CodeMaker mk = maker();
    assertTrue(LESS_THAN, context("1"), mk.args(" 2"));
    assertTrue(LESS_THAN, context("-1"), mk.args(" 0"));
    assertTrue(LESS_THAN, context("\"a\""), mk.args(" \"j\""));
    assertTrue(LESS_THAN, context("{}"), mk.args(" 1 2"));
    assertFalse(LESS_THAN, context("-17"), mk.args(" -18"));
    assertFalse(LESS_THAN, context("-17"), mk.args(" -18"));
    assertFalse(LESS_THAN, context("\"j\""), mk.args(" \"a\""));
    assertFalse(LESS_THAN, context("[]"), mk.args(" []"));
    assertFalse(LESS_THAN, context("{}"), mk.args(" 2 2"));
    assertFalse(LESS_THAN, context("{}"), mk.args(" 3 2"));
}
Also used : CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Example 19 with CodeMaker

use of com.squarespace.template.CodeMaker in project template-compiler by Squarespace.

the class ContentFormattersTest method testSquarespaceThumbnail.

@Test
public void testSquarespaceThumbnail() throws CodeException {
    CodeMaker mk = maker();
    Arguments args = mk.args(" 50");
    String json = "\"100x200\"";
    assertFormatter(SQSP_THUMB_FOR_WIDTH, args, json, "100w");
    assertFormatter(SQSP_THUMB_FOR_HEIGHT, args, json, "100w");
    args = mk.args(" 600");
    json = "\"1200x2400\"";
    assertFormatter(SQSP_THUMB_FOR_WIDTH, args, json, "750w");
    assertFormatter(SQSP_THUMB_FOR_HEIGHT, args, json, "300w");
}
Also used : Arguments(com.squarespace.template.Arguments) CodeMaker(com.squarespace.template.CodeMaker) Test(org.testng.annotations.Test)

Aggregations

CodeMaker (com.squarespace.template.CodeMaker)19 Test (org.testng.annotations.Test)19 Arguments (com.squarespace.template.Arguments)10 Context (com.squarespace.template.Context)4 CodeBuilder (com.squarespace.template.CodeBuilder)1 Instruction (com.squarespace.template.Instruction)1