Skip to content

Commit 74bd487

Browse files
committed
Increase test coverage: Array.prototype.toLocaleString
Branch coverage: Before: 15/18 After: 18/18 JerryScript-DCO-1.0-Signed-off-by: Mate Dabis [email protected]
1 parent c23cf41 commit 74bd487

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/jerry/array-prototype-tolocalestring.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,38 @@ try {
5454
assert (e.message === "foo");
5555
assert (e instanceof ReferenceError);
5656
}
57+
58+
/* ES 5.1 15.4.4.3 1. */
59+
// Checking behavior when the function's this_argument is null
60+
try {
61+
Array.prototype.toLocaleString.call(null);
62+
assert(false);
63+
} catch (e) {
64+
assert(e instanceof TypeError);
65+
}
66+
67+
/* ES 5.1 15.4.4.3 2. */
68+
// Checking behavior when length throws error
69+
try {
70+
var obj = {};
71+
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError("foo"); } });
72+
Array.prototype.toLocaleString.call(obj);
73+
assert(false);
74+
} catch (e) {
75+
assert(e instanceof ReferenceError);
76+
assert(e.message == "foo");
77+
}
78+
79+
/* ES 5.1 15.4.4.3 3. */
80+
// Checking behavior when length is an object, which has a valueOf method that throws an error
81+
var len = { };
82+
Object.defineProperty(len, 'valueOf', { 'get' : function () { throw new ReferenceError("vOf"); } });
83+
var obj = { toLocaleString : Array.prototype.toLocaleString, length : len };
84+
85+
try {
86+
obj.toLocaleString();
87+
assert(false);
88+
} catch (e) {
89+
assert(e.message === 'vOf');
90+
assert(e instanceof ReferenceError);
91+
}

0 commit comments

Comments
 (0)