Skip to content

Commit 8ecd28f

Browse files
committed
Update tests for Array.toLocaleString
1 parent 23f475e commit 8ecd28f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

test/Array/toLocaleString.baseline

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,15 @@ TypeError : The value of the property 'toLocaleString' is not a Function object
4343

4444
9. Array: toLocaleString should use length property
4545
10.00, 20.00, 30.00, , ,
46+
47+
48+
10. Array: toLocaleString should use toLocaleString accessor on element
49+
accessor-value
50+
51+
52+
11. Array: toLocaleString should throw TypeError on undefined
53+
TypeError : Cannot redefine non-configurable property 'toLocaleString'
54+
55+
56+
12. Array: toLocaleString should throw TypeError on invalid function
57+
TypeError : Cannot redefine non-configurable property 'toLocaleString'

test/Array/toLocaleString.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,36 @@ guarded_call(function () {
184184
echo(output);
185185
}
186186
});
187+
188+
scenario("Array: toLocaleString should use toLocaleString accessor on element");
189+
var o = ["test"];
190+
guarded_call(function () {
191+
Object.defineProperty(String.prototype, "toLocaleString", {
192+
get() {
193+
return function() { return "accessor-value"; };
194+
}
195+
});
196+
echo(Array.prototype.toLocaleString.apply(o));
197+
});
198+
199+
scenario("Array: toLocaleString should throw TypeError on undefined");
200+
var o = ["test"];
201+
guarded_call(function () {
202+
Object.defineProperty(String.prototype, "toLocaleString", {
203+
get() {
204+
return undefined;
205+
}
206+
});
207+
echo(Array.prototype.toLocaleString.apply(o));
208+
});
209+
210+
scenario("Array: toLocaleString should throw TypeError on invalid function");
211+
var o = ["test"];
212+
guarded_call(function () {
213+
Object.defineProperty(String.prototype, "toLocaleString", {
214+
get() {
215+
return 0;
216+
}
217+
});
218+
echo(Array.prototype.toLocaleString.apply(o));
219+
});

0 commit comments

Comments
 (0)