Package cambridge.model

Examples of cambridge.model.Expression.eval()


   public void testList() {
      String expression = "['a', 'b', 213, aa]";
      try {
         Expression e = Expressions.parse(expression, 0, 0);
//         assertEquals("Testing type", CambridgeExpression.Type.Object, e.getType(bindings));
         assertTrue(e.eval(bindings) instanceof List);
         List l = (List) e.eval(bindings);
         assertEquals("a", l.get(0));
         assertEquals("b", l.get(1));
         assertEquals(213, l.get(2));
      } catch (ExpressionParsingException e) {
View Full Code Here


      String expression = "['a', 'b', 213, aa]";
      try {
         Expression e = Expressions.parse(expression, 0, 0);
//         assertEquals("Testing type", CambridgeExpression.Type.Object, e.getType(bindings));
         assertTrue(e.eval(bindings) instanceof List);
         List l = (List) e.eval(bindings);
         assertEquals("a", l.get(0));
         assertEquals("b", l.get(1));
         assertEquals(213, l.get(2));
      } catch (ExpressionParsingException e) {
         e.printStackTrace();
View Full Code Here

    public void testSimple() throws ExpressionEvaluationException
    {
        ExpressionContext context = expressionLanguage.createNewContext();
        Expression expression = expressionLanguage.parse("5 + 8", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing simple arithmetic", 13, result);
    }

    @Test
    public void testComplexArithmetic() throws ExpressionEvaluationException
View Full Code Here

    {
        ExpressionContext context = expressionLanguage.createNewContext();
        context.put("name", "Cambridge");
        Expression expression = expressionLanguage.parse("name", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing variable access", "Cambridge", result);
    }

    @Test
    public void testBean() throws Exception
View Full Code Here

    {
        ExpressionContext context = expressionLanguage.createNewContext();
        context.put("sample", sample);
        Expression expression = expressionLanguage.parse("sample", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing variable access", sample, result);
        assertTrue("Testing variable access", sample == result);

        assertEquals("Testing bean name", "Cambridge", expressionLanguage.parse("sample.name", 1, 1).eval(context));
        assertEquals("Testing bean id", 100, expressionLanguage.parse("sample.id", 1, 1).eval(context));
View Full Code Here

    public void testList() throws Exception
    {
        String expression = "['a', 'b', 213, aa]";
        ExpressionContext context = expressionLanguage.createNewContext();
        Expression e = expressionLanguage.parse(expression, 0, 0);
        assertTrue(e.eval(context) instanceof List);
        List<?> l = (List<?>) e.eval(context);
        assertEquals("a", l.get(0));
        assertEquals("b", l.get(1));
        assertEquals(213, l.get(2));
    }
View Full Code Here

    {
        String expression = "['a', 'b', 213, aa]";
        ExpressionContext context = expressionLanguage.createNewContext();
        Expression e = expressionLanguage.parse(expression, 0, 0);
        assertTrue(e.eval(context) instanceof List);
        List<?> l = (List<?>) e.eval(context);
        assertEquals("a", l.get(0));
        assertEquals("b", l.get(1));
        assertEquals(213, l.get(2));
    }
}
View Full Code Here

    public void testSimple() throws ExpressionEvaluationException
    {
        ExpressionContext context = expressionLanguage.createNewContext();
        Expression expression = expressionLanguage.parse("5 + 8", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing simple arithmetic", 13, result);
    }

    @Test
    public void testComplexArithmetic() throws ExpressionEvaluationException
View Full Code Here

    {
        ExpressionContext context = expressionLanguage.createNewContext();
        context.put("name", "Cambridge");
        Expression expression = expressionLanguage.parse("name", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing variable access", "Cambridge", result);
    }

    @Test
    public void testBean() throws Exception
View Full Code Here

    {
        ExpressionContext context = expressionLanguage.createNewContext();
        context.put("sample", sample);
        Expression expression = expressionLanguage.parse("sample", 1, 1);

        Object result = expression.eval(context);
        assertEquals("Testing variable access", sample, result);
        assertTrue("Testing variable access", sample == result);

        assertEquals("Testing bean name", "Cambridge", expressionLanguage.parse("sample.name", 1, 1).eval(context));
        assertEquals("Testing bean id", 100, expressionLanguage.parse("sample.id", 1, 1).eval(context));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.