Skip to content

Commit f833585

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 f833585

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/jerry/array-prototype-tolocalestring.js

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

0 commit comments

Comments
 (0)