]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/array-find-does-not-lookup-twice.js
1 function shouldBe(actual
, expected
) {
2 if (actual
!== expected
)
3 throw new Error('bad value: ' + actual
);
6 function shouldThrow(func
, message
) {
14 throw new Error("not thrown.");
15 if (String(error
) !== message
)
16 throw new Error("bad error: " + String(error
));
19 var array
= new Array(10);
21 for (var i
= 0; i
< 10; ++i
) {
24 Object
.defineProperty(array
, index
, {
27 throw new Error('get is called.' + index
);
35 shouldBe(array
.length
, 10);
37 // Doesn't throw any errors.
38 var findValue
= array
.find(function (value
) {
41 shouldBe(findValue
, 9);
43 for (var i
= 0; i
< 10; ++i
) {
44 shouldThrow(function () {
46 }, "Error: get is called." + i
);