Unreviewed, rolling out r194328.
[WebKit-https.git] / LayoutTests / js / dom / script-tests / string-prototype-properties.js
1 description(
2 'This is a test case for <a https://bugs.webkit.org/show_bug.cgi?id=64677">bug 64677</a>.'
3 );
4
5 // These calls pass undefined as this value, and as such should show in toObject.
6 shouldThrow("String.prototype.toString.call(undefined)");
7 shouldThrow("String.prototype.valueOf.call(undefined)");
8 shouldThrow("String.prototype.charAt.call(undefined, 0)");
9 shouldThrow("String.prototype.charCodeAt.call(undefined, 0)");
10 shouldThrow("String.prototype.concat.call(undefined, 'five')");
11 shouldThrow("String.prototype.indexOf.call(undefined, '2')");
12 shouldThrow("String.prototype.lastIndexOf.call(undefined, '2')");
13 shouldThrow("String.prototype.match.call(undefined, /2+/)");
14 shouldThrow("String.prototype.replace.call(undefined, /2+/, '-')");
15 shouldThrow("String.prototype.search.call(undefined, '4')");
16 shouldThrow("String.prototype.slice.call(undefined, 1, 3)");
17 shouldThrow("String.prototype.split.call(undefined, '2')");
18 shouldThrow("String.prototype.slice.call(undefined, 1, 3)");
19 shouldThrow("String.prototype.substr.call(undefined, 1, 3)");
20 shouldThrow("String.prototype.substring.call(undefined, 1, 3)");
21 shouldThrow("String.prototype.toLowerCase.call(undefined)");
22 shouldThrow("String.prototype.toUpperCase.call(undefined)");
23 shouldThrow("String.prototype.localeCompare.call(undefined, '1224')");
24 shouldThrow("String.prototype.toLocaleLowerCase.call(undefined)");
25 shouldThrow("String.prototype.toLocaleUpperCase.call(undefined)");
26 shouldThrow("String.prototype.trim.call(undefined)");
27
28 // These calls pass a primitive number as this value, toString and valueOf
29 // should throw, all other method should convert ToString, without converting
30 // via the Number object type.
31 shouldThrow("String.prototype.toString.call(1224)");
32 shouldThrow("String.prototype.valueOf.call(1224)");
33 var numberPrototypeToString = Number.prototype.toString;
34 Number.prototype.toString = (function(){ throw "SHOULD NOT BE REACHED"; });
35 shouldBe("String.prototype.charAt.call(1224, 0)", '"1"');
36 shouldBe("String.prototype.charCodeAt.call(1224, 0)", '0x31');
37 shouldBe("String.prototype.concat.call(1224, 'five')", '"1224five"');
38 shouldBe("String.prototype.indexOf.call(1224, '2')", '1');
39 shouldBe("String.prototype.lastIndexOf.call(1224, '2')", '2');
40 shouldBe("String.prototype.match.call(1224, /2+/)", '["22"]');
41 shouldBe("String.prototype.replace.call(1224, /2+/, '-')", '"1-4"');
42 shouldBe("String.prototype.search.call(1224, '4')", '3');
43 shouldBe("String.prototype.slice.call(1224, 1, 3)", '"22"');
44 shouldBe("String.prototype.split.call(1224, '2')", '["1","","4"]');
45 shouldBe("String.prototype.slice.call(1224, 1, 3)", '"22"');
46 shouldBe("String.prototype.substr.call(1224, 1, 3)", '"224"');
47 shouldBe("String.prototype.substring.call(1224, 1, 3)", '"22"');
48 shouldBe("String.prototype.toLowerCase.call(1224)", '"1224"');
49 shouldBe("String.prototype.toUpperCase.call(1224)", '"1224"');
50 shouldBe("String.prototype.localeCompare.call(1224, '1224')", '0');
51 shouldBe("String.prototype.toLocaleLowerCase.call(1224)", '"1224"');
52 shouldBe("String.prototype.toLocaleUpperCase.call(1224)", '"1224"');
53 shouldBe("String.prototype.trim.call(1224)", '"1224"');
54 Number.prototype.toString = numberPrototypeToString;