Skip to content

Commit 5a80e89

Browse files
committed
Increase test coverage: Array.prototype.indexOf
Branch coverage: Before: 22/26 After: 26/26 JerryScript-DCO-1.0-Signed-off-by: Mate Dabis mdabis@inf.u-szeged.hu
1 parent 0c20f8e commit 5a80e89

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/jerry/array-prototype-indexof.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,36 @@ try {
8686
assert(e.message === "foo");
8787
assert(e instanceof ReferenceError);
8888
}
89+
90+
// Checking behavior when values are unable to find
91+
try{
92+
var a = [undefined,undefined,undefined,undefined,undefined];
93+
for(var i=0; i<a.length; i++)
94+
{delete a[i];}
95+
a.indexOf("bar");
96+
} catch (e) { }
97+
98+
// Checking behavior when value is null
99+
try{
100+
Array.prototype.indexOf.call(null, "asd");
101+
} catch (e) { }
102+
103+
// Checking behavior when length is not a number
104+
try {
105+
var o = {};
106+
Object.defineProperty(o, 'toString', { 'get' : function () { throw new ReferenceError ("foo"); } });
107+
var a = { length : o }
108+
Array.prototype.indexOf.call(a, function () { })
109+
assert (false);
110+
} catch (e) {
111+
assert (e instanceof ReferenceError);
112+
}
113+
114+
// checking behavior when unable to get the first element
115+
try {
116+
var a = [0, 1, 2, 3, 4];
117+
Object.defineProperty(a, '0', { 'get' : function () { throw new ReferenceError; } });
118+
Array.prototype.indexOf.call(a, "bar")
119+
} catch (e) {
120+
assert (e instanceof ReferenceError);
121+
}

0 commit comments

Comments
 (0)