]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - API/tests/testapi.js
JavaScriptCore-1097.13.tar.gz
[apple/javascriptcore.git] / API / tests / testapi.js
index 15c9e50db22e7da230f2bb895bd017bb38912bde..28fa5443393558043cc2166f6e2cd6efb34615c5 100644 (file)
@@ -94,6 +94,9 @@ shouldBe("MyObject('throwOnCall')", "an exception");
 shouldBe("new MyObject('throwOnConstruct')", "an exception");
 shouldBe("'throwOnHasInstance' instanceof MyObject", "an exception");
 
+MyObject.nullGetForwardSet = 1;
+shouldBe("MyObject.nullGetForwardSet", 1);
+
 var foundMyPropertyName = false;
 var foundRegularType = false;
 for (var p in MyObject) {
@@ -151,9 +154,11 @@ shouldBe("MyObject()", undefined);
 shouldBe("typeof myObject", "object");
 shouldBe("MyObject ? 1 : 0", true); // toBoolean
 shouldBe("+MyObject", 1); // toNumber
+shouldBe("(Object.prototype.toString.call(MyObject))", "[object MyObject]"); // Object.prototype.toString
 shouldBe("(MyObject.toString())", "[object MyObject]"); // toString
-shouldBe("String(MyObject)", "MyObjectAsString"); // type conversion to string
+shouldBe("String(MyObject)", "MyObjectAsString"); // toString
 shouldBe("MyObject - 0", 1); // toNumber
+shouldBe("MyObject.valueOf()", 1); // valueOf
 
 shouldBe("typeof MyConstructor", "object");
 constructedObject = new MyConstructor(1);
@@ -162,8 +167,10 @@ shouldBe("constructedObject.value", 1);
 shouldBe("myObject instanceof MyObject", true);
 shouldBe("(new Object()) instanceof MyObject", false);
 
-shouldThrow("MyObject.nullGetSet = 1");
-shouldThrow("MyObject.nullGetSet");
+shouldThrow("new MyBadConstructor()");
+
+MyObject.nullGetSet = 1;
+shouldBe("MyObject.nullGetSet", 1);
 shouldThrow("MyObject.nullCall()");
 shouldThrow("MyObject.hasPropertyLie");
 
@@ -181,6 +188,8 @@ shouldBe("derived.protoOnly()", 2);
 shouldBe("derived.protoDup", 2);
 shouldBe("derived.derivedOnly", 2)
 
+shouldBe("derived.baseHardNull()", undefined)
+
 // base properties throw 1 when set; derived, 2
 shouldBe("derived.baseDup = 0", 2);
 shouldBe("derived.baseOnly = 0", 1);
@@ -246,6 +255,32 @@ shouldThrow("String(EvilExceptionObject)");
 
 shouldBe("EmptyObject", "[object CallbackObject]");
 
+for (var i = 0; i < 6; ++i)
+    PropertyCatchalls.x = i;
+shouldBe("PropertyCatchalls.x", 4);
+
+for (var i = 0; i < 6; ++i)
+    var x = PropertyCatchalls.x;
+shouldBe("x", null);
+
+for (var i = 0; i < 10; ++i) {
+    for (var p in PropertyCatchalls) {
+        if (p == "x")
+            continue;
+        shouldBe("p", i % 10);
+        break;
+    }
+}
+
+PropertyCatchalls.__proto__ = { y: 1 };
+for (var i = 0; i < 6; ++i)
+    var y = PropertyCatchalls.y;
+shouldBe("y", null);
+
+var o = { __proto__: PropertyCatchalls };
+for (var i = 0; i < 6; ++i)
+    var z = PropertyCatchalls.z;
+shouldBe("z", null);
+
 if (failed)
     throw "Some tests failed";
-