Author: ate
Date: Mon Jan 20 20:04:24 2014
New Revision: 1559819

URL: http://svn.apache.org/r1559819
Log:
SCXML-188: correcting test of Javascript evaluation return value, not making 
assumptions on specific numeric return type (Integer or Double) if no decimals 
are expected.

Modified:
    
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java

Modified: 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java?rev=1559819&r1=1559818&r2=1559819&view=diff
==============================================================================
--- 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java
 (original)
+++ 
commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml2/env/javascript/JSEvaluatorTest.java
 Mon Jan 20 20:04:24 2014
@@ -73,10 +73,10 @@ public class JSEvaluatorTest {
 
     private static final TestItem[] SIMPLE_EXPRESSIONS = {
             new TestItem("'FIB: ' + (1 + 1 + 2 + 3 + 5)",new String("FIB: 
12")),
-            new TestItem("1 + 1 + 2 + 3 + 5",            new Double(12)),
+            new TestItem("1 + 1 + 2 + 3 + 5",            new Integer(12)),
+            new TestItem("1.1 + 1.1 + 2.1 + 3.1 + 5.1",  new Double(12.5)),
             new TestItem("(1 + 1 + 2 + 3 + 5) == 12",    new Boolean(true)),
             new TestItem("(1 + 1 + 2 + 3 + 5) == 13",    new Boolean(false)),
-            new TestItem("1.0 + 1.0 + 2.0 + 3.0 + 5.0",  new Double(12.0)),
     };
 
     private static final TestItem[] VAR_EXPRESSIONS = {
@@ -182,16 +182,10 @@ public class JSEvaluatorTest {
     public void testStandardExpressions() throws Exception {
         for (TestItem item: SIMPLE_EXPRESSIONS) {
             Object eval = evaluator.eval(context,item.expression);
-            // Allow for OpenJDK 1.6 which returns Integer instead of Double
-            if (eval instanceof Integer && item.result instanceof Number) {
+            if (item.result instanceof Integer && eval instanceof Number) {
                 Assert.assertEquals("Invalid result: " + item.expression,
-                        ((Number) item.result).intValue(),
+                        ((Integer) item.result).intValue(),
                         ((Number) eval).intValue());
-                if (!(item.result instanceof Integer)) {
-                    System.err.println("Evaluated: " + item.expression +
-                            ". Expected: " + 
item.result.getClass().getCanonicalName() 
-                            + ", actual: Integer");
-                }
             } else {
                 Assert.assertEquals("Invalid result: " + item.expression,
                         item.result,


Reply via email to