Index: test/mjsunit/harmony/proxies.js |
diff --git a/test/mjsunit/harmony/proxies.js b/test/mjsunit/harmony/proxies.js |
index 3edb2a0ceecc5298dc00614c6c65a5838a13233d..a23427c54a353f8c5d2284e02d4596714a2a0991 100644 |
--- a/test/mjsunit/harmony/proxies.js |
+++ b/test/mjsunit/harmony/proxies.js |
@@ -88,22 +88,22 @@ TestSet(Proxy.create({get: function(pr, pk) { return function(r, k, v) { key = k |
// Comparison. |
-var o1 = Proxy.create({}) |
-var o2 = Proxy.create({}) |
- |
-assertTrue(o1 == o1) |
-assertTrue(o2 == o2) |
-assertTrue(!(o1 == o2)) |
-assertTrue(!(o1 == {})) |
-assertTrue(!({} == o2)) |
-assertTrue(!({} == {})) |
+function TestComparison(eq) { |
+ var o1 = Proxy.create({}) |
+ var o2 = Proxy.create({}) |
+ |
+ assertTrue(eq(o1, o1)) |
+ assertTrue(eq(o2, o2)) |
+ assertTrue(!eq(o1, o2)) |
+ assertTrue(!eq(o1, {})) |
+ assertTrue(!eq({}, o2)) |
+ assertTrue(!eq({}, {})) |
+} |
-assertTrue(o1 === o1) |
-assertTrue(o2 === o2) |
-assertTrue(!(o1 === o2)) |
-assertTrue(!(o1 === {})) |
-assertTrue(!({} === o2)) |
-assertTrue(!({} === {})) |
+TestComparison(function(o1, o2) { return o1 == o2 }) |
+TestComparison(function(o1, o2) { return o1 === o2 }) |
+TestComparison(function(o1, o2) { return !(o1 != o2) }) |
+TestComparison(function(o1, o2) { return !(o1 !== o2) }) |
@@ -114,3 +114,60 @@ assertTrue(typeof Proxy.create({}) == "object") |
assertTrue("object" == typeof Proxy.create({})) |
// No function proxies yet. |
+ |
+ |
+ |
+// Instanceof (instanceof). |
+ |
+function TestInstanceof() { |
+ var o = {} |
+ var p1 = Proxy.create({}) |
+ var p2 = Proxy.create({}, o) |
+ var p3 = Proxy.create({}, p2) |
+ |
+ var f = function() {} |
+ f.prototype = o |
+ var f1 = function() {} |
+ f1.prototype = p1 |
+ var f2 = function() {} |
+ f2.prototype = p2 |
+ |
+ assertTrue(o instanceof Object) |
+ assertFalse(o instanceof f) |
+ assertFalse(o instanceof f1) |
+ assertFalse(o instanceof f2) |
+ assertFalse(p1 instanceof Object) |
+ assertFalse(p1 instanceof f) |
+ assertFalse(p1 instanceof f1) |
+ assertFalse(p1 instanceof f2) |
+ assertTrue(p2 instanceof Object) |
+ assertTrue(p2 instanceof f) |
+ assertFalse(p2 instanceof f1) |
+ assertFalse(p2 instanceof f2) |
+ assertTrue(p3 instanceof Object) |
+ assertTrue(p3 instanceof f) |
+ assertFalse(p3 instanceof f1) |
+ assertTrue(p3 instanceof f2) |
+} |
+ |
+TestInstanceof() |
+ |
+ |
+ |
+// Prototype (Object.getPrototypeOf). |
+ |
+function TestPrototype() { |
+ var o = {} |
+ var p1 = Proxy.create({}) |
+ var p2 = Proxy.create({}, o) |
+ var p3 = Proxy.create({}, p2) |
+ var p4 = Proxy.create({}, 666) |
+ |
+ assertSame(Object.getPrototypeOf(o), Object.prototype) |
+ assertSame(Object.getPrototypeOf(p1), null) |
+ assertSame(Object.getPrototypeOf(p2), o) |
+ assertSame(Object.getPrototypeOf(p3), p2) |
+ assertSame(Object.getPrototypeOf(p4), null) |
+} |
+ |
+TestPrototype() |