]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/poly-chain-then-setter.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / poly-chain-then-setter.js
diff --git a/tests/stress/poly-chain-then-setter.js b/tests/stress/poly-chain-then-setter.js
new file mode 100644 (file)
index 0000000..cc363b9
--- /dev/null
@@ -0,0 +1,33 @@
+function Cons1() {
+}
+Cons1.prototype.f = 42;
+
+function Cons2() {
+}
+Cons2.prototype.__defineSetter__("f", function(value) {
+    counter++;
+    this._f = value;
+});
+Cons2.prototype.__defineGetter__("f", function() { return this._f; });
+
+function foo(o, value) {
+    o.f = value;
+    return o.f;
+}
+
+noInline(foo);
+
+var counter = 0;
+
+function test(o, value, expectedCount) {
+    var result = foo(o, value);
+    if (result != value)
+        throw new Error("Bad result: " + result);
+    if (counter != expectedCount)
+        throw new Error("Bad counter value: " + counter);
+}
+
+for (var i = 0; i < 100000; ++i) {
+    test(new Cons1(), i, counter);
+    test(new Cons2(), i, counter + 1);
+}