fix for ternary or elvis using a full expression for their result components. parser polishing
This commit is contained in:
@@ -217,6 +217,7 @@ public class EvaluationTests extends ExpressionTestCase {
|
||||
evaluate("2>4?1:2",2,Integer.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTernaryOperator02() {
|
||||
evaluate("'abc'=='abc'?1:2",1,Integer.class);
|
||||
@@ -233,6 +234,14 @@ public class EvaluationTests extends ExpressionTestCase {
|
||||
Assert.assertFalse(expr.isWritable(eContext));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTernaryOperator05() {
|
||||
evaluate("1>2?#var=4:#var=5",5,Integer.class);
|
||||
evaluate("3?:#var=5",3,Integer.class);
|
||||
evaluate("null?:#var=5",5,Integer.class);
|
||||
evaluate("2>4?(3>2?true:false):(5<3?true:false)",false,Boolean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexer03() {
|
||||
evaluate("'christian'[8]", "n", String.class);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class HelperTests extends ExpressionTestCase {
|
||||
// IntLiteral value:2
|
||||
// ===> Expression '3+4+5+6+7-2' - AST end
|
||||
Assert.assertTrue(s.indexOf("===> Expression '3+4+5+6+7-2' - AST start")!=-1);
|
||||
Assert.assertTrue(s.indexOf(" OperatorPlus value:((((3 + 4) + 5) + 6) + 7) #children:2")!=-1);
|
||||
Assert.assertTrue(s.indexOf(" OpPlus value:((((3 + 4) + 5) + 6) + 7) #children:2")!=-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.springframework.expression.spel.SpelExpression;
|
||||
import org.springframework.expression.spel.SpelMessages;
|
||||
import org.springframework.expression.spel.SpelNode;
|
||||
import org.springframework.expression.spel.SpelParseException;
|
||||
import org.springframework.expression.spel.ast.OperatorAnd;
|
||||
import org.springframework.expression.spel.ast.OperatorOr;
|
||||
import org.springframework.expression.spel.ast.OpAnd;
|
||||
import org.springframework.expression.spel.ast.OpOr;
|
||||
|
||||
|
||||
public class SpelParserTests {
|
||||
@@ -228,8 +228,8 @@ public class SpelParserTests {
|
||||
public void testPositionalInformation() throws EvaluationException, ParseException {
|
||||
SpelExpression expr = new SpelExpressionParser().parse("true and true or false");
|
||||
SpelNode rootAst = expr.getAST();
|
||||
OperatorOr operatorOr = (OperatorOr)rootAst;
|
||||
OperatorAnd operatorAnd = (OperatorAnd)operatorOr.getLeftOperand();
|
||||
OpOr operatorOr = (OpOr)rootAst;
|
||||
OpAnd operatorAnd = (OpAnd)operatorOr.getLeftOperand();
|
||||
SpelNode rightOrOperand = operatorOr.getRightOperand();
|
||||
|
||||
// check position for final 'false'
|
||||
|
||||
Reference in New Issue
Block a user