Rearrange String.prototype.indexOf, lastIndexOf and Replace helpers

Fixes issue #515
JerryScript-DCO-1.0-Signed-off-by: Laszlo Vidacs lvidacs.u-szeged@partner.samsung.com
This commit is contained in:
Laszlo Vidacs
2015-11-23 18:03:49 +01:00
committed by Peter Gal
parent f20db76dfb
commit cd7cf53ecb
4 changed files with 87 additions and 248 deletions
+3 -18
View File
@@ -85,7 +85,7 @@ assert("Hello world, welcome to the universe.".indexOf("welcome", undefined_var)
// check booleans
assert("true".indexOf(true, false) === 0);
// check this is undefined
// check coercible - undefined
try {
String.prototype.indexOf.call(undefined);
assert(false);
@@ -93,7 +93,7 @@ try {
assert(e instanceof TypeError);
}
// check this is null
// check coercible - null
try {
String.prototype.indexOf.call(null);
assert(false);
@@ -101,24 +101,9 @@ try {
assert(e instanceof TypeError);
}
// check coercible - undefined
try {
assert(true.indexOf());
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
// check coercible - null
try {
assert(isNaN(String.prototype.indexOf.call(null, 0)));
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
// check coercible - Boolean
assert(String.prototype.indexOf.call(true, "e") === 3);
assert(String.prototype.indexOf.call(false, "e") === 4);
// check coercible - Object
var test_object = {firstName:"John", lastName:"Doe"};