Index: test/webkit/fast/js/array-bad-time.js |
diff --git a/test/webkit/dfg-peephole-compare-final-object-to-final-object-or-other-when-both-proven-final-object.js b/test/webkit/fast/js/array-bad-time.js |
similarity index 67% |
copy from test/webkit/dfg-peephole-compare-final-object-to-final-object-or-other-when-both-proven-final-object.js |
copy to test/webkit/fast/js/array-bad-time.js |
index f8a67946a2124262a6602a082d65a5e1e72925c0..1d3802eda32068b68da29bea17ff7678bdf3bcb2 100644 |
--- a/test/webkit/dfg-peephole-compare-final-object-to-final-object-or-other-when-both-proven-final-object.js |
+++ b/test/webkit/fast/js/array-bad-time.js |
@@ -22,25 +22,34 @@ |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
description( |
-"Tests that the peephole CompareEq optimization for the case where one side is predicted final object and the other side is predicted either final object or other (i.e. null or undefined) doesn't assert when both sides are also proven final object." |
+"Tests that defining a setter on the Array prototype works even if it is done after arrays are allocated." |
); |
-function foo(a, b) { |
+var ouches = 0; |
+ |
+function foo(haveABadTime) { |
var result = []; |
- result.push(a.f); |
- result.push(b.f); |
- if (a == b) |
- result.push(true); |
- else |
- result.push(false); |
+ result.length = 5; |
+ for (var i = 0; i < result.length; ++i) { |
+ if (i == haveABadTime) { |
+ debug("Henceforth I will have a bad time."); |
+ Array.prototype.__defineSetter__("3", function() { debug("Ouch!"); ouches++; }); |
+ } |
+ result[i] = i; |
+ } |
return result; |
} |
-for (var i = 0; i < 100; ++i) { |
- if (i%2) { |
- var o = {f:42}; |
- shouldBe("foo(o, o)", "[42, 42, true]"); |
+var expected = "\"0,1,2,3,4\""; |
+ |
+for (var i = 0; i < 1000; ++i) { |
+ var haveABadTime; |
+ if (i == 950) { |
+ haveABadTime = 2; |
+ expected = "\"0,1,2,,4\""; |
} else |
- shouldThrow("foo({f:42}, null)"); |
+ haveABadTime = -1; |
+ shouldBe("\"" + foo(haveABadTime).join(",") + "\"", expected); |
} |
+shouldBe("ouches", "50"); |