OLD | NEW |
1 String.replace(…) test | 1 String.replace(…) test |
2 | 2 |
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". |
4 | 4 |
5 | 5 |
6 PASS testString is "It's the end of the world as we know it, and I feel fine." | 6 PASS testString is "It's the end of the world as we know it, and I feel fine." |
7 PASS testString.replace('end','BEGINNING') is "It's the BEGINNING of the world a
s we know it, and I feel fine." | 7 PASS testString.replace('end','BEGINNING') is "It's the BEGINNING of the world a
s we know it, and I feel fine." |
8 PASS testString.replace(/[aeiou]/gi,'-') is "-t's th- -nd -f th- w-rld -s w- kn-
w -t, -nd - f--l f-n-." | 8 PASS testString.replace(/[aeiou]/gi,'-') is "-t's th- -nd -f th- w-rld -s w- kn-
w -t, -nd - f--l f-n-." |
9 PASS testString.replace(/[aeiou]/gi, function Capitalize(s){ return s.toUpperCas
e(); }) is "It's thE End Of thE wOrld As wE knOw It, And I fEEl fInE." | 9 PASS testString.replace(/[aeiou]/gi, function Capitalize(s){ return s.toUpperCas
e(); }) is "It's thE End Of thE wOrld As wE knOw It, And I fEEl fInE." |
10 PASS testString.replace(/([aeiou])([a-z])/g, function Capitalize(){ return RegEx
p.$1.toUpperCase()+RegExp.$2; }) is "It's the End Of the wOrld As we knOw It, An
d I fEel fIne." | 10 FAIL testString.replace(/([aeiou])([a-z])/g, function Capitalize(){ return RegEx
p.$1.toUpperCase()+RegExp.$2; }) should be It's the End Of the wOrld As we knOw
It, And I fEel fIne.. Was It's the Ind In the wInld In we knIn In, Ind I fInl fI
ne.. |
11 PASS testString.replace(/([aeiou])([a-z])/g, function Capitalize(orig,re1,re2) {
return re1.toUpperCase()+re2; }) is "It's the End Of the wOrld As we knOw It, A
nd I fEel fIne." | 11 PASS testString.replace(/([aeiou])([a-z])/g, function Capitalize(orig,re1,re2) {
return re1.toUpperCase()+re2; }) is "It's the End Of the wOrld As we knOw It, A
nd I fEel fIne." |
12 PASS testString.replace(/(.*)/g, function replaceWithDollars(matchGroup) { retur
n '$1'; }) is "$1$1" | 12 PASS testString.replace(/(.*)/g, function replaceWithDollars(matchGroup) { retur
n '$1'; }) is "$1$1" |
13 PASS testString.replace(/(.)(.*)/g, function replaceWithMultipleDollars(matchGro
up) { return '$1$2'; }) is "$1$2" | 13 PASS testString.replace(/(.)(.*)/g, function replaceWithMultipleDollars(matchGro
up) { return '$1$2'; }) is "$1$2" |
14 PASS testString.replace(/(.)(.*)/, function checkReplacementArguments() { return
arguments.length; }) is "5" | 14 PASS testString.replace(/(.)(.*)/, function checkReplacementArguments() { return
arguments.length; }) is "5" |
15 PASS testReplace(/x/g, false) is "0y1y2" | 15 PASS testReplace(/x/g, false) is "0y1y2" |
16 FAIL testReplace(/x/g, true) should throw an exception. Was 0y1y2. | 16 FAIL testReplace(/x/g, true) should throw an exception. Was 0y1y2. |
17 PASS testReplace(/x/, false) is "0y1x2" | 17 PASS testReplace(/x/, false) is "0y1x2" |
18 PASS testReplace(/x/, true) is "0y1x2" | 18 PASS testReplace(/x/, true) is "0y1x2" |
19 PASS testReplace(/x/g, false); re.lastIndex is 0 | 19 PASS testReplace(/x/g, false); re.lastIndex is 0 |
20 FAIL testReplace(/x/g, true); re.lastIndex should throw an exception. Was 3. | 20 FAIL testReplace(/x/g, true); re.lastIndex should throw an exception. Was 3. |
21 PASS testReplace(/x/, false); re.lastIndex is 3 | 21 PASS testReplace(/x/, false); re.lastIndex is 3 |
22 PASS testReplace(/x/, true); re.lastIndex is 3 | 22 PASS testReplace(/x/, true); re.lastIndex is 3 |
23 PASS testReplace(/x/g, false) is "0y1y2" | 23 PASS testReplace(/x/g, false) is "0y1y2" |
24 FAIL testReplace(/x/g, true) should throw an exception. Was 0y1y2. | 24 FAIL testReplace(/x/g, true) should throw an exception. Was 0y1y2. |
25 PASS testReplace(/x/, false) is "0y1x2" | 25 PASS testReplace(/x/, false) is "0y1x2" |
26 PASS testReplace(/x/, true) is "0y1x2" | 26 PASS testReplace(/x/, true) is "0y1x2" |
27 PASS testReplace(/x/g, false); re.lastIndex is 0 | 27 PASS testReplace(/x/g, false); re.lastIndex is 0 |
28 FAIL testReplace(/x/g, true); re.lastIndex should throw an exception. Was 3. | 28 FAIL testReplace(/x/g, true); re.lastIndex should throw an exception. Was 3. |
29 PASS testReplace(/x/, false); re.lastIndex is 3 | 29 PASS testReplace(/x/, false); re.lastIndex is 3 |
30 PASS testReplace(/x/, true); re.lastIndex is 3 | 30 PASS testReplace(/x/, true); re.lastIndex is 3 |
31 PASS testReplace(/x/g, false) is "01122" | 31 PASS testReplace(/x/g, false) is "01122" |
32 PASS testReplace(/x/g, true) threw exception TypeError: Cannot assign to read on
ly property 'lastIndex' of [object RegExp]. | 32 PASS testReplace(/x/g, true) threw exception TypeError: Cannot assign to read on
ly property 'lastIndex' of object '[object RegExp]'. |
33 PASS testReplace(/x/, false) is "041x2" | 33 PASS testReplace(/x/, false) is "041x2" |
34 PASS testReplace(/x/, true) threw exception TypeError: Cannot assign to read onl
y property 'lastIndex' of [object RegExp]. | 34 PASS testReplace(/x/, true) threw exception TypeError: Cannot assign to read onl
y property 'lastIndex' of object '[object RegExp]'. |
35 PASS testReplace(/x/g, false); re.lastIndex is 2 | 35 PASS testReplace(/x/g, false); re.lastIndex is 2 |
36 PASS testReplace(/x/g, true); re.lastIndex threw exception TypeError: Cannot ass
ign to read only property 'lastIndex' of [object RegExp]. | 36 PASS testReplace(/x/g, true); re.lastIndex threw exception TypeError: Cannot ass
ign to read only property 'lastIndex' of object '[object RegExp]'. |
37 PASS testReplace(/x/, false); re.lastIndex is 4 | 37 PASS testReplace(/x/, false); re.lastIndex is 4 |
38 PASS testReplace(/x/, true); re.lastIndex threw exception TypeError: Cannot assi
gn to read only property 'lastIndex' of [object RegExp]. | 38 PASS testReplace(/x/, true); re.lastIndex threw exception TypeError: Cannot assi
gn to read only property 'lastIndex' of object '[object RegExp]'. |
39 PASS try { testReplace(/x/g, false); throw 0; } catch (e) { }; replacerCalled; i
s true | 39 PASS try { testReplace(/x/g, false); throw 0; } catch (e) { }; replacerCalled; i
s true |
40 FAIL try { testReplace(/x/g, true); throw 0; } catch (e) { }; replacerCalled; sh
ould be false. Was true. | 40 FAIL try { testReplace(/x/g, true); throw 0; } catch (e) { }; replacerCalled; sh
ould be false. Was true. |
41 PASS successfullyParsed is true | 41 PASS successfullyParsed is true |
42 | 42 |
43 TEST COMPLETE | 43 TEST COMPLETE |
44 | 44 |
OLD | NEW |