public void testComputeForJavaSrc() {
MinFunction minFunction = new MinFunction();
JavaExpr expr0 = new JavaExpr("JAVA_CODE_0", IntegerData.class, Integer.MAX_VALUE);
JavaExpr expr1 = new JavaExpr("JAVA_CODE_1", IntegerData.class, Integer.MAX_VALUE);
assertEquals(
new JavaExpr(
"com.google.template.soy.data.restricted.IntegerData.forValue(" +
"Math.min(JAVA_CODE_0.integerValue(), JAVA_CODE_1.integerValue()))",
IntegerData.class, Integer.MAX_VALUE),
minFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));
expr0 = new JavaExpr("JAVA_CODE_0", FloatData.class, Integer.MAX_VALUE);
expr1 = new JavaExpr("JAVA_CODE_1", FloatData.class, Integer.MAX_VALUE);
assertEquals(
new JavaExpr(
"com.google.template.soy.data.restricted.FloatData.forValue(" +
"Math.min(JAVA_CODE_0.floatValue(), JAVA_CODE_1.floatValue()))",
FloatData.class, Integer.MAX_VALUE),
minFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));
expr0 = new JavaExpr("JAVA_CODE_0", IntegerData.class, Integer.MAX_VALUE);
expr1 = new JavaExpr("JAVA_CODE_1", FloatData.class, Integer.MAX_VALUE);
assertEquals(
new JavaExpr(
"com.google.template.soy.data.restricted.FloatData.forValue(" +
"Math.min(JAVA_CODE_0.floatValue(), JAVA_CODE_1.floatValue()))",
FloatData.class, Integer.MAX_VALUE),
minFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));
expr0 = new JavaExpr("JAVA_CODE_0", NumberData.class, Integer.MAX_VALUE);
expr1 = new JavaExpr("JAVA_CODE_1", SoyData.class, Integer.MAX_VALUE);
assertEquals(
new JavaExpr(
"com.google.template.soy.javasrc.codedeps.SoyUtils.$$min(" +
"JAVA_CODE_0," +
" (com.google.template.soy.data.restricted.NumberData) JAVA_CODE_1)",
NumberData.class, Integer.MAX_VALUE),
minFunction.computeForJavaSrc(ImmutableList.of(expr0, expr1)));