]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/exception-in-to-property-key-should-be-handled-early.js
4 throw new Error("propertyKey.toString is called.");
8 function shouldThrow(func
, message
) {
16 throw new Error("not thrown.");
17 if (String(error
) !== message
)
18 throw new Error("bad error: " + String(error
));
24 var toStringCalled
= false;
27 toStringCalled
= true;
37 Object
.defineProperty(object
, '', {
39 called
= "getter for '' is called.";
43 function test(object
, property
) {
48 shouldThrow(function () { test(object
, propertyKey
); }, "Error: propertyKey.toString is called.");
50 throw new Error(called
);
51 toStringCalled
= false;
52 shouldThrow(function () { test(null, propertyKey
); }, "TypeError: null is not an object (evaluating 'object[property]')");
54 throw new Error("toString is called.");
60 var toStringCalled
= false;
63 toStringCalled
= true;
69 called
= "getter for '' is called.";
72 called
= "setter for '' is called.";
81 function test(object
, property
) {
86 for (var i
= 0; i
< 10000; ++i
)
87 test(object
, property
);
89 shouldThrow(function () { test(object
, propertyKey
); }, "Error: propertyKey.toString is called.");
91 throw new Error(called
);
92 toStringCalled
= false;
93 shouldThrow(function () { test(null, propertyKey
); }, "TypeError: null is not an object (evaluating 'object[property]')");
95 throw new Error("toString is called.");
102 var toStringCalled
= false;
105 toStringCalled
= true;
109 function test(array
, length
, property
) {
111 for (var i
= 0; i
< length
; ++i
)
112 result
+= array
[property
];
117 Object
.defineProperty(String
.prototype, "", {
119 called
= "getter for '' is called.";
123 var array
= [1, 2, 3];
124 for (var i
= 0; i
< 100000; ++i
)
125 test(array
, array
.length
, 0);
127 var array
= [1, false, 3];
128 for (var i
= 0; i
< 100000; ++i
)
129 test(array
, array
.length
, 1);
131 test("hello", "hello".length
, 2);
132 shouldThrow(function () { test("hello", "hello".length
, propertyKey
); }, "Error: propertyKey.toString is called.");
134 throw new Error(called
);
135 toStringCalled
= false;
136 shouldThrow(function () { test(null, 20, propertyKey
); }, "TypeError: null is not an object (near '...for (var i = 0; i < length; ++i)...')");
138 throw new Error("toString is called.");