Commits

Anonymous committed a3904bd

Fixed small error with ASTTest expressions containing sub-expressions without any paranthetical boundaries.

  • Participants
  • Parent commits f8c247a

Comments (0)

Files changed (4)

File src/java/ognl/ASTTest.java

             String first = OgnlRuntime.getChildSource(context, target, _children[0]);
             if (!OgnlRuntime.isBoolean(first) && !context.getCurrentType().isPrimitive())
                 first = OgnlRuntime.getCompiler().createLocalReference(context, first, context.getCurrentType());
+            if (ExpressionNode.class.isInstance(_children[0])) {
+                first = "(" + first + ")";
+            }
+            
+            String second = OgnlRuntime.getChildSource(context, target, _children[1]);
+            if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive())
+                second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());
+            if (ExpressionNode.class.isInstance(_children[1])) {
+                second = "(" + second + ")";
+            }
 
-            String second = OgnlRuntime.getChildSource(context, target, _children[1]);
-             if (!OgnlRuntime.isBoolean(second) && !context.getCurrentType().isPrimitive())
-                 second = OgnlRuntime.getCompiler().createLocalReference(context, second, context.getCurrentType());
-            
             String third = OgnlRuntime.getChildSource(context, target, _children[2]);
-             if (!OgnlRuntime.isBoolean(third) && !context.getCurrentType().isPrimitive())
-                 third = OgnlRuntime.getCompiler().createLocalReference(context, third, context.getCurrentType());
+            if (!OgnlRuntime.isBoolean(third) && !context.getCurrentType().isPrimitive())
+                third = OgnlRuntime.getCompiler().createLocalReference(context, third, context.getCurrentType());
+            if (ExpressionNode.class.isInstance(_children[2])) {
+                third = "(" + third + ")";
+            }
 
             result += "ognl.OgnlOps.booleanValue(" + first + ")";
 

File src/test/java/org/ognl/test/ArithmeticAndLogicalOperatorsTest.java

             { "5 instanceof java.lang.Integer", Boolean.TRUE },
             { "5. instanceof java.lang.Integer", Boolean.FALSE },
             { "!false || true", Boolean.TRUE},
+            { "(1 > 0 && true) || 2 > 0", Boolean.TRUE},
 
             // Logical expressions (string versions)
             { "2 or 0", Integer.valueOf(2)},

File src/test/java/org/ognl/test/PropertyTest.java

             { BEAN, "two.getMessage(active ? 'ACT' : 'INA')", "[ACT]"},
             { BEAN, "hasChildren('aaa')", Boolean.TRUE},
             { BEAN, "two.hasChildren('aa')", Boolean.FALSE},
-            { BEAN, "two.hasChildren('a')", Boolean.FALSE}
+            { BEAN, "two.hasChildren('a')", Boolean.FALSE},
+            { ROOT, "sorted ? (readonly ? 'currentSortDesc' : 'currentSortAsc') : 'currentSortNone'", "currentSortAsc"}
     };
 
     public static String formatValue(int millis, boolean b1, boolean b2)

File src/test/java/org/ognl/test/objects/Root.java

         return new Long(4);
     }
 
+    public boolean isSorted()
+    {
+        return true;
+    }
+
     public TestClass getMyTest()
     {
         return new TestImpl();