blob: fccf373f7d74519a70921a0809b1d2420b4ea4c7 [file] [log] [blame]
String.replace(…) test
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS testString is "It's the end of the world as we know it, and I feel fine."
PASS testString.replace('end','BEGINNING') is "It's the BEGINNING of the world as we know it, and I feel fine."
PASS testString.replace(/[aeiou]/gi,'-') is "-t's th- -nd -f th- w-rld -s w- kn-w -t, -nd - f--l f-n-."
PASS testString.replace(/[aeiou]/gi, function Capitalize(s){ return s.toUpperCase(); }) is "It's thE End Of thE wOrld As wE knOw It, And I fEEl fInE."
PASS testString.replace(/([aeiou])([a-z])/g, function Capitalize(){ return RegExp.$1.toUpperCase()+RegExp.$2; }) is "It's the End Of the wOrld As we knOw It, And I fEel fIne."
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, And I fEel fIne."
PASS testString.replace(/(.*)/g, function replaceWithDollars(matchGroup) { return '$1'; }) is "$1$1"
PASS testString.replace(/(.)(.*)/g, function replaceWithMultipleDollars(matchGroup) { return '$1$2'; }) is "$1$2"
PASS testString.replace(/(.)(.*)/, function checkReplacementArguments() { return arguments.length; }) is "5"
PASS testReplace(/x/g, false) is "0y1y2"
PASS testReplace(/x/g, true) threw exception TypeError: Attempted to assign to readonly property..
PASS testReplace(/x/, false) is "0y1x2"
PASS testReplace(/x/, true) is "0y1x2"
PASS testReplace(/x/g, false); re.lastIndex is 0
PASS testReplace(/x/g, true); re.lastIndex threw exception TypeError: Attempted to assign to readonly property..
PASS testReplace(/x/, false); re.lastIndex is 3
PASS testReplace(/x/, true); re.lastIndex is 3
PASS testReplace(/x/g, false) is "0y1y2"
PASS testReplace(/x/g, true) threw exception TypeError: Attempted to assign to readonly property..
PASS testReplace(/x/, false) is "0y1x2"
PASS testReplace(/x/, true) is "0y1x2"
PASS testReplace(/x/g, false); re.lastIndex is 0
PASS testReplace(/x/g, true); re.lastIndex threw exception TypeError: Attempted to assign to readonly property..
PASS testReplace(/x/, false); re.lastIndex is 3
PASS testReplace(/x/, true); re.lastIndex is 3
PASS testReplace(/x/g, false) is "01122"
PASS testReplace(/x/g, true) threw exception TypeError: Attempted to assign to readonly property..
PASS testReplace(/x/, false) is "041x2"
PASS testReplace(/x/, true) threw exception TypeError: Attempted to assign to readonly property..
PASS testReplace(/x/g, false); re.lastIndex is 2
PASS testReplace(/x/g, true); re.lastIndex threw exception TypeError: Attempted to assign to readonly property..
PASS testReplace(/x/, false); re.lastIndex is 4
PASS testReplace(/x/, true); re.lastIndex threw exception TypeError: Attempted to assign to readonly property..
PASS try { testReplace(/x/g, false); throw 0; } catch (e) { }; replacerCalled; is true
PASS try { testReplace(/x/g, true); throw 0; } catch (e) { }; replacerCalled; is false
PASS successfullyParsed is true
TEST COMPLETE