use of cn.taketoday.expression.ExpressionParser in project today-infrastructure by TAKETODAY.
the class SpelReproTests method SPR9486_floatEqDoubleUnaryMinus.
@Test
void SPR9486_floatEqDoubleUnaryMinus() {
Boolean expectedResult = -10.21f == -10.2;
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("-10.21f == -10.2");
Boolean result = expression.getValue(context, null, Boolean.class);
assertThat(result).isEqualTo(expectedResult);
}
use of cn.taketoday.expression.ExpressionParser in project today-infrastructure by TAKETODAY.
the class SpelReproTests method array.
@Test
void array() {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = null;
Object result = null;
expression = parser.parseExpression("new java.lang.Long[0].class");
result = expression.getValue(context, "");
assertThat(result.toString()).as("Equal assertion failed: ").isEqualTo("class [Ljava.lang.Long;");
expression = parser.parseExpression("T(java.lang.Long[])");
result = expression.getValue(context, "");
assertThat(result.toString()).as("Equal assertion failed: ").isEqualTo("class [Ljava.lang.Long;");
expression = parser.parseExpression("T(java.lang.String[][][])");
result = expression.getValue(context, "");
assertThat(result.toString()).as("Equal assertion failed: ").isEqualTo("class [[[Ljava.lang.String;");
assertThat(((SpelExpression) expression).toStringAST()).isEqualTo("T(java.lang.String[][][])");
expression = parser.parseExpression("new int[0].class");
result = expression.getValue(context, "");
assertThat(result.toString()).as("Equal assertion failed: ").isEqualTo("class [I");
expression = parser.parseExpression("T(int[][])");
result = expression.getValue(context, "");
assertThat(result.toString()).isEqualTo("class [[I");
}
use of cn.taketoday.expression.ExpressionParser in project today-infrastructure by TAKETODAY.
the class SpelReproTests method SPR9486_floatFunctionResolver.
@Test
void SPR9486_floatFunctionResolver() {
Number expectedResult = Math.abs(-10.2f);
ExpressionParser parser = new SpelExpressionParser();
SPR9486_FunctionsClass testObject = new SPR9486_FunctionsClass();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("abs(-10.2f)");
Number result = expression.getValue(context, testObject, Number.class);
assertThat(result).isEqualTo(expectedResult);
}
use of cn.taketoday.expression.ExpressionParser in project today-infrastructure by TAKETODAY.
the class SpelReproTests method SPR9486_floatLessThanFloat.
@Test
void SPR9486_floatLessThanFloat() {
Boolean expectedNumber = -10.21f < -10.2f;
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("-10.21f < -10.2f");
Boolean result = expression.getValue(context, null, Boolean.class);
assertThat(result).isEqualTo(expectedNumber);
}
use of cn.taketoday.expression.ExpressionParser in project today-infrastructure by TAKETODAY.
the class SpelReproTests method SPR9486_addFloatWithFloat.
@Test
void SPR9486_addFloatWithFloat() {
Number expectedNumber = 10.21f + 10.2f;
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression expression = parser.parseExpression("10.21f + 10.2f");
Number result = expression.getValue(context, null, Number.class);
assertThat(result).isEqualTo(expectedNumber);
}
Aggregations