Skip to content

Commit 473e3c9

Browse files
committed
Updated tests to test actual toLocale method and ensure state is reset
1 parent 8ecd28f commit 473e3c9

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

test/Array/toLocaleString.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ accessor-value
5050

5151

5252
11. Array: toLocaleString should throw TypeError on undefined
53-
TypeError : Cannot redefine non-configurable property 'toLocaleString'
53+
TypeError : The value of the property 'toLocaleString' is not a Function object
5454

5555

5656
12. Array: toLocaleString should throw TypeError on invalid function
57-
TypeError : Cannot redefine non-configurable property 'toLocaleString'
57+
TypeError : The value of the property 'toLocaleString' is not a Function object

test/Array/toLocaleString.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -186,34 +186,30 @@ guarded_call(function () {
186186
});
187187

188188
scenario("Array: toLocaleString should use toLocaleString accessor on element");
189+
var originalToLocaleString = String.prototype.toLocaleString;
190+
String.prototype.toLocaleString = function () {
191+
return "accessor-value";
192+
};
189193
var o = ["test"];
190194
guarded_call(function () {
191-
Object.defineProperty(String.prototype, "toLocaleString", {
192-
get() {
193-
return function() { return "accessor-value"; };
194-
}
195-
});
196195
echo(Array.prototype.toLocaleString.apply(o));
197196
});
197+
String.prototype.toLocaleString = originalToLocaleString;
198198

199199
scenario("Array: toLocaleString should throw TypeError on undefined");
200+
var originalToLocaleString = String.prototype.toLocaleString;
201+
String.prototype.toLocaleString = undefined;
200202
var o = ["test"];
201203
guarded_call(function () {
202-
Object.defineProperty(String.prototype, "toLocaleString", {
203-
get() {
204-
return undefined;
205-
}
206-
});
207204
echo(Array.prototype.toLocaleString.apply(o));
208205
});
206+
String.prototype.toLocaleString = originalToLocaleString;
209207

210208
scenario("Array: toLocaleString should throw TypeError on invalid function");
209+
var originalToLocaleString = String.prototype.toLocaleString;
210+
String.prototype.toLocaleString = 0;
211211
var o = ["test"];
212212
guarded_call(function () {
213-
Object.defineProperty(String.prototype, "toLocaleString", {
214-
get() {
215-
return 0;
216-
}
217-
});
218213
echo(Array.prototype.toLocaleString.apply(o));
219214
});
215+
String.prototype.toLocaleString = originalToLocaleString;

0 commit comments

Comments
 (0)