incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1164533 - /incubator/lcf/trunk/framework/script-engine/src/test/java/org/apache/manifoldcf/scriptengine/tests/ExpressionTest.java
Date Fri, 02 Sep 2011 13:51:28 GMT
Author: kwright
Date: Fri Sep  2 13:51:28 2011
New Revision: 1164533

URL: http://svn.apache.org/viewvc?rev=1164533&view=rev
Log:
Complete the integer part of the expression test.  Other tests will be modeled on this one.

Modified:
    incubator/lcf/trunk/framework/script-engine/src/test/java/org/apache/manifoldcf/scriptengine/tests/ExpressionTest.java

Modified: incubator/lcf/trunk/framework/script-engine/src/test/java/org/apache/manifoldcf/scriptengine/tests/ExpressionTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/test/java/org/apache/manifoldcf/scriptengine/tests/ExpressionTest.java?rev=1164533&r1=1164532&r2=1164533&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/test/java/org/apache/manifoldcf/scriptengine/tests/ExpressionTest.java
(original)
+++ incubator/lcf/trunk/framework/script-engine/src/test/java/org/apache/manifoldcf/scriptengine/tests/ExpressionTest.java
Fri Sep  2 13:51:28 2011
@@ -30,10 +30,114 @@ public class ExpressionTest extends Scri
     throws Exception
   {
     VariableReference vr;
+    
+    // Binary +
     vr = evaluateExpression("1+2");
     assertNotNull(vr);
     assertEquals(vr.resolve().getIntValue(),3);
-    // MHL
+    
+    // Binary -
+    vr = evaluateExpression("1-2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),-1);
+
+    // Binary *
+    vr = evaluateExpression("2*3");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),6);
+
+    // Binary /
+    vr = evaluateExpression("3/2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),1);
+
+    // Unary -
+    vr = evaluateExpression("-2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),-2);
+
+    // Binary &
+    vr = evaluateExpression("1&5");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),1);
+
+    // Binary |
+    vr = evaluateExpression("1|2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),3);
+
+    // Unary !
+    vr = evaluateExpression("!2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),2^2);
+
+    // >
+    vr = evaluateExpression("1>1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),false);
+    vr = evaluateExpression("2>1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),true);
+
+    // >=
+    vr = evaluateExpression("0>=1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),false);
+    vr = evaluateExpression("1>=1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),true);
+
+    // <
+    vr = evaluateExpression("2<2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),false);
+    vr = evaluateExpression("1<2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),true);
+
+    // <=
+    vr = evaluateExpression("2<=1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),false);
+    vr = evaluateExpression("1<=1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),true);
+
+    // ==
+    vr = evaluateExpression("1==2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),false);
+    vr = evaluateExpression("1==1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),true);
+
+    // !=
+    vr = evaluateExpression("1!=1");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),false);
+    vr = evaluateExpression("1!=2");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getBooleanValue(),true);
+
+    // Attributes
+    vr = evaluateExpression("2 .__int__");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getIntValue(),2);
+    vr = evaluateExpression("2 .__string__");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getStringValue(),"2");
+    vr = evaluateExpression("2 .__float__");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getDoubleValue(),2.0,0.0);
+    vr = evaluateExpression("2 .__script__");
+    assertNotNull(vr);
+    assertEquals(vr.resolve().getStringValue(),"2");
+
+    // Various values
+    assertEquals(new VariableInt(2).getIntValue(),2);
+    assertEquals(new VariableInt(2).getStringValue(),"2");
+    assertEquals(new VariableInt(2).getDoubleValue(),2.0,0.0);
+
   }
 
 }



Mime
View raw message