Package org.zkoss.zss.engine.xel

Examples of org.zkoss.zss.engine.xel.Token


    assertTokenEquals((Token) tokens.get(j++), "operand", "text", "no");
    assertTokenEquals((Token) tokens.get(j++), "function", "stop", "");
    assertTokenEquals((Token) tokens.get(j++), "operator-infix", "concatenate", "&");
    assertTokenEquals((Token) tokens.get(j++), "operand", "text", "  more \"test\" text");
 
    Token root = parser.parse(tokens, null, null);
    assertTokenEquals((Token) root, "operator-infix", "concatenate", "&");
    assertTokenEquals((Token) root.getOperands().get(0), "function", "start", "IF");
    assertTokenEquals((Token) root.getOperands().get(1), "operand", "text", "  more \"test\" text");
  }
View Full Code Here


    assertTokenEquals((Token) tokens.get(j++), "function", "start", "SUM");
    assertTokenEquals((Token) tokens.get(j++), "operand", "range", "A");
    assertTokenEquals((Token) tokens.get(j++), "function", "stop", "");

   
    Token root = parser.parse(tokens, null, new BookImpl("Mybook"));
    assertTokenEquals((Token) root, "function", "start", "SUM");
    assertTokenEquals((Token) root.getOperands().get(0), "operand", "var", "A");
  }
View Full Code Here

    int j = 0;
    assertTokenEquals((Token) tokens.get(j++), "function", "start", "SUM");
    assertTokenEquals((Token) tokens.get(j++), "operand", "number", "1");
    assertTokenEquals((Token) tokens.get(j++), "function", "stop", "");

    Token root = parser.parse(tokens, null, null);
    assertTokenEquals(root, "function", "start", "SUM");
    assertTokenEquals((Token) root.getOperands().get(0), "operand", "number", "1");
  }
View Full Code Here

    assertTokenEquals((Token) tokens.get(j++), "operand", "range", "a");
    assertTokenEquals((Token) tokens.get(j++), "operator-infix", "math", "+");
    assertTokenEquals((Token) tokens.get(j++), "operand", "range", "b");
    assertTokenEquals((Token) tokens.get(j++), "operator-postfix","", "%");
    assertTokenEquals((Token) tokens.get(j++), "subexpression", "stop", "");
    Token root = parser.parse(tokens, null, new BookImpl("Mybook"));

    assertTokenEquals(root, "operator-infix", "math", "+");
    assertTokenEquals((Token)root.getOperands().get(0), "operand", "var", "a");
    assertTokenEquals((Token)root.getOperands().get(1), "operator-postfix","", "%");
  }
View Full Code Here

    List tokens = parser.parseFormulaTokens(expr);
   
    assertNotNull(tokens);
    assertEquals(23, tokens.size());

    Token root = parser.parse(tokens, null, new BookImpl("Mybook"));

    assertTokenEquals(root, "function", "start", "SUM");
  }
View Full Code Here

    assertEquals(1, tokens.size());

    int j = 0;
    assertTokenEquals((Token) tokens.get(j++), "operand", "logical", "TRUE");

    Token root = parser.parse(tokens, null, null);
    assertTokenEquals(root, "operand", "logical", "TRUE");
  }
View Full Code Here

    assertEquals(type, token.getType() == null ? "" : token.getType().toString());
    assertEquals(subtype, token.getSubtype() == null ? "" : token.getSubtype().toString());
  }
 
  public void testEvaluate1() {
    Token root = null;
    String expr = "=1+2+3";
    Object x = parser.parse(expr, null, null).evaluate(null);
    assertEquals(6.0, ((Number)x).doubleValue(), 0);

    expr = "=1+\"2\"+3";
    x = parser.parse(expr, null, null).evaluate(null);
    assertEquals(6.0, ((Number)x).doubleValue(), 0);

    expr = "=\"1\"+\"2\"+3";
    x = parser.parse(expr, null, null).evaluate(null);
    assertEquals(6.0, ((Number)x).doubleValue(), 0);

    expr = "=1 + \"2\" * 3 + 4%";
    x = parser.parse(expr, null, null).evaluate(null);
    assertEquals(7.04, ((Number)x).doubleValue(), 0);

    expr = "=\"1\" & \"2\" * 3 + 4%";
    x = parser.parse(expr, null, null).evaluate(null);
    assertEquals("16.04", x);
   
    expr = "=\"1\" & \"2\"^3 + 4%";
    x = parser.parse(expr, null, null).evaluate(null);
    assertEquals("18.04", x);

    expr = "=\"1\" & \"2\"^3 + 4% / 0";
    root = parser.parse(expr, null, null);
    try {
      x = root.evaluate(null);
    } catch (SSErrorXelException ex) {
      assertEquals(SSError.DIV0, ex.getSSError());
    }
    expr = "=1234567890^1E+96";
    root = parser.parse(expr, null, null);
    try {
      x = root.evaluate(null);
    } catch (SSErrorXelException ex) {
      assertEquals(SSError.NUM, ex.getSSError());
    }
  }
View Full Code Here

      assertEquals(SSError.NUM, ex.getSSError());
    }
  }

  public void testEvaluate2() {
    Token root = null;
    String expr = "=SUM(1+2+3, 4, 5)";
    root = parser.parse(expr, null, null);
    Object x = root.evaluate(getXelContext());
    assertEquals(15.0, ((Number)x).doubleValue(), 0);
  }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.engine.xel.Token

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.