|
@@ -129,6 +129,13 @@ public class EqualsTests extends ScriptTestCase {
|
|
|
assertEquals(0, exec("def a = 1; Object b = new HashMap(); if (a === (Object)b) return 1; else return 0;"));
|
|
|
}
|
|
|
|
|
|
+ public void testBranchEqualsDefAndPrimitive() {
|
|
|
+ assertEquals(true, exec("def x = 1000; int y = 1000; return x == y;"));
|
|
|
+ assertEquals(false, exec("def x = 1000; int y = 1000; return x === y;"));
|
|
|
+ assertEquals(true, exec("def x = 1000; int y = 1000; return y == x;"));
|
|
|
+ assertEquals(false, exec("def x = 1000; int y = 1000; return y === x;"));
|
|
|
+ }
|
|
|
+
|
|
|
public void testBranchNotEquals() {
|
|
|
assertEquals(1, exec("def a = (char)'a'; def b = (char)'b'; if (a != b) return 1; else return 0;"));
|
|
|
assertEquals(0, exec("def a = (char)'a'; def b = (char)'a'; if (a != b) return 1; else return 0;"));
|
|
@@ -139,6 +146,13 @@ public class EqualsTests extends ScriptTestCase {
|
|
|
assertEquals(1, exec("def a = 1; Object b = new HashMap(); if (a !== (Object)b) return 1; else return 0;"));
|
|
|
}
|
|
|
|
|
|
+ public void testBranchNotEqualsDefAndPrimitive() {
|
|
|
+ assertEquals(false, exec("def x = 1000; int y = 1000; return x != y;"));
|
|
|
+ assertEquals(true, exec("def x = 1000; int y = 1000; return x !== y;"));
|
|
|
+ assertEquals(false, exec("def x = 1000; int y = 1000; return y != x;"));
|
|
|
+ assertEquals(true, exec("def x = 1000; int y = 1000; return y !== x;"));
|
|
|
+ }
|
|
|
+
|
|
|
public void testRightHandNull() {
|
|
|
assertEquals(false, exec("HashMap a = new HashMap(); return a == null;"));
|
|
|
assertEquals(false, exec("HashMap a = new HashMap(); return a === null;"));
|