commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1300178 [3/3] - in /commons/proper/jexl/trunk: ./ src/main/java/org/apache/commons/jexl3/ src/main/java/org/apache/commons/jexl3/internal/ src/main/java/org/apache/commons/jexl3/internal/introspection/ src/main/java/org/apache/commons/jexl...
Date Tue, 13 Mar 2012 15:13:09 GMT
Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/JexlParser.java Tue Mar 13 15:13:08 2012
@@ -28,36 +28,29 @@ import java.util.Stack;
  */
 public abstract class JexlParser extends StringParser {
     /**
-     * The map of named registers aka script parameters.
-     * Each parameter is associated to a register and is materialized as an offset in the registers array used
-     * during evaluation.
+     * The map of named registers aka script parameters. Each parameter is associated to a register and is materialized
+     * as an offset in the registers array used during evaluation.
      */
     protected Scope frame = null;
     protected Stack<Scope> frames = new Stack<Scope>();
 
     /**
-     * Sets the frame to use bythis parser.
-     * <p>
-     * This is used to allow parameters to be declared before parsing.
-     * </p>
+     * Sets the frame to use bythis parser. <p> This is used to allow parameters to be declared before parsing. </p>
      * @param theFrame the register map
      */
     public void setFrame(Scope theFrame) {
         frame = theFrame;
     }
-    
+
     /**
-     * Gets the frame used by this parser.
-     * <p>
-     * Since local variables create new named registers, it is important to regain access after
-     * parsing to known which / how-many registers are needed.
-     * </p>
+     * Gets the frame used by this parser. <p> Since local variables create new named registers, it is important to
+     * regain access after parsing to known which / how-many registers are needed. </p>
      * @return the named register map
      */
     public Scope getFrame() {
         return frame;
     }
-    
+
     /**
      * Create a new local variable frame and push it as current scope.
      */
@@ -65,9 +58,9 @@ public abstract class JexlParser extends
         if (frame != null) {
             frames.push(frame);
         }
-        frame = new Scope(frame, (String[])null);
+        frame = new Scope(frame, (String[]) null);
     }
-    
+
     /**
      * Pops back to previous local variable frame.
      */
@@ -78,52 +71,45 @@ public abstract class JexlParser extends
             frame = null;
         }
     }
-    
 
     /**
-     * Checks whether an identifier is a local variable or argument, ie stored in a register. 
+     * Checks whether an identifier is a local variable or argument, ie stored in a register.
      * @param identifier the identifier
      * @param image the identifier image
      * @return the image
      */
     public String checkVariable(ASTIdentifier identifier, String image) {
         if (frame != null) {
-            Integer register = frame.getRegister(image);
+            Integer register = frame.getSymbol(image);
             if (register != null) {
-                identifier.setRegister(register.intValue());
+                identifier.setSymbol(register.intValue());
             }
         }
         return image;
     }
 
     /**
-     * Declares a local variable.
-     * <p>
-     * This method creates an new entry in the named register map.
-     * </p>
+     * Declares a local variable. <p> This method creates an new entry in the named register map. </p>
      * @param identifier the identifier used to declare
      * @param image the variable name
      */
     public void declareVariable(ASTVar identifier, String image) {
         if (frame == null) {
-            frame = new Scope(null, (String[])null);
+            frame = new Scope(null, (String[]) null);
         }
         Integer register = frame.declareVariable(image);
-        identifier.setRegister(register.intValue());
+        identifier.setSymbol(register.intValue());
         identifier.image = image;
     }
-    
+
     /**
-     * Declares a local parameter.
-     * <p>
-     * This method creates an new entry in the named register map.
-     * </p>
+     * Declares a local parameter. <p> This method creates an new entry in the named register map. </p>
      * @param identifier the identifier used to declare
      * @param image the variable name
      */
     public void declareParameter(String image) {
         if (frame == null) {
-            frame = new Scope(null, (String[])null);
+            frame = new Scope(null, (String[]) null);
         }
         frame.declareParameter(image);
     }
@@ -131,7 +117,7 @@ public abstract class JexlParser extends
     /**
      * Default implementation does nothing but is overriden by generated code.
      * @param top whether the identifier is beginning an l/r value
-     * @throws ParseException subclasses may throw this 
+     * @throws ParseException subclasses may throw this
      */
     public void Identifier(boolean top) throws ParseException {
         // Overriden by generated code
@@ -149,28 +135,40 @@ public abstract class JexlParser extends
     }
 
     /**
-     * Ambiguous statement detector.
-     * @param n the node
-     * @throws ParseException 
-     */
-    void jjtreeCloseNodeScope(JexlNode n) throws ParseException {
-        if (n instanceof ASTAmbiguous && n.jjtGetNumChildren() > 0) {
-            JexlInfo dbgInfo = null;
+     * Called by parser at end of node construction.
+     * <p>Detects "Ambiguous statement" and 'non-leaft value assignment'.</p>
+     * @param node the node
+     * @throws ParseException
+     */
+    void jjtreeCloseNodeScope(JexlNode node) throws ParseException {
+        if (node instanceof ASTJexlScript) {
+            ASTJexlScript script = (ASTJexlScript) node;
+            // reaccess in case local variables have been declared
+            if (script.getScope() != frame) {
+                script.setScope(frame);
+            }
+            popFrame();
+        } else if (node instanceof ASTAmbiguous && node.jjtGetNumChildren() > 0) {
+            final JexlInfo dbgInfo;
             Token tok = this.getToken(0);
             if (tok != null) {
                 dbgInfo = new JexlInfo(tok.image, tok.beginLine, tok.beginColumn);
             } else {
-                dbgInfo = n.jexlInfo();
+                dbgInfo = node.jexlInfo();
             }
             throw new JexlException.Parsing(dbgInfo, "Ambiguous statement, missing ';' between expressions", null);
-        }
-        if (n instanceof ASTJexlScript) {
-            ASTJexlScript script = (ASTJexlScript) n;
-            // reaccess in case local variables have been declared
-            if (script.getScope() != frame) {
-                script.setScope(frame);
+        } else if (node instanceof ASTAssignment) {
+            JexlNode lv = node.jjtGetChild(0);
+            if (!lv.isLeftValue()) {
+                final JexlInfo dbgInfo;
+                Token tok = this.getToken(0);
+                if (tok != null) {
+                    dbgInfo = new JexlInfo(tok.image, tok.beginLine, tok.beginColumn);
+                } else {
+                    dbgInfo = node.jexlInfo();
+                }
+                throw new JexlException.Parsing(dbgInfo, "Invalid assignment expression", null);
             }
-            popFrame();
         }
     }
 }

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/Parser.jjt Tue Mar 13 15:13:08 2012
@@ -24,6 +24,7 @@ options
    NODE_SCOPE_HOOK=true;
    NODE_CLASS="JexlNode";
    UNICODE_INPUT=true;
+   //DEBUG_PARSER=true;
 }
 
 PARSER_BEGIN(Parser)
@@ -96,6 +97,7 @@ PARSER_END(Parser)
     | < FALSE : "false" >
     | < RETURN : "return" >
     | < FUNCTION : "function" >
+    | < LAMBDA : "->" >
 }
 
 <FOR_EACH_IN> TOKEN : /* foreach in */
@@ -232,32 +234,23 @@ void WhileStatement() : {}
     <WHILE> <LPAREN> Expression() <RPAREN> Statement()
 }
 
-
-void ForeachStatement() : {}
-{  
-    <FOR> <LPAREN> LValueVar() <COLON>  Expression() <RPAREN> Statement()
-|
-    <FOREACH> <LPAREN> LValueVar() <IN>  Expression() <RPAREN> Statement()
-}
-
 void ReturnStatement() : {}
 {
     <RETURN> Expression()
 }
 
-
-/***************************************
- *      Expression syntax
- ***************************************/
-
-void Expression() #void : {}
+void ForeachStatement() : {}
 {
-    ConditionalExpression() (LOOKAHEAD(1) <assign> Expression() #Assignment(2) )?
+    <FOR> <LPAREN> ForEachVar() <COLON>  Expression() <RPAREN> Statement()
+|
+    <FOREACH> <LPAREN> ForEachVar() <IN>  Expression() <RPAREN> Statement()
 }
 
-void Assignment() #Assignment(2) : {}
+void ForEachVar() #Reference : {}
 {
-    ConditionalExpression() <assign> Expression()
+    <VAR> DeclareVar()
+|
+    Identifier()
 }
 
 void Var() #void : {}
@@ -273,11 +266,18 @@ void DeclareVar() #Var :
     t=<IDENTIFIER> { declareVariable(jjtThis, t.image); }
 }
 
-void LValueVar() #Reference : {}
-{   
-    LOOKAHEAD(1) <VAR> DeclareVar() DotReference() 
-|
-    LOOKAHEAD(1) Identifier(true) DotReference()
+/***************************************
+ *      Expression syntax
+ ***************************************/
+
+void Expression() #void : {}
+{
+      AssignmentExpression()
+}
+
+void AssignmentExpression() #void : {}
+{
+    ConditionalExpression() [ LOOKAHEAD( <assign> ) <assign> Expression() #Assignment(2) ]
 }
 
 /***************************************
@@ -294,58 +294,47 @@ void ConditionalExpression() #void : {}
   )?
 }
 
-void ConditionalOrExpression() #void :
-{}
+void ConditionalOrExpression() #void : {}
 {
   ConditionalAndExpression()
-  (
-    <OR> ConditionalAndExpression() #OrNode(2)
-  )*
+  ( <OR> ConditionalAndExpression() #OrNode(2) )*
 }
 
-void ConditionalAndExpression() #void :
-{}
+void ConditionalAndExpression() #void : {}
 {
   InclusiveOrExpression()
-  (
-    <AND> InclusiveOrExpression() #AndNode(2)
-  )*
+  ( <AND> InclusiveOrExpression() #AndNode(2) )*
 }
 
-void InclusiveOrExpression() #void :
-{}
+void InclusiveOrExpression() #void : {}
 {
   ExclusiveOrExpression()
   ( <or> ExclusiveOrExpression() #BitwiseOrNode(2) )*
 }
 
-void ExclusiveOrExpression() #void :
-{}
+void ExclusiveOrExpression() #void : {}
 {
   AndExpression()
   ( <xor> AndExpression() #BitwiseXorNode(2) )*
 }
 
-void AndExpression() #void :
-{}
+void AndExpression() #void : {}
 {
   EqualityExpression()
   ( <and> EqualityExpression() #BitwiseAndNode(2) )*
 }
 
-void EqualityExpression() #void :
-{}
+void EqualityExpression() #void : {}
 {
   RelationalExpression()
   (
      <eq> RelationalExpression() #EQNode(2)
-   |
+|
      <ne> RelationalExpression() #NENode(2)
   )?
 }
 
-void RelationalExpression() #void :
-{}
+void RelationalExpression() #void : {}
 {
   AdditiveExpression()
   (
@@ -367,16 +356,14 @@ void RelationalExpression() #void :
  *      Arithmetic
  ***************************************/
 
-void AdditiveExpression() #AdditiveNode(>1) : {}
-{
-    MultiplicativeExpression() ( LOOKAHEAD(1) AdditiveOperator() MultiplicativeExpression())*
-}
-
-void AdditiveOperator() : {}
+void AdditiveExpression() #void : {}
 {
-    <plus> { jjtThis.image = "+"; }
-|
-    <minus> { jjtThis.image = "-"; }
+  MultiplicativeExpression()
+  ( LOOKAHEAD(2) (
+    <plus> MultiplicativeExpression() #AddNode(2)
+  |
+    <minus> MultiplicativeExpression() #SubNode(2)
+  ) )*
 }
 
 void MultiplicativeExpression() #void : {}
@@ -384,9 +371,9 @@ void MultiplicativeExpression() #void : 
   UnaryExpression()
   (
     <mult> UnaryExpression() #MulNode(2)
-   |
+  |
     <div> UnaryExpression() #DivNode(2)
-   |
+  |
     <mod> UnaryExpression() #ModNode(2)
   )*
 }
@@ -399,7 +386,11 @@ void UnaryExpression() #void : {}
 |
   <not> UnaryExpression() #NotNode(1)
 |
-  PrimaryExpression()
+  <EMPTY> UnaryExpression() #EmptyFunction(1)
+|
+  <SIZE> UnaryExpression() #SizeFunction(1)
+|
+  ValueExpression()
 }
 
 
@@ -414,10 +405,10 @@ void Identifier(boolean top) :
 {
     t=<IDENTIFIER> { jjtThis.image = top? checkVariable(jjtThis, t.image) : t.image; }
 |
-    t=<REGISTER> { jjtThis.image = t.image; jjtThis.setRegister(t.image); }
+    t=<REGISTER> { jjtThis.image = t.image; jjtThis.setSymbol(t.image); }
 }
 
-void StringIdentifier() #Identifier : 
+void StringIdentifier() #Identifier :
 {
     Token t;
 }
@@ -510,59 +501,62 @@ void MapEntry() : {}
  *      Functions & Methods
  ***************************************/
 
-void EmptyFunction() : {}
+void EmptyMethod() #EmptyMethod() : {}
 {
-    LOOKAHEAD(3) <EMPTY> <LPAREN> Expression() <RPAREN>
-|
-    <EMPTY> Reference()
+    <EMPTY> <LPAREN> <RPAREN>
 }
 
-void SizeFunction() : {}
+void SizeMethod() #SizeMethod() : {}
 {
-    <SIZE> <LPAREN> Expression() <RPAREN>
+    <SIZE> <LPAREN> <RPAREN>
 }
 
-void Function() #FunctionNode: {}
+void Arguments() #Arguments : {}
 {
-
-   Identifier(true) <COLON> Identifier() <LPAREN>[ Expression() ( <COMMA> Expression() )* ] <RPAREN>
+     <LPAREN> (Expression() (<COMMA> Expression())* )? <RPAREN>
 }
 
-void Method() #MethodNode: {}
+void FunctionCall() #void : {}
 {
-   Identifier(true) <LPAREN>[ Expression() ( <COMMA> Expression() )* ] <RPAREN>
+      LOOKAHEAD(2) Identifier() <COLON> Identifier() Arguments() #FunctionNode(3)
+    |
+      LOOKAHEAD(2) Identifier(true) Arguments() #FunctionNode(2)
 }
 
-void AnyMethod() #void : {}
+void Constructor() #ConstructorNode() : {}
 {
-    LOOKAHEAD(<SIZE>) SizeMethod()
-  |
-    LOOKAHEAD(Identifier() <LPAREN>) Method()
+  <NEW> <LPAREN> [ Expression() ( <COMMA> Expression() )* ] <RPAREN>
 }
 
-void SizeMethod() : {}
+void Parameter() #void :
 {
-    <SIZE> <LPAREN> <RPAREN>
+    Token t;
 }
-
-void Constructor() #ConstructorNode() : {}
 {
-  <NEW> <LPAREN>[ Expression() ( <COMMA> Expression() )* ] <RPAREN>
+    t=<IDENTIFIER> { declareParameter(t.image); }
 }
 
-void DeclareParm() #void :
+void Parameters() #void : {}
 {
-    Token t;
+     <LPAREN> [Parameter() (<COMMA> Parameter())* ] <RPAREN>
 }
+
+
+void LambdaLookahead() #void() : {}
 {
-    t=<IDENTIFIER> { declareParameter(t.image); }
+  <FUNCTION> Parameters()
+  |
+  Parameters() <LAMBDA>
 }
 
-void Lambda() #JexlLambda() : {
+void Lambda() #JexlLambda() :
+{
    pushFrame();
 }
 {
-  <FUNCTION> <LPAREN>[ DeclareParm() ( <COMMA> DeclareParm() )* ] <RPAREN> Block()
+  <FUNCTION> Parameters() Block()
+  |
+  Parameters() <LAMBDA> Block()
 }
 
 
@@ -571,76 +565,77 @@ void Lambda() #JexlLambda() : {
  *     References
  ***************************************/
 
-void PrimaryExpression() #void : {}
+void IdentifierAccess() :
 {
-  LOOKAHEAD(2) Reference()
-|
-  LOOKAHEAD( <EMPTY> ) EmptyFunction()
-|
-  LOOKAHEAD( <SIZE> ) SizeFunction()
-|
-  LOOKAHEAD( <NEW> <LPAREN> ) Constructor()
-|
-  LOOKAHEAD( <LCURLY> (Expression())? <COLON> ) MapLiteral()
-|
-  LOOKAHEAD( <LBRACKET> (Expression() | <RBRACKET>) ) ArrayLiteral()
-|
-  Literal()
-| Lambda()
+    Token t;
+}
+{
+    <DOT> (
+        t=<IDENTIFIER> { jjtThis.setIdentifier(t.image);}
+    |
+        t=<INTEGER_LITERAL> { jjtThis.setIdentifier(t.image); }
+    |
+        t=<STRING_LITERAL> { jjtThis.setIdentifier(Parser.buildString(t.image, true)); }
+    )
 }
 
 void ArrayAccess() : {}
 {
-    Identifier() (LOOKAHEAD(1) <LBRACKET> Expression() <RBRACKET>)+
+    (LOOKAHEAD(1) <LBRACKET> Expression() <RBRACKET>)+
 }
 
-void DotReference() #void : {}
+void MemberAccess() #void : {}
 {
-  (<DOT>
-     ( LOOKAHEAD(Identifier() <LBRACKET> )
-         ArrayAccess()
-       |
-       ( LOOKAHEAD(2)
-            AnyMethod()
-          |
-            Identifier()
-          |
-            IntegerLiteral()
-          |
-            StringIdentifier()
-       )
-     )
-  )*
+    LOOKAHEAD(<LBRACKET>) ArrayAccess()
+    |
+    LOOKAHEAD(<DOT>) IdentifierAccess()
 }
 
-void Reference() : {}
+void ReferenceExpression() #MethodNode(>1) : {}
 {
-  (
-   LOOKAHEAD(<NEW>) Constructor()
-|
-   LOOKAHEAD(Identifier() <LBRACKET> ) ArrayAccess()
-|
-   LOOKAHEAD(Identifier() <COLON> Identifier() <LPAREN>) Function()
-|
-   LOOKAHEAD(Identifier() <LPAREN>) Method()
-|
-   LOOKAHEAD(<LCURLY>) MapLiteral()
-|
-   LOOKAHEAD(<LBRACKET>) ArrayLiteral()
-|
-   LOOKAHEAD( <LPAREN> Expression() ) ReferenceExpression()
-|
-   StringLiteral()
-|
-   Identifier(true)
-  )  DotReference()
+    ( <LPAREN> Expression() <RPAREN> #ReferenceExpression(1) ) ( LOOKAHEAD(<LPAREN>) Arguments() )*
+}
+
+void PrimaryExpression() #void : {}
+{
+       LOOKAHEAD( LambdaLookahead() ) Lambda()
+    |
+       LOOKAHEAD( <LPAREN> ) ReferenceExpression()
+    |
+       LOOKAHEAD( <LCURLY> ) MapLiteral()
+    |
+       LOOKAHEAD( <LBRACKET> ) ArrayLiteral()
+    |
+       LOOKAHEAD( <NEW> ) Constructor()
+    |
+       LOOKAHEAD(2) FunctionCall()
+    |
+       Identifier(true)
+    |
+       Literal()
+}
+
+void MethodCall() #void : {}
+{
+    LOOKAHEAD(<DOT> <SIZE>) (<DOT> <SIZE> <LPAREN> <RPAREN>) #SizeMethod(1)
+    |
+    LOOKAHEAD(<DOT> <EMPTY>) ( <DOT> <SIZE> <LPAREN> <RPAREN>) #EmptyMethod(1)
+    |
+    (MemberAccess() (LOOKAHEAD(<LPAREN>) Arguments())+) #MethodNode(>1)
+}
+
+
+void MemberExpression() #void : {}
+{
+    LOOKAHEAD(MethodCall()) MethodCall() | MemberAccess()
 }
 
-/**
- * ReferenceExpression is a subclass of ArrayAccess
- */
-void ReferenceExpression() : {}
+void ValueExpression() #void : {}
 {
-    <LPAREN> Expression() <RPAREN> (LOOKAHEAD(1) <LBRACKET> Expression() <RBRACKET>)*
+    ( PrimaryExpression() ( LOOKAHEAD(2) MemberExpression() )*) #Reference(>1)
 }
 
+
+
+
+

Modified: commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParserVisitor.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParserVisitor.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParserVisitor.java (original)
+++ commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/parser/ParserVisitor.java Tue Mar 13 15:13:08 2012
@@ -85,9 +85,9 @@ public abstract class ParserVisitor {
 
     protected abstract Object visit(ASTNRNode node, Object data);
 
-    protected abstract Object visit(ASTAdditiveNode node, Object data);
+    protected abstract Object visit(ASTAddNode node, Object data);
 
-    protected abstract Object visit(ASTAdditiveOperator node, Object data);
+    protected abstract Object visit(ASTSubNode node, Object data);
 
     protected abstract Object visit(ASTMulNode node, Object data);
 
@@ -121,6 +121,8 @@ public abstract class ParserVisitor {
 
     protected abstract Object visit(ASTEmptyFunction node, Object data);
 
+    protected abstract Object visit(ASTEmptyMethod node, Object data);
+
     protected abstract Object visit(ASTSizeFunction node, Object data);
 
     protected abstract Object visit(ASTFunctionNode node, Object data);
@@ -133,5 +135,9 @@ public abstract class ParserVisitor {
 
     protected abstract Object visit(ASTArrayAccess node, Object data);
 
+    protected abstract Object visit(ASTIdentifierAccess node, Object data);
+
+    protected abstract Object visit(ASTArguments node, Object data);
+
     protected abstract Object visit(ASTReferenceExpression node, Object data);
 }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArrayAccessTest.java Tue Mar 13 15:13:08 2012
@@ -21,13 +21,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.jexl3.internal.Debugger;
 import org.apache.commons.jexl3.junit.Asserter;
 
 
 /**
  * Tests for array access operator []
- * 
+ *
  * @since 2.0
  */
 public class ArrayAccessTest extends JexlTestCase {
@@ -35,7 +34,7 @@ public class ArrayAccessTest extends Jex
     private Asserter asserter;
 
     private static final String GET_METHOD_STRING = "GetMethod string";
-    
+
     // Needs to be accessible by Foo.class
     static final String[] GET_METHOD_ARRAY =
         new String[] { "One", "Two", "Three" };
@@ -47,7 +46,7 @@ public class ArrayAccessTest extends Jex
     public ArrayAccessTest() {
         super("ArrayAccessTest");
     }
-    
+
     @Override
     public void setUp() {
         asserter = new Asserter(JEXL);
@@ -116,8 +115,9 @@ public class ArrayAccessTest extends Jex
         foo[0][1] = "two";
 
         asserter.setVariable("foo", foo);
-
         asserter.assertExpression("foo[0][1]", "two");
+        asserter.assertExpression("foo[0][1] = 'three'", "three");
+        asserter.assertExpression("foo[0][1]", "three");
     }
 
     public void testArrayProperty() throws Exception {
@@ -130,16 +130,17 @@ public class ArrayAccessTest extends Jex
         asserter.assertExpression("foo.array2[1][1]", GET_METHOD_ARRAY2[1][1]);
         asserter.assertExpression("foo.array2[1].1", GET_METHOD_ARRAY2[1][1]);
     }
-    
+
     // This is JEXL-26
     public void testArrayAndDottedConflict() throws Exception {
         Object[] objects = new Object[] {"an", "array", new Long(0)};
-        
+        asserter.setStrict(false);
+        asserter.setSilent(true);
         asserter.setVariable("objects", objects);
         asserter.setVariable("status", "Enabled");
         asserter.assertExpression("objects[1].status", null);
         asserter.assertExpression("objects.1.status", null);
-        
+
         asserter.setVariable("base.status", "Ok");
         asserter.assertExpression("base.objects[1].status", null);
         asserter.assertExpression("base.objects.1.status", null);
@@ -147,7 +148,7 @@ public class ArrayAccessTest extends Jex
 
     public void testArrayMethods() throws Exception {
         Object[] objects = new Object[] {"an", "array", new Long(0)};
-        
+
         asserter.setVariable("objects", objects);
         asserter.assertExpression("objects.get(1)", "array");
         asserter.assertExpression("objects.size()", new Integer(3));

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/AssignTest.java Tue Mar 13 15:13:08 2012
@@ -18,7 +18,7 @@ package org.apache.commons.jexl3;
 
 /**
  * Test cases for assignment.
- * 
+ *
  * @since 1.1
  */
 public class AssignTest extends JexlTestCase {
@@ -35,7 +35,7 @@ public class AssignTest extends JexlTest
             return value;
         }
     }
-    
+
     public static class Quux {
         String str;
         Froboz froboz;
@@ -43,19 +43,19 @@ public class AssignTest extends JexlTest
             this.str = str;
             froboz = new Froboz(fro);
         }
-        
+
         public Froboz getFroboz() {
             return froboz;
         }
-        
+
         public void setFroboz(Froboz froboz) {
             this.froboz = froboz;
         }
-        
+
         public String getStr() {
             return str;
         }
-        
+
         public void setStr(String str) {
             this.str = str;
         }
@@ -67,7 +67,7 @@ public class AssignTest extends JexlTest
 
     /**
      * Make sure bean assignment works
-     * 
+     *
      * @throws Exception on any error
      */
     public void testAntish() throws Exception {
@@ -89,7 +89,7 @@ public class AssignTest extends JexlTest
         o = check.evaluate(jc);
         assertEquals("Result is not 10", new Integer(10), o);
     }
-    
+
     public void testBeanish() throws Exception {
         JexlExpression assign = JEXL.createExpression("froboz.value = 10");
         JexlExpression check = JEXL.createExpression("froboz.value");
@@ -101,7 +101,7 @@ public class AssignTest extends JexlTest
         o = check.evaluate(jc);
         assertEquals("Result is not 10", new Integer(10), o);
     }
-    
+
     public void testAmbiguous() throws Exception {
         JexlExpression assign = JEXL.createExpression("froboz.nosuchbean = 10");
         JexlContext jc = new MapContext();
@@ -114,13 +114,12 @@ public class AssignTest extends JexlTest
         catch(RuntimeException xrt) {
             String str = xrt.toString();
             assertTrue(str.contains("nosuchbean"));
-            return;
         }
         finally {
             assertEquals("Should have failed", null, o);
         }
     }
-        
+
     public void testArray() throws Exception {
         JexlExpression assign = JEXL.createExpression("froboz[\"value\"] = 10");
         JexlExpression check = JEXL.createExpression("froboz[\"value\"]");
@@ -132,7 +131,14 @@ public class AssignTest extends JexlTest
         o = check.evaluate(jc);
         assertEquals("Result is not 10", new Integer(10), o);
     }
-    
+
+    public void testMini() throws Exception {
+        JexlContext jc = new MapContext();
+        JexlExpression assign = JEXL.createExpression("quux = 10");
+        Object o = assign.evaluate(jc);
+        assertEquals("Result is not 10", new Integer(10), o);
+
+    }
     public void testMore() throws Exception {
         JexlContext jc = new MapContext();
         jc.set("quuxClass", Quux.class);

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/CacheTest.java Tue Mar 13 15:13:08 2012
@@ -588,8 +588,8 @@ public class CacheTest extends JexlTestC
     public void testComputeCache() throws Exception {
             runThreaded(ComputeTask.class, LOOPS, true);
     }
-    
-    public static class JexlContextNS extends JexlEvalContext implements JexlContext.NamespaceResolver {
+
+    public static class JexlContextNS extends JexlEvalContext {
         final Map<String, Object> funcs;
         JexlContextNS(Map<String, Object> vars, Map<String, Object> funcs) {
             super(vars);
@@ -599,7 +599,7 @@ public class CacheTest extends JexlTestC
         public Object resolveNamespace(String name) {
             return funcs.get(name);
         }
-        
+
     }
 
     /**

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ClassCreatorTest.java Tue Mar 13 15:13:08 2012
@@ -39,7 +39,7 @@ public class ClassCreatorTest extends Je
     public ClassCreatorTest() {
         super("ClassCreatorTest");
     }
-    
+
     @Override
     public void setUp() throws Exception {
         base = new File(System.getProperty("java.io.tmpdir") + File.pathSeparator + "jexl" + System.currentTimeMillis());

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java Tue Mar 13 15:13:08 2012
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,7 @@ package org.apache.commons.jexl3;
 
 /**
  * Test cases for the if statement.
- * 
+ *
  * @since 1.1
  */
 public class IfTest extends JexlTestCase {
@@ -28,7 +28,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Make sure if true executes the true statement
-     * 
+     *
      * @throws Exception on any error
      */
     public void testSimpleIfTrue() throws Exception {
@@ -41,7 +41,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Make sure if false doesn't execute the true statement
-     * 
+     *
      * @throws Exception on any error
      */
     public void testSimpleIfFalse() throws Exception {
@@ -54,7 +54,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Make sure if false executes the false statement
-     * 
+     *
      * @throws Exception on any error
      */
     public void testSimpleElse() throws Exception {
@@ -67,7 +67,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Test the if statement handles blocks correctly
-     * 
+     *
      * @throws Exception on any error
      */
     public void testBlockIfTrue() throws Exception {
@@ -80,7 +80,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Test the if statement handles blocks in the else statement correctly
-     * 
+     *
      * @throws Exception on any error
      */
     public void testBlockElse() throws Exception {
@@ -93,7 +93,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Test the if statement evaluates expressions correctly
-     * 
+     *
      * @throws Exception on any error
      */
     public void testIfWithSimpleExpression() throws Exception {
@@ -107,7 +107,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Test the if statement evaluates arithmetic expressions correctly
-     * 
+     *
      * @throws Exception on any error
      */
     public void testIfWithArithmeticExpression() throws Exception {
@@ -121,7 +121,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Test the if statement evaluates decimal arithmetic expressions correctly
-     * 
+     *
      * @throws Exception on any error
      */
     public void testIfWithDecimalArithmeticExpression() throws Exception {
@@ -135,7 +135,7 @@ public class IfTest extends JexlTestCase
 
     /**
      * Test the if statement works with assignment
-     * 
+     *
      * @throws Exception on any error
      */
     public void testIfWithAssignment() throws Exception {
@@ -155,7 +155,7 @@ public class IfTest extends JexlTestCase
      */
     public void testTernary() throws Exception {
         JexlEngine jexl = JEXL;
-        
+
         JexlEvalContext jc = new JexlEvalContext();
         JexlExpression e = jexl.createExpression("x.y.z = foo ?'bar':'quux'");
         Object o;
@@ -249,7 +249,7 @@ public class IfTest extends JexlTestCase
             o = jc.get("x.y.z");
             assertEquals("Should be quux", "quux", o);
         }
-        
+
         jc.set("foo", Double.NaN);
 
         for (int l = 0; l < 4; ++l) {
@@ -260,7 +260,7 @@ public class IfTest extends JexlTestCase
             o = jc.get("x.y.z");
             assertEquals("Should be quux", "quux", o);
         }
-                
+
         jc.set("foo", "");
 
         for (int l = 0; l < 4; ++l) {
@@ -271,7 +271,7 @@ public class IfTest extends JexlTestCase
             o = jc.get("x.y.z");
             assertEquals("Should be quux", "quux", o);
         }
-                        
+
         jc.set("foo", "false");
 
         for (int l = 0; l < 4; ++l) {
@@ -281,8 +281,8 @@ public class IfTest extends JexlTestCase
             assertEquals("Should be quux", "quux", o);
             o = jc.get("x.y.z");
             assertEquals("Should be quux", "quux", o);
-        }               
-        
+        }
+
         jc.set("foo", 0d);
 
         for (int l = 0; l < 4; ++l) {
@@ -293,7 +293,7 @@ public class IfTest extends JexlTestCase
             o = jc.get("x.y.z");
             assertEquals("Should be quux", "quux", o);
         }
-                
+
         jc.set("foo", 0);
 
         for (int l = 0; l < 4; ++l) {

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java Tue Mar 13 15:13:08 2012
@@ -18,7 +18,6 @@ package org.apache.commons.jexl3;
 
 import org.apache.commons.jexl3.internal.Engine;
 import org.apache.commons.jexl3.internal.TemplateEngine;
-import org.apache.commons.jexl3.internal.Debugger;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.math.MathContext;
@@ -147,15 +146,16 @@ public class IssuesTest extends JexlTest
         // ensure errors will throw
         jc.setStrict(true);
         jc.setSilent(false);
-        String jexlExp = "(foo.getInner().foo() eq true) and (foo.getInner().goo() = (foo.getInner().goo()+1-1))";
-        JexlExpression e = jexl.createExpression(jexlExp);
-        jc.set("foo", new Foo());
-
         try {
+            String jexlExp = "(foo.getInner().foo() eq true) and (foo.getInner().goo() = (foo.getInner().goo()+1-1))";
+            JexlExpression e = jexl.createExpression(jexlExp);
+            jc.set("foo", new Foo());
             /* Object o = */ e.evaluate(jc);
             fail("Should have failed due to invalid assignment");
+        } catch (JexlException.Parsing xparse) {
+            String dbg = xparse.toString();
         } catch (JexlException xjexl) {
-            // expected
+            fail("Should have thrown a parse exception");
         }
     }
 
@@ -279,7 +279,8 @@ public class IssuesTest extends JexlTest
     // JEXL-62
     public void test62() throws Exception {
         JexlEngine jexl = createEngine(false);
-        JexlEvalContext ctxt = new JexlEvalContext();
+        MapContext vars = new MapContext();
+        JexlEvalContext ctxt = new JexlEvalContext(vars);
         ctxt.setStrict(true);
         ctxt.setSilent(true);// to avoid throwing JexlException on null method call
 
@@ -295,7 +296,7 @@ public class IssuesTest extends JexlTest
         assertEquals(jscript.getText(), null, jscript.execute(ctxt)); // OK
 
         JexlExpression jexpr;
-        ctxt.clearVariables();
+        vars.clear();
         jexpr = jexl.createExpression("dummy.hashCode()");
         assertEquals(jexpr.getExpression(), null, jexpr.evaluate(ctxt)); // OK
 
@@ -330,7 +331,7 @@ public class IssuesTest extends JexlTest
             fail("c.e not accessible as property");
         } catch (JexlException.Property xjexl) {
             String msg = xjexl.getMessage();
-            assertTrue(msg.indexOf("c.e") > 0);
+            assertTrue(msg.indexOf("e") > 0);
         }
 
     }
@@ -473,7 +474,7 @@ public class IssuesTest extends JexlTest
         }
     }
 
-// A's class definition 
+// A's class definition
     public static class A105 {
         String nameA;
         String propA;
@@ -688,7 +689,7 @@ public class IssuesTest extends JexlTest
         ctx.set("result", new BigDecimal("9958.33"));
         ctx.set("salary", new BigDecimal("119500.00"));
         ctx.set("month", new BigDecimal("12.00"));
-        ctx.set("percent", new BigDecimal("100.00"));
+        ctx.set("work.percent", new BigDecimal("100.00"));
 
         // will fail because default scale is 5
         assertFalse((Boolean) exp1.evaluate(ctx));
@@ -748,11 +749,40 @@ public class IssuesTest extends JexlTest
         JexlExpression e = jexl.createExpression("method()");
         JexlContext jc = new ObjectContext<ThrowNPE>(jexl, new ThrowNPE());
         try {
-        e.evaluate(jc);
-        fail("Should have thrown NPE");
-        } catch(JexlException xany) {
+            e.evaluate(jc);
+            fail("Should have thrown NPE");
+        } catch (JexlException xany) {
             Throwable xth = xany.getCause();
             assertEquals(NullPointerException.class, xth.getClass());
         }
     }
+
+    public void test130a() throws Exception {
+        String myName = "Test.Name";
+        Object myValue = "Test.Value";
+
+        JexlEngine myJexlEngine = new Engine();
+        MapContext myMapContext = new MapContext();
+        myMapContext.set(myName, myValue);
+
+        Object myObjectWithTernaryConditional = myJexlEngine.createScript(myName + "?:null").execute(myMapContext);
+        assertEquals(myValue, myObjectWithTernaryConditional);
+    }
+
+    public void test130b() throws Exception {
+        String myName = "Test.Name";
+        Object myValue = new Object() {
+            @Override
+            public String toString() {
+                return "Test.Value";
+            }
+        };
+
+        JexlEngine myJexlEngine = new Engine();
+        MapContext myMapContext = new MapContext();
+        myMapContext.set(myName, myValue);
+
+        Object myObjectWithTernaryConditional = myJexlEngine.createScript(myName + "?:null").execute(myMapContext);
+        assertEquals(myValue, myObjectWithTernaryConditional);
+    }
 }

Copied: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java (from r1243213, commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/UnifiedJEXLTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java?p2=commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java&p1=commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/UnifiedJEXLTest.java&r1=1243213&r2=1300178&rev=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/UnifiedJEXLTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JXLTTest.java Tue Mar 13 15:13:08 2012
@@ -31,18 +31,19 @@ import java.util.Set;
 /**
  * Test cases for the UnifiedEL.
  */
-public class UnifiedJEXLTest extends JexlTestCase {
+public class JXLTTest extends JexlTestCase {
     private static final JexlEngine ENGINE = new JexlBuilder().silent(false).cache(128).strict(true).create();
 
     private static final JxltEngine JXLT = ENGINE.createJxltEngine();
     private static final Log LOG = LogFactory.getLog(JxltEngine.class);
+    private MapContext vars = new MapContext();
     private JexlEvalContext context = null;
 
     @Override
     public void setUp() throws Exception {
         // ensure jul logging is only error
         java.util.logging.Logger.getLogger(org.apache.commons.jexl3.JexlEngine.class.getName()).setLevel(java.util.logging.Level.SEVERE);
-        context = new JexlEvalContext();
+        context = new JexlEvalContext(vars);
     }
 
     @Override
@@ -50,7 +51,7 @@ public class UnifiedJEXLTest extends Jex
         debuggerCheck(ENGINE);
         super.tearDown();
     }
-    
+
     /** Extract the source from a toString-ed expression. */
     private String getSource(String tostring) {
         int len = tostring.length();
@@ -89,7 +90,7 @@ public class UnifiedJEXLTest extends Jex
         }
     }
 
-    public UnifiedJEXLTest(String testName) {
+    public JXLTTest(String testName) {
         super(testName);
     }
 
@@ -126,6 +127,15 @@ public class UnifiedJEXLTest extends Jex
         assertEquals(source, getSource(expr.toString()));
     }
 
+    boolean contains(Set<List<String>> set, List<String> list) {
+        for(List<String> sl : set) {
+            if (sl.equals(list)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     public void testPrepareEvaluate() throws Exception {
         final String source = "Dear #{p} ${name};";
         JxltEngine.UnifiedExpression expr = JXLT.createExpression("Dear #{p} ${name};");
@@ -133,20 +143,20 @@ public class UnifiedJEXLTest extends Jex
 
         Set<List<String>> evars = expr.getVariables();
         assertEquals(1, evars.size());
-        assertTrue(evars.contains(Arrays.asList("name")));
+        assertTrue(contains(evars, Arrays.asList("name")));
         context.set("name", "Doe");
         JxltEngine.UnifiedExpression phase1 = expr.prepare(context);
         String as = phase1.asString();
         assertEquals("Dear ${p} Doe;", as);
         Set<List<String>> evars1 = phase1.getVariables();
         assertEquals(1, evars1.size());
-        assertTrue(evars1.contains(Arrays.asList("p")));
-        context.clearVariables();
+        assertTrue(contains(evars1, Arrays.asList("p")));
+        vars.clear();
         context.set("p", "Mr");
         context.set("name", "Should not be used in 2nd phase");
         Object o = phase1.evaluate(context);
         assertEquals("Dear Mr Doe;", o);
-        
+
         String p1 = getSource(phase1.toString());
         assertEquals(source, getSource(phase1.toString()));
         assertEquals(source, getSource(expr.toString()));
@@ -158,14 +168,14 @@ public class UnifiedJEXLTest extends Jex
 
         Set<List<String>> evars = expr.getVariables();
         assertEquals(1, evars.size());
-        assertTrue(evars.contains(Arrays.asList("hi")));
+        assertTrue(contains(evars, Arrays.asList("hi")));
 
         context.set("hi", "greeting");
         context.set("greeting.world", "Hello World!");
         assertTrue("expression should be deferred", expr.isDeferred());
         Object o = expr.evaluate(context);
         assertEquals("Hello World!", o);
-        
+
         assertEquals(source, getSource(expr.toString()));
     }
 
@@ -178,7 +188,7 @@ public class UnifiedJEXLTest extends Jex
         Object o = expr.evaluate(none);
         assertTrue("expression should be immediate", expr.isImmediate());
         assertEquals("Hello World!", o);
-        
+
         assertEquals(source, getSource(expr.toString()));
     }
 
@@ -190,7 +200,7 @@ public class UnifiedJEXLTest extends Jex
         Object o = expr.evaluate(none);
         assertTrue("expression should be immediate", expr.isImmediate());
         assertEquals("Hello World!", o);
-        
+
         assertEquals(source, getSource(expr.toString()));
     }
 
@@ -203,7 +213,7 @@ public class UnifiedJEXLTest extends Jex
         assertEquals("prepare should return immediate version", "${'world'}", as);
         Object o = expr.evaluate(none);
         assertEquals("world", o);
-        
+
         assertEquals(source, getSource(expr.toString()));
     }
 
@@ -310,7 +320,7 @@ public class UnifiedJEXLTest extends Jex
         t.evaluate(context, strw);
         output = strw.toString();
         assertEquals("no x\n", output);
-        
+
         String dstr = t.toString();
         assertNotNull(dstr);
     }
@@ -334,7 +344,7 @@ public class UnifiedJEXLTest extends Jex
         output = strw.toString();
         assertEquals("no x\n", output);
     }
-    
+
     public void testPrepareTemplate() throws Exception {
         String source =
                  "$$ for(var x : list) {\n"
@@ -349,13 +359,13 @@ public class UnifiedJEXLTest extends Jex
         context.set("l10n", "value");
         JxltEngine.Template tpEN = tl10n.prepare(context);
         context.set("l10n", null);
-        
+
         StringWriter strw;
         strw = new StringWriter();
         tpFR.evaluate(context, strw, args);
         String outFR = strw.toString();
         assertEquals("valeur=42\n", outFR);
-        
+
         context.set("l10n", null);
         strw = new StringWriter();
         tpEN.evaluate(context, strw, args);
@@ -386,28 +396,28 @@ public class UnifiedJEXLTest extends Jex
                 + "Life, the universe, and everything\n"
                 + "The value 169 is over fourty-two\n";
         assertEquals(out42, output);
-        
+
         String dstr = t.asString();
         assertNotNull(dstr);
     }
-    
+
     public static class FrobozWriter extends PrintWriter {
         public FrobozWriter(Writer w) {
             super(w);
         }
-        
+
         public void print(Froboz froboz) {
             super.print("froboz{");
             super.print(froboz.value);
             super.print("}");
         }
-        
+
         @Override
         public String toString() {
             return out.toString();
         }
     }
-    
+
     public void testWriter() throws Exception {
         Froboz froboz = new Froboz(42);
         Writer writer = new FrobozWriter(new StringWriter());

Copied: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java (from r1243213, commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEvalContext.java)
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java?p2=commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java&p1=commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEvalContext.java&r1=1243213&r2=1300178&rev=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/main/java/org/apache/commons/jexl3/JexlEvalContext.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlEvalContext.java Tue Mar 13 15:13:08 2012
@@ -18,17 +18,19 @@ package org.apache.commons.jexl3;
 
 import java.math.MathContext;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.Map;
+import org.apache.commons.jexl3.internal.Engine;
 
 /**
- * A JEXL evaluation context wrapping variables and options.
+ * A JEXL evaluation environment wrapping variables, namespace and options.
  */
-public class JexlEvalContext implements JexlContext, JexlEngine.Options {
+public class JexlEvalContext implements JexlContext, JexlContext.NamespaceResolver, JexlEngine.Options {
     /** The marker for the empty vars. */
-    protected static final Map<String,Object> EMPTY_MAP = Collections.<String,Object>emptyMap();
-    /** The wrapped variable vars (if any).*/
-    protected final Map<String, Object> vars;
+    private static final Map<String,Object> EMPTY_MAP = Collections.<String,Object>emptyMap();
+    /** The variables.*/
+    private final JexlContext vars;
+    /** The namespace. */
+    private final JexlContext.NamespaceResolver ns;
     /** Whether the engine should be silent. */
     private Boolean silent = null;
     /** Whether the engine should be strict. */
@@ -48,18 +50,37 @@ public class JexlEvalContext implements 
     }
 
     /**
-     * Creates a MapContext wrapping an existing user provided vars.
+     * Creates an evaluation environment wrapping an existing user provided vars.
      * <p>The supplied vars should be null only in derived classes that override the get/set/has methods.
      * For a default vars context with a code supplied vars, use the default no-parameter contructor.</p>
      * @param map the variables map
      */
-    public JexlEvalContext(Map<String, Object> map) { 
-        this.vars = map == EMPTY_MAP ? new HashMap<String, Object>() : map;
+    public JexlEvalContext(Map<String, Object> map) {
+        this.vars = map == EMPTY_MAP ? new MapContext() : new MapContext(map);
+        this.ns = null;
+    }
+
+    /**
+     * Creates an evaluation environment from a context.
+     * @param context the context (may be null, implies readonly)
+     */
+    public JexlEvalContext(JexlContext context) {
+        this(context, context instanceof JexlContext.NamespaceResolver? (JexlContext.NamespaceResolver) context : null);
+    }
+
+    /**
+     * Creates an evaluation environment from a context and a namespace.
+     * @param context the context (may be null, implies readonly)
+     * @param namespace the namespace (may be null, implies empty namespace)
+     */
+    public JexlEvalContext(JexlContext context, JexlContext.NamespaceResolver namespace) {
+        this.vars = context != null? context : Engine.EMPTY_CONTEXT;
+        this.ns = namespace != null? namespace : Engine.EMPTY_NS;
     }
 
     @Override
     public boolean has(String name) {
-        return vars.containsKey(name);
+        return vars.has(name);
     }
 
     @Override
@@ -69,14 +90,12 @@ public class JexlEvalContext implements 
 
     @Override
     public void set(String name, Object value) {
-        vars.put(name, value);
+        vars.set(name, value);
     }
 
-    /**
-     * Clears the variable vars.
-     */
-    public void clearVariables() {
-        vars.clear();
+    @Override
+    public Object resolveNamespace(String name) {
+        return ns != null? ns.resolveNamespace(name) : null;
     }
 
     /**

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/JexlTest.java Tue Mar 13 15:13:08 2012
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -117,7 +117,7 @@ public class JexlTest extends JexlTestCa
         assertExpression(jc, "num <= 2.5", Boolean.FALSE);
         assertExpression(jc, "now2 <= now", Boolean.FALSE); // test comparable
 
-//        
+//
         assertExpression(jc, "'6' >= '5'", Boolean.TRUE);
         assertExpression(jc, "num >= 5", Boolean.TRUE);
         assertExpression(jc, "num >= num", Boolean.TRUE);
@@ -229,7 +229,7 @@ public class JexlTest extends JexlTestCa
         jc.set("foo", new Foo());
 
         assertExpression(jc, "map['size']", "cheese");
-// PR - unsure whether or not we should support map.size or force usage of the above 'escaped' version        
+// PR - unsure whether or not we should support map.size or force usage of the above 'escaped' version
 //        assertExpression(jc, "map.size", "cheese");
         assertExpression(jc, "foo.getSize()", new Integer(22));
         // failing assertion for size property
@@ -355,7 +355,7 @@ public class JexlTest extends JexlTestCa
         assertExpression(jc, "not empty(string)", Boolean.FALSE);
         assertExpression(jc, "! empty string", Boolean.FALSE);
         assertExpression(jc, "!(empty string)", Boolean.FALSE);
-        assertExpression(jc, "!empty(string)", Boolean.FALSE);
+        assertExpression(jc, "! empty(string)", Boolean.FALSE);
 
     }
 
@@ -402,8 +402,8 @@ public class JexlTest extends JexlTestCa
         assertExpression(jc, "empty(foo)", Boolean.TRUE);
     }
 
-    /** 
-     * test quoting in strings 
+    /**
+     * test quoting in strings
      */
     public void testStringQuoting() throws Exception {
         JexlContext jc = new MapContext();
@@ -572,7 +572,7 @@ public class JexlTest extends JexlTestCa
         JexlExpression expr = JEXL.createExpression("first and foo.trueAndModify");
         expr.evaluate(jc);
         assertTrue("Short circuit failure: rhs evaluated when lhs FALSE", !tester.getModified());
-        // handle true for the left arg of 'and' 
+        // handle true for the left arg of 'and'
         tester = new Foo();
         jc.set("first", Boolean.TRUE);
         jc.set("foo", tester);
@@ -593,7 +593,7 @@ public class JexlTest extends JexlTestCa
         JexlExpression expr = JEXL.createExpression("first or foo.trueAndModify");
         expr.evaluate(jc);
         assertTrue("Short circuit failure: rhs not evaluated when lhs FALSE", tester.getModified());
-        // handle true for the left arg of 'or' 
+        // handle true for the left arg of 'or'
         tester = new Foo();
         jc.set("first", Boolean.TRUE);
         jc.set("foo", tester);
@@ -677,7 +677,7 @@ public class JexlTest extends JexlTestCa
 
     public void testUnicodeSupport() throws Exception {
         JexlContext jc = new MapContext();
-        assertExpression(jc, "'x' == 'Użytkownik'", Boolean.FALSE);
+        assertExpression(jc, "'x' == 'U?ytkownik'", Boolean.FALSE);
         assertExpression(jc, "'c:\\some\\windows\\path'", "c:\\some\\windows\\path");
         assertExpression(jc, "'foo\\u0020bar'", "foo\u0020bar");
         assertExpression(jc, "'foo\\u0020\\u0020bar'", "foo\u0020\u0020bar");
@@ -736,6 +736,7 @@ public class JexlTest extends JexlTestCa
         assertEquals(expr.toString(), 20, result);
         expr = jexl.createExpression("duck.user = 'zero'");
         result = expr.evaluate(jc);
+        assertEquals(expr.toString(), "zero", result);
         expr = jexl.createExpression("duck.user");
         result = expr.evaluate(jc);
         assertEquals(expr.toString(), 0, result);

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/LambdaTest.java Tue Mar 13 15:13:08 2012
@@ -26,7 +26,7 @@ public class LambdaTest extends JexlTest
     public LambdaTest(String testName) {
         super(testName);
     }
-    
+
     public void testScriptArguments() throws Exception {
         JexlEngine jexl = new Engine();
         JexlScript s = jexl.createScript("{ x + x }", "x");
@@ -34,13 +34,13 @@ public class LambdaTest extends JexlTest
         Object result = s42.execute(null, s);
         assertEquals(42, result);
     }
-    
+
     public void testScriptContext() throws Exception {
         JexlEngine jexl = new Engine();
         JexlScript s = jexl.createScript("function(x) { x + x }");
         JexlScript fs = (JexlScript) s.execute(null);
         String fsstr = fs.getExpression();
-        assertEquals("function(x) { x + x; };", fsstr);
+        assertEquals("(x)->{ x + x; };", fsstr);
         assertEquals(42, fs.execute(null, 21));
         JexlScript s42 = jexl.createScript("s(21)");
         JexlEvalContext ctxt = new JexlEvalContext();
@@ -50,7 +50,7 @@ public class LambdaTest extends JexlTest
         result = s42.evaluate(ctxt);
         assertEquals(42, result);
     }
-    
+
     public void testLambda() throws Exception {
         JexlEngine jexl = new Engine();
         String strs = "var s = function(x) { x + x }; s(21)";
@@ -62,7 +62,7 @@ public class LambdaTest extends JexlTest
         result = s42.execute(null);
         assertEquals(42, result);
     }
-    
+
     public void testLambdaClosure() throws Exception {
         JexlEngine jexl = new Engine();
         String strs = "var t = 20; var s = function(x, y) { x + y + t}; s(15, 7)";
@@ -82,4 +82,30 @@ public class LambdaTest extends JexlTest
         result = s42.execute(null);
         assertEquals(42, result);
     }
+
+    public void testLambdaLambda() throws Exception {
+        JexlEngine jexl = new Engine();
+        String strs = "var t = 19; ( (x, y)->{ var t = 20; x + y + t} )(15, 7);";
+        JexlScript s42 = jexl.createScript(strs);
+        Object result = s42.execute(null);
+        assertEquals(42, result);
+
+        strs = "( (x, y)->{ ( (xx, yy)->{xx + yy } )(x, y) } )(15, 27)";
+        s42 = jexl.createScript(strs);
+        result = s42.execute(null);
+        assertEquals(42, result);
+
+        strs = "var t = 19; var s = (x, y)->{ var t = 20; x + y + t}; t = 54; s(15, 7)";
+        s42 = jexl.createScript(strs);
+        result = s42.execute(null);
+        assertEquals(42, result);
+    }
+
+    public void testNestLambda() throws Exception {
+        JexlEngine jexl = new Engine();
+        String strs = "( (x)->{ (y)->{ x + y } })(15)(27)";
+        JexlScript s42 = jexl.createScript(strs);
+        Object result = s42.execute(null);
+        assertEquals(42, result);
+    }
 }

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/MethodTest.java Tue Mar 13 15:13:08 2012
@@ -23,7 +23,7 @@ import org.apache.commons.jexl3.junit.As
 
 /**
  * Tests for calling methods on objects
- * 
+ *
  * @since 2.0
  */
 public class MethodTest extends JexlTestCase {
@@ -70,7 +70,7 @@ public class MethodTest extends JexlTest
             }
             return mixed + ":" + result;
         }
-        
+
         public String concat(String... strs) {
             if (strs.length > 0) {
                 StringBuilder strb = new StringBuilder(strs[0]);
@@ -107,7 +107,7 @@ public class MethodTest extends JexlTest
         }
     }
 
-    public static class EnhancedContext extends JexlEvalContext implements JexlContext.NamespaceResolver {
+    public static class EnhancedContext extends JexlEvalContext {
         int factor = 6;
         final Map<String, Object> funcs;
 
@@ -148,7 +148,7 @@ public class MethodTest extends JexlTest
         asserter.assertExpression("test.callInts(1,2,3,4,5)", "Varargs:15");
         asserter.assertExpression("test.concat(['1', '2', '3'])", "1, 2, 3");
         asserter.assertExpression("test.concat('1', '2', '3')", "1, 2, 3");
-        
+
     }
 
     public void testCallMixedVarArgMethod() throws Exception {
@@ -279,7 +279,7 @@ public class MethodTest extends JexlTest
 
         JexlExpression e = JEXL.createExpression("func:ten()");
         JexlEvalContext jc = new EnhancedContext(funcs);
-        
+
         Object o = e.evaluate(jc);
         assertEquals("Result is not 10", new Integer(10), o);
 
@@ -307,6 +307,7 @@ public class MethodTest extends JexlTest
             nsScript = ns;
         }
 
+        @Override
         public Object resolveNamespace(String name) {
             if (name == null) {
                 return this;

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ScriptCallableTest.java Tue Mar 13 15:13:08 2012
@@ -66,7 +66,7 @@ public class ScriptCallableTest extends 
         future.cancel(true);
         assertTrue(future.isCancelled());
     }
-    
+
     public void testCallableClosure() throws Exception {
         JexlScript e = JEXL.createScript("function(t) {while(t);}");
         e = (JexlScript) e.execute(null);
@@ -94,7 +94,7 @@ public class ScriptCallableTest extends 
             Thread.sleep(1000 * s);
             return s;
         }
-        
+
         public int waitInterrupt(int s) {
             try {
                 Thread.sleep(1000 * s);
@@ -104,7 +104,7 @@ public class ScriptCallableTest extends 
             }
             return -1;
         }
-        
+
         public int runForever() {
             boolean x = false;
             while(true) {
@@ -126,7 +126,7 @@ public class ScriptCallableTest extends 
         assertTrue(future.isDone());
         assertEquals(0, t);
     }
-    
+
     public void testWait() throws Exception {
         JexlScript e = JEXL.createScript("wait(1)");
         Callable<Object> c = e.callable(new TestContext());
@@ -152,7 +152,7 @@ public class ScriptCallableTest extends 
         future.cancel(true);
         assertTrue(future.isCancelled());
     }
-    
+
     public void testCancelWaitInterrupt() throws Exception {
         JexlScript e = JEXL.createScript("waitInterrupt(42)");
         Callable<Object> c = e.callable(new TestContext());
@@ -168,7 +168,7 @@ public class ScriptCallableTest extends 
         future.cancel(true);
         assertTrue(future.isCancelled());
     }
-    
+
     public void testCancelForever() throws Exception {
         JexlScript e = JEXL.createScript("runForever()");
         Callable<Object> c = e.callable(new TestContext());
@@ -184,7 +184,7 @@ public class ScriptCallableTest extends 
         future.cancel(true);
         assertTrue(future.isCancelled());
     }
-    
+
     public void testCancelLoopWait() throws Exception {
         JexlScript e = JEXL.createScript("while (true) { wait(10) }");
         Callable<Object> c = e.callable(new TestContext());

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java Tue Mar 13 15:13:08 2012
@@ -34,37 +34,37 @@ public class VarTest extends JexlTestCas
     public VarTest(String testName) {
         super(testName);
     }
-    
+
     public void testStrict() throws Exception {
-        JexlEvalContext map = new JexlEvalContext();
-        JexlContext ctxt = new ReadonlyContext(map, map);
-        map.setStrict(true);
-        map.setSilent(false);
+        JexlEvalContext env = new JexlEvalContext();
+        JexlContext ctxt = new ReadonlyContext(env, env);
+        env.setStrict(true);
+        env.setSilent(false);
         JexlScript e;
-        
+
         e = JEXL.createScript("x");
         try {
             Object o = e.execute(ctxt);
             fail("should have thrown an unknown var exception");
         } catch(JexlException xjexl) {
             // ok since we are strict and x does not exist
-        } 
+        }
         e = JEXL.createScript("x = 42");
         try {
             Object o = e.execute(ctxt);
             fail("should have thrown a readonly context exception");
         } catch(JexlException xjexl) {
             // ok since we are strict and context is readonly
-        }   
-        
-        map.set("x", "fourty-two");
+        }
+
+        env.set("x", "fourty-two");
         e = JEXL.createScript("x.theAnswerToEverything()");
         try {
             Object o = e.execute(ctxt);
             fail("should have thrown an unknown method exception");
         } catch(JexlException xjexl) {
             // ok since we are strict and method does not exist
-        } 
+        }
     }
 
     public void testLocalBasic() throws Exception {
@@ -108,7 +108,7 @@ public class VarTest extends JexlTestCas
         JexlScript e = JEXL.createScript("var y  = 42; for(var x : numbers()) { if (x > 10) return x } y;");
         Object o = e.execute(jc);
         assertEquals("Result is not 17", new Integer(17), o);
-        
+
         assertTrue(toString(e.getVariables()), e.getVariables().isEmpty());
     }
 
@@ -138,7 +138,7 @@ public class VarTest extends JexlTestCas
         strb.append("}");
         return strb.toString();
     }
-    
+
     /**
      * Creates a variable reference set from an array of array of strings.
      * @param refs the variable reference set
@@ -151,7 +151,7 @@ public class VarTest extends JexlTestCas
         }
         return set;
     }
-    
+
     /**
      * Checks that two sets of variable references are equal
      * @param lhs the left set
@@ -173,7 +173,7 @@ public class VarTest extends JexlTestCas
         }
         return true;
     }
-    
+
     List<String> stringify(Set<List<String>> sls) {
         List<String> ls = new ArrayList<String>();
         for(List<String> l : sls) {
@@ -197,8 +197,8 @@ public class VarTest extends JexlTestCas
         vars = e.getVariables();
         expect = mkref(new String[][]{{"e"},{"f"}});
         assertTrue(eq(expect, vars));
-        
-        
+
+
         e = JEXL.createScript("e[f][g]");
         vars = e.getVariables();
         expect = mkref(new String[][]{{"e"},{"f"},{"g"}});
@@ -218,7 +218,7 @@ public class VarTest extends JexlTestCas
         vars = e.getVariables();
         expect = mkref(new String[][]{{"e"},{"f"}});
         assertTrue(eq(expect, vars));
-        
+
         e = JEXL.createScript("e['f']['g']");
         vars = e.getVariables();
         expect = mkref(new String[][]{{"e","f","g"}});
@@ -235,7 +235,7 @@ public class VarTest extends JexlTestCas
         expect = mkref(new String[][]{{"a"}, {"b", "c"}, {"b", "c", "d"}, {"e", "f"}});
         assertTrue(eq(expect, vars));
     }
-    
+
     public void testMix() throws Exception {
         JexlScript e;
         // x is a parameter, y a context variable, z a local variable
@@ -243,20 +243,20 @@ public class VarTest extends JexlTestCas
         Set<List<String>> vars = e.getVariables();
         String[] parms = e.getParameters();
         String[] locals = e.getLocalVariables();
-        
+
         assertTrue(eq(mkref(new String[][]{{"y"}}), vars));
         assertEquals(1, parms.length);
         assertEquals("x", parms[0]);
         assertEquals(1, locals.length);
         assertEquals("z", locals[0]);
     }
-    
+
     public void testLiteral() throws Exception {
         JexlScript e = JEXL.createScript("x.y[['z', 't']]");
         Set<List<String>> vars = e.getVariables();
         assertEquals(1, vars.size());
         assertTrue(eq(mkref(new String[][]{{"x", "y", "[ 'z', 't' ]"}}), vars));
-        
+
         e = JEXL.createScript("x.y[{'z': 't'}]");
         vars = e.getVariables();
         assertEquals(1, vars.size());

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/Util.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/Util.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/Util.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/internal/Util.java Tue Mar 13 15:13:08 2012
@@ -29,7 +29,7 @@ import org.apache.commons.jexl3.parser.J
  * @author henri
  */
 public class Util {
-    
+
     /**
      * Will force testing the debugger for each derived test class by
      * recreating each expression from the JexlNode in the JexlEngine cache &
@@ -126,7 +126,7 @@ public class Util {
         }
         return null;
     }
-    
+
     /**
      * A helper class to help debug AST problems.
      * @param e the script

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java?rev=1300178&r1=1300177&r2=1300178&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/junit/Asserter.java Tue Mar 13 15:13:08 2012
@@ -45,7 +45,7 @@ public class Asserter extends Assert {
     private final JexlEngine engine;
 
     /**
-     * 
+     *
      * Create an asserter.
      * @param jexl the JEXL engine to use
      */
@@ -68,34 +68,34 @@ public class Asserter extends Assert {
     public JexlContext getContext() {
         return context;
     }
-    
+
     public void setStrict(boolean s) {
         context.setStrict(s, s);
     }
-    
+
     public void setStrict(boolean es, boolean as) {
         context.setStrict(es, as);
     }
-    
+
     public void setSilent(boolean silent) {
         context.setSilent(silent);
     }
-    
+
     public void clearOptions() {
         context.clearOptions();
     }
 
     /**
-     * Performs an assertion that the value of the given Jexl expression 
+     * Performs an assertion that the value of the given Jexl expression
      * evaluates to the given expected value.
-     * 
+     *
      * @param expression is the Jexl expression to evaluate
      * @param expected is the expected value of the expression
      * @throws Exception if the expression could not be evaluationed or an assertion
      * fails
      */
     public void assertExpression(String expression, Object expected) throws Exception {
-        JexlExpression exp = engine.createExpression(expression);
+        JexlExpression exp = engine.createScript(expression);
         Object value = exp.evaluate(context);
         if (expected instanceof BigDecimal) {
             JexlArithmetic jexla = engine.getArithmetic();
@@ -115,7 +115,7 @@ public class Asserter extends Assert {
      */
     public void failExpression(String expression, String matchException) throws Exception {
         try {
-            JexlExpression exp = engine.createExpression(expression);
+            JexlExpression exp = engine.createScript(expression);
             exp.evaluate(context);
             fail("expression: " + expression);
         } catch (JexlException xjexl) {
@@ -128,7 +128,7 @@ public class Asserter extends Assert {
     /**
      * Puts a variable of a certain name in the context so that it can be used from
      * assertion expressions.
-     * 
+     *
      * @param name variable name
      * @param value variable value
      */



Mime
View raw message