blob: 729ee8706283c629ff7a13b2e07f0690c1b0854f [file] [log] [blame]
This test checks the ES6 string functions startsWith(), endsWith(), and includes().
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS String.prototype.includes.name is 'includes'
PASS String.prototype.includes.length is 1
PASS 'foo bar'.includes('bar') is true
PASS 'foo bar'.includes('bar', 4) is true
PASS 'foo bar'.includes('ar', 5) is true
PASS 'foo bar'.includes('qux') is false
PASS 'foo bar'.includes('foo') is true
PASS 'foo bar'.includes('foo', 0) is true
PASS 'foo bar'.includes('foo', -1) is true
PASS 'foo bar'.includes('') is true
PASS 'foo bar'.includes() is false
PASS 'foo bar qux'.includes('qux', 7) is true
PASS 'foo bar qux'.includes('bar', 7) is false
PASS 'foo null bar'.includes() is false
PASS 'foo null bar'.includes(null) is true
PASS 'foo null bar'.includes(null) is true
PASS 'foo undefined bar'.includes() is true
PASS 'foo undefined bar'.includes(undefined) is true
PASS 'foo undefined bar'.includes() is true
PASS 'foo undefined bar'.includes() is true
PASS 'foo true bar'.includes(true) is true
PASS 'foo false bar'.includes(false) is true
PASS 'foo 1 bar'.includes(1) is true
PASS 'foo 1.1 bar'.includes(1.1) is true
PASS 'foo NaN bar'.includes(NaN) is true
PASS 'foo 1.0 bar'.includes(1.0) is true
PASS 'foo 1e+100 bar'.includes(1e+100) is true
PASS 'foo 1e100 bar'.includes(1e100) is false
PASS 'フーバー'.includes('ーバ') is true
PASS 'フーバー'.includes('クー') is false
PASS 'abc'.includes('a', 'abc'.length) is false
PASS 'abc'.includes('a', Math.pow(2, 33)) is false
PASS 'abc'.includes('a', Infinity) is false
PASS 'abc'.includes('ab', -Infinity) is true
PASS 'abc'.includes('cd', -Infinity) is false
PASS 'abc'.includes('ab', 0) is true
PASS 'abc'.includes('cd', 0) is false
PASS String.prototype.startsWith.name is 'startsWith'
PASS String.prototype.startsWith.length is 1
PASS 'foo bar'.startsWith('foo') is true
PASS 'foo bar'.startsWith('foo', 0) is true
PASS 'foo bar'.startsWith('foo', -1) is true
PASS 'foo bar'.startsWith('oo', 1) is true
PASS 'foo bar'.startsWith('qux') is false
PASS 'foo bar'.startsWith('') is true
PASS 'foo bar'.startsWith() is false
PASS 'null'.startsWith() is false
PASS 'null'.startsWith(null) is true
PASS 'null bar'.startsWith(null) is true
PASS 'undefined'.startsWith() is true
PASS 'undefined'.startsWith(undefined) is true
PASS 'undefined bar'.startsWith() is true
PASS 'undefined bar'.startsWith() is true
PASS 'true bar'.startsWith(true) is true
PASS 'false bar'.startsWith(false) is true
PASS '1 bar'.startsWith(1) is true
PASS '1.1 bar'.startsWith(1.1) is true
PASS 'NaN bar'.startsWith(NaN) is true
PASS '1e+100 bar'.startsWith(1e+100) is true
PASS '1e100 bar'.startsWith(1e100) is false
PASS 'フーバー'.startsWith('フー') is true
PASS 'フーバー'.startsWith('バー') is false
PASS 'フーバー'.startsWith('abc') is false
PASS 'フーバー'.startsWith('abc', 1) is false
PASS 'foo bar'.startsWith('フー') is false
PASS 'foo bar'.startsWith('フー', 1) is false
PASS 'abc'.startsWith('a', Infinity) is false
PASS 'abc'.startsWith('a', 1) is false
PASS 'abc'.startsWith('b', 1) is true
PASS 'abc'.startsWith('b', 2) is false
PASS 'abc'.startsWith('c', 2) is true
PASS 'abc'.startsWith('a', Math.pow(2, 33)) is false
PASS String.prototype.endsWith.name is 'endsWith'
PASS String.prototype.endsWith.length is 1
PASS 'foo bar'.endsWith('bar') is true
PASS 'foo bar'.endsWith('ba', 6) is true
PASS 'foo bar'.endsWith(' ba', 6) is true
PASS 'foo bar'.endsWith('foo bar') is true
PASS 'foo bar'.endsWith('foo bar', 7) is true
PASS 'foo bar'.endsWith('foo bar', 8) is true
PASS 'foo bar'.endsWith('foo bar', -1) is false
PASS 'foo bar'.endsWith('qux') is false
PASS 'foo bar'.endsWith('') is true
PASS 'foo bar'.endsWith() is false
PASS 'foo null'.endsWith() is false
PASS 'foo null'.endsWith(null) is true
PASS 'foo null'.endsWith(null) is true
PASS 'foo undefined'.endsWith() is true
PASS 'foo undefined'.endsWith(undefined) is true
PASS 'foo undefined'.endsWith() is true
PASS 'foo undefined'.endsWith() is true
PASS 'foo true'.endsWith(true) is true
PASS 'foo false'.endsWith(false) is true
PASS 'foo 1'.endsWith(1) is true
PASS 'foo 1.1'.endsWith(1.1) is true
PASS 'foo NaN'.endsWith(NaN) is true
PASS 'foo 1e+100'.endsWith(1e+100) is true
PASS 'foo 1e100'.endsWith(1e100) is false
PASS 'フーバー'.endsWith('バー') is true
PASS 'フーバー'.endsWith('フー') is false
PASS 'フーバー'.endsWith('abc') is false
PASS 'フーバー'.endsWith('abc') is false
PASS 'foo bar'.endsWith('フー') is false
PASS 'foo bar'.endsWith('フー', 3) is false
PASS 'abc'.endsWith('bc', Infinity) is true
PASS 'abc'.endsWith('bc', Math.pow(2, 33)) is true
PASS 'abc'.endsWith('a', 0) is false
PASS 'abc'.endsWith('a', 1) is true
PASS 'abc'.endsWith('b', 1) is false
PASS 'abc'.endsWith('b', 2) is true
PASS 'abc'.endsWith('bc', 2) is false
PASS 'abc'.endsWith('bc', 3) is true
PASS (function() { var f = String.prototype.startsWith; (function() { f('a'); })(); })() threw exception TypeError: Type error.
PASS (function() { var f = String.prototype.endsWith; (function() { f('a'); })(); })() threw exception TypeError: Type error.
PASS (function() { var f = String.prototype.includes; (function() { f('a'); })(); })() threw exception TypeError: Type error.
PASS 'foo bar'.startsWith(/w+/) threw exception TypeError: Argument to String.prototype.startsWith cannot be a RegExp.
PASS 'foo bar'.endsWith(/w+/) threw exception TypeError: Argument to String.prototype.endsWith cannot be a RegExp.
PASS 'foo bar'.includes(/w+/) threw exception TypeError: Argument to String.prototype.includes cannot be a RegExp.
PASS stringToSearchIn.startsWith(searchString, startOffset) is true
PASS sideEffect == 'ABC' is true
PASS stringToSearchIn.startsWith(searchString, startOffset) threw exception error.
PASS sideEffect == '' is true
PASS stringToSearchIn.startsWith(searchString, startOffset) threw exception error.
PASS sideEffect == 'A' is true
PASS stringToSearchIn.startsWith(searchString, startOffset) threw exception error.
PASS sideEffect == 'AB' is true
PASS stringToSearchIn.endsWith(searchString, endOffset) is true
PASS sideEffect == 'ABC' is true
PASS stringToSearchIn.endsWith(searchString, endOffset) threw exception error.
PASS sideEffect == '' is true
PASS stringToSearchIn.endsWith(searchString, endOffset) threw exception error.
PASS sideEffect == 'A' is true
PASS stringToSearchIn.endsWith(searchString, endOffset) threw exception error.
PASS sideEffect == 'AB' is true
PASS stringToSearchIn.includes(searchString, startOffset) is true
PASS sideEffect == 'ABC' is true
PASS stringToSearchIn.includes(searchString, startOffset) threw exception error.
PASS sideEffect == '' is true
PASS stringToSearchIn.includes(searchString, startOffset) threw exception error.
PASS sideEffect == 'A' is true
PASS stringToSearchIn.includes(searchString, startOffset) threw exception error.
PASS sideEffect == 'AB' is true
PASS successfullyParsed is true
TEST COMPLETE