Skip to content

Commit c15e190

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 c15e190

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/jerry/array-prototype-tolocalestring.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,33 @@ try {
5454
assert (e.message === "foo");
5555
assert (e instanceof ReferenceError);
5656
}
57+
58+
// Checking behavior when null is passed to the function
59+
try {
60+
Array.prototype.toLocaleString.call(null);
61+
} catch (e) {
62+
assert(e instanceof TypeError);
63+
}
64+
65+
// Checking behavior when null is passed to the function
66+
try {
67+
var obj = {};
68+
Object.defineProperty(obj, 'length', { 'get' : function () { throw new ReferenceError ("foo"); } });
69+
Array.prototype.toLocaleString.call(obj);
70+
assert(false);
71+
} catch (e) {
72+
assert(e instanceof ReferenceError);
73+
}
74+
75+
// Checking behavior when length is an object, wichs valueOf throws error
76+
var len = { };
77+
Object.defineProperty(len, 'valueOf', { 'get' : function () { throw new ReferenceError ("foo"); } });
78+
var obj = { toLocaleString : Array.prototype.toLocaleString, length : len };
79+
80+
try {
81+
obj.toLocaleString();
82+
assert(false);
83+
} catch (e) {
84+
assert(e.message === 'foo');
85+
assert(e instanceof ReferenceError);
86+
}

0 commit comments

Comments
 (0)