use of com.squarespace.template.Arguments in project template-compiler by Squarespace.
the class ContentFormattersTest method testResize.
@Test
public void testResize() throws CodeException {
CodeMaker mk = maker();
Arguments args = mk.args(" 50");
String json = "\"100x200\"";
assertFormatter(RESIZED_HEIGHT_FOR_WIDTH, args, json, "100");
assertFormatter(RESIZED_WIDTH_FOR_HEIGHT, args, json, "25");
args = mk.args(" 600");
json = "\"1200x2400\"";
assertFormatter(RESIZED_HEIGHT_FOR_WIDTH, args, json, "1200");
assertFormatter(RESIZED_WIDTH_FOR_HEIGHT, args, json, "300");
assertInvalidArgs(RESIZED_HEIGHT_FOR_WIDTH, mk.args(""));
assertInvalidArgs(RESIZED_WIDTH_FOR_HEIGHT, mk.args(""));
}
use of com.squarespace.template.Arguments in project template-compiler by Squarespace.
the class LegacyMoneyFormatFactoryTest method cldr.
private String cldr(String tag, String currency, String number, boolean narrow) throws CodeException {
Arguments args = mk.args(narrow ? " symbol:narrow" : " ");
CLDR_MONEY.validateArgs(args);
Locale locale = Locale.forLanguageTag(tag);
Context ctx = new Context(moneyJson(number, currency), new StringBuilder(), locale);
Variables variables = new Variables("@", ctx.node());
CLDR_MONEY.apply(ctx, args, variables);
return variables.first().node().asText();
}
use of com.squarespace.template.Arguments in project template-compiler by Squarespace.
the class InternationalFormattersTest method testExtraArgument.
public void testExtraArgument() throws Exception {
if (isJava8()) {
try {
MONEY_FORMATTER.validateArgs(new Arguments(new StringView(" en-US bad-arg")));
Assert.fail("expected ArgumentsException, too many arguments passed");
} catch (ArgumentsException e) {
// fall through
}
}
}
use of com.squarespace.template.Arguments in project template-compiler by Squarespace.
the class LegacyMoneyFormatFactoryTest method cldr.
private String cldr(CLDR.Locale locale, String currency, String number, boolean narrow) throws CodeException {
Arguments args = mk.args(narrow ? " symbol:narrow" : " ");
CLDR_MONEY.validateArgs(args);
Context ctx = new Context(moneyJson(number, currency));
ctx.cldrLocale(locale);
Variables variables = new Variables("@", ctx.node());
CLDR_MONEY.apply(ctx, args, variables);
return variables.first().node().asText();
}
use of com.squarespace.template.Arguments in project template-compiler by Squarespace.
the class LegacyMoneyFormatFactoryTest method legacy.
private String legacy(String locale, String currency, String number) throws CodeException {
Arguments args = mk.args(" " + locale);
LEGACY_MONEY.validateArgs(args);
Context ctx = new Context(moneyJson(number, currency));
Variables variables = new Variables("@", ctx.node());
LEGACY_MONEY.apply(ctx, args, variables);
return variables.first().node().asText();
}
Aggregations