Skip to content

Commit 4b2bad9

Browse files
committed
Polishing
(cherry picked from commit efc5b47)
1 parent 1513c4a commit 4b2bad9

File tree

2 files changed

+143
-114
lines changed

2 files changed

+143
-114
lines changed

spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
import static org.junit.Assert.*;
4747

4848
/**
49-
* Checks the behaviour of the SpelCompiler.
50-
* This should cover compilation all compiled node types.
49+
* Checks SpelCompiler behavior. This should cover compilation all compiled node types.
5150
*
5251
* @author Andy Clement
5352
* @since 4.1
@@ -320,9 +319,8 @@ public void realLiteral() throws Exception {
320319
double resultI = expression.getValue(new TestClass1(), Double.TYPE);
321320
assertCanCompile(expression);
322321
double resultC = expression.getValue(new TestClass1(), Double.TYPE);
323-
assertEquals(3.4d, resultI,0.1d);
324-
assertEquals(3.4d, resultC,0.1d);
325-
322+
assertEquals(3.4d, resultI, 0.1d);
323+
assertEquals(3.4d, resultC, 0.1d);
326324
assertEquals(3.4d, expression.getValue());
327325
}
328326

@@ -455,13 +453,12 @@ public void intLiteral() throws Exception {
455453
assertCanCompile(expression);
456454
assertEquals(new Integer(42), expression.getValue(Integer.class));
457455

458-
// Code gen is different for -1 .. 6 because there are bytecode instructions specifically for those
459-
// values
456+
// Code gen is different for -1 .. 6 because there are bytecode instructions specifically for those values
460457

461458
// Not an int literal but an opminus with one operand:
462-
// expression = parser.parseExpression("-1");
463-
// assertCanCompile(expression);
464-
// assertEquals(-1, expression.getValue());
459+
// expression = parser.parseExpression("-1");
460+
// assertCanCompile(expression);
461+
// assertEquals(-1, expression.getValue());
465462
expression = parser.parseExpression("0");
466463
assertCanCompile(expression);
467464
assertEquals(0, expression.getValue());
@@ -506,8 +503,8 @@ public void floatLiteral() throws Exception {
506503
float resultI = expression.getValue(new TestClass1(), Float.TYPE);
507504
assertCanCompile(expression);
508505
float resultC = expression.getValue(new TestClass1(), Float.TYPE);
509-
assertEquals(3.4f, resultI,0.1f);
510-
assertEquals(3.4f, resultC,0.1f);
506+
assertEquals(3.4f, resultI, 0.1f);
507+
assertEquals(3.4f, resultC, 0.1f);
511508

512509
assertEquals(3.4f, expression.getValue());
513510
}
@@ -3293,10 +3290,10 @@ public void constructorReference() throws Exception {
32933290
assertCanCompile(expression);
32943291
Object o = expression.getValue();
32953292
assertEquals(testclass8,o.getClass().getName());
3296-
TestClass8 tc8 = (TestClass8)o;
3293+
TestClass8 tc8 = (TestClass8) o;
32973294
assertEquals(42, tc8.i);
32983295
assertEquals("123", tc8.s);
3299-
assertEquals(4.0d, tc8.d,0.5d);
3296+
assertEquals(4.0d, tc8.d, 0.5d);
33003297
assertEquals(true, tc8.z);
33013298

33023299
// no-arg ctor
@@ -4351,15 +4348,16 @@ public void mixingItUp_propertyAccessIndexerOpLtTernaryRootNull() throws Excepti
43514348

43524349
expression = parser.parseExpression("DR[0].three");
43534350
Object v = expression.getValue(payload);
4354-
assertEquals("Lorg/springframework/expression/spel/SpelCompilationCoverageTests$Three", getAst().getExitDescriptor());
4351+
assertEquals("Lorg/springframework/expression/spel/SpelCompilationCoverageTests$Three",
4352+
getAst().getExitDescriptor());
43554353

43564354
Expression expression = parser.parseExpression("DR[0].three.four lt 0.1d?#root:null");
43574355
v = expression.getValue(payload);
43584356

43594357
SpelExpression sExpr = (SpelExpression) expression;
43604358
Ternary ternary = (Ternary) sExpr.getAST();
43614359
OpLT oplt = (OpLT) ternary.getChild(0);
4362-
CompoundExpression cExpr = (CompoundExpression)oplt.getLeftOperand();
4360+
CompoundExpression cExpr = (CompoundExpression) oplt.getLeftOperand();
43634361
String cExprExitDescriptor = cExpr.getExitDescriptor();
43644362
assertEquals("D", cExprExitDescriptor);
43654363
assertEquals("Z", oplt.getExitDescriptor());
@@ -4599,14 +4597,16 @@ public void compilerWithGenerics_12040_3() {
45994597

46004598
@Test
46014599
public void indexerMapAccessor_12045() throws Exception {
4602-
SpelParserConfiguration spc = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE,getClass().getClassLoader());
4600+
SpelParserConfiguration spc = new SpelParserConfiguration(
4601+
SpelCompilerMode.IMMEDIATE,getClass().getClassLoader());
46034602
SpelExpressionParser sep = new SpelExpressionParser(spc);
46044603
expression=sep.parseExpression("headers[command]");
46054604
MyMessage root = new MyMessage();
46064605
assertEquals("wibble", expression.getValue(root));
4607-
// This next call was failing because the isCompilable check in Indexer did not check on the key being compilable
4608-
// (and also generateCode in the Indexer was missing the optimization that it didn't need necessarily need to call
4609-
// generateCode for that accessor)
4606+
// This next call was failing because the isCompilable check in Indexer
4607+
// did not check on the key being compilable (and also generateCode in the
4608+
// Indexer was missing the optimization that it didn't need necessarily
4609+
// need to call generateCode for that accessor)
46104610
assertEquals("wibble", expression.getValue(root));
46114611
assertCanCompile(expression);
46124612

0 commit comments

Comments
 (0)