Package com.google.template.soy.jssrc.restricted

Examples of com.google.template.soy.jssrc.restricted.JsExpr



  public void testComputeForJsSrc() {

    IsNonnullFunction isNonnullFunction = new IsNonnullFunction();
    JsExpr expr = new JsExpr("JS_CODE", Integer.MAX_VALUE);
    assertEquals(
        new JsExpr("JS_CODE != null", Operator.NOT_EQUAL.getPrecedence()),
        isNonnullFunction.computeForJsSrc(ImmutableList.of(expr)));
  }
View Full Code Here



  public void testComputeForJsSrc() {

    RandomIntFunction randomIntFunction = new RandomIntFunction();
    JsExpr argExpr = new JsExpr("JS_CODE", Integer.MAX_VALUE);
    assertEquals(new JsExpr("Math.floor(Math.random() * JS_CODE)", Integer.MAX_VALUE),
                 randomIntFunction.computeForJsSrc(ImmutableList.of(argExpr)));
  }
View Full Code Here

      for (TestData testData : testDataListBuilder.build()) {
        expectedOutputsListBuilder.add(testData.expectedOutput);

        ImmutableList.Builder<JsExpr> args = ImmutableList.builder();
        for (String argJs : testData.directiveArgsJs) {
          args.add(new JsExpr("(" + argJs + ")", Integer.MAX_VALUE));
        }
        if (generatedJsExprsAsJsArrayHasElements) {
          generatedJsExprsAsJsArray.append(",\n");
        }
        generatedJsExprsAsJsArray
            .append("(")
            .append(
                testData.directive.applyForJsSrc(
                    new JsExpr("(" + testData.valueJs + ")", Integer.MAX_VALUE), args.build())
                .getText())
            .append(")");
        generatedJsExprsAsJsArrayHasElements = true;
      }
      generatedJsExprsAsJsArray.append("]");
View Full Code Here


  public void testComputeForJsSrc_lowPrecedenceArg() {

    StrContainsFunction f = new StrContainsFunction();
    JsExpr arg0 = new JsExpr("'foo' + 'bar'", Operator.PLUS.getPrecedence());
    JsExpr arg1 = new JsExpr("'bar'", Integer.MAX_VALUE);
    assertEquals(
        new JsExpr("('foo' + 'bar').indexOf('bar') != -1", Operator.NOT_EQUAL.getPrecedence()),
        f.computeForJsSrc(ImmutableList.of(arg0, arg1)));
  }
View Full Code Here


  public void testComputeForJsSrc_maxPrecedenceArgs() {

    StrContainsFunction f = new StrContainsFunction();
    JsExpr arg0 = new JsExpr("'foobar'", Integer.MAX_VALUE);
    JsExpr arg1 = new JsExpr("'bar'", Integer.MAX_VALUE);
    assertEquals(
        new JsExpr("'foobar'.indexOf('bar') != -1", Operator.NOT_EQUAL.getPrecedence()),
        f.computeForJsSrc(ImmutableList.of(arg0, arg1)));
  }
View Full Code Here


  public void testComputeForJsSrc() {

    MinFunction minFunction = new MinFunction();
    JsExpr expr0 = new JsExpr("JS_CODE_0", Integer.MAX_VALUE);
    JsExpr expr1 = new JsExpr("JS_CODE_1", Integer.MAX_VALUE);
    assertEquals(new JsExpr("Math.min(JS_CODE_0, JS_CODE_1)", Integer.MAX_VALUE),
                 minFunction.computeForJsSrc(ImmutableList.of(expr0, expr1)));
  }
View Full Code Here

TOP

Related Classes of com.google.template.soy.jssrc.restricted.JsExpr

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.