| function shouldBe(actual, expected) { |
| throw new Error('bad value: ' + actual); |
| function shouldThrow(func, message) { |
| throw new Error("not thrown."); |
| if (String(error) !== message) |
| throw new Error("bad error: " + String(error)); |
| var array = new Array(10); |
| for (var i = 0; i < 10; ++i) { |
| Object.defineProperty(array, index, { |
| throw new Error('get is called.' + index); |
| shouldBe(array.length, 10); |
| // Doesn't throw any errors. |
| var findValue = array.find(function (value) { |
| for (var i = 0; i < 10; ++i) { |
| shouldThrow(function () { |
| }, "Error: get is called." + i); |