add traceur test suite
This commit is contained in:
76
test/fixtures/traceur/StringExtras/CodePointAt.js
vendored
Normal file
76
test/fixtures/traceur/StringExtras/CodePointAt.js
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
// Tests taken from https://mths.be/codepointat
|
||||
|
||||
assert.equal(String.prototype.codePointAt.length, 1);
|
||||
|
||||
// String that starts with a BMP symbol
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(''), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt('_'), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(-Infinity), undefined);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(-1), undefined);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(-0), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(0), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(3), 0x1D306);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(4), 0xDF06);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(5), 0x64);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(42), undefined);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(Infinity), undefined);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(Infinity), undefined);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(NaN), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(false), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(null), 0x61);
|
||||
assert.equal('abc\uD834\uDF06def'.codePointAt(undefined), 0x61);
|
||||
|
||||
// String that starts with an astral symbol
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(''), 0x1D306);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt('1'), 0xDF06);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt('_'), 0x1D306);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(), 0x1D306);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(-1), undefined);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(-0), 0x1D306);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(0), 0x1D306);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(1), 0xDF06);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(42), undefined);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(false), 0x1D306);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(null), 0x1D306);
|
||||
assert.equal('\uD834\uDF06def'.codePointAt(undefined), 0x1D306);
|
||||
|
||||
// Lone high surrogates
|
||||
assert.equal('\uD834abc'.codePointAt(''), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt('_'), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt(), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt(-1), undefined);
|
||||
assert.equal('\uD834abc'.codePointAt(-0), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt(0), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt(false), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt(NaN), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt(null), 0xD834);
|
||||
assert.equal('\uD834abc'.codePointAt(undefined), 0xD834);
|
||||
|
||||
// Lone low surrogates
|
||||
assert.equal('\uDF06abc'.codePointAt(''), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt('_'), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt(), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt(-1), undefined);
|
||||
assert.equal('\uDF06abc'.codePointAt(-0), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt(0), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt(false), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt(NaN), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt(null), 0xDF06);
|
||||
assert.equal('\uDF06abc'.codePointAt(undefined), 0xDF06);
|
||||
|
||||
assert.throw(function() { String.prototype.codePointAt.call(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.codePointAt.call(undefined, 4); }, TypeError);
|
||||
assert.throw(function() { String.prototype.codePointAt.call(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.codePointAt.call(null, 4); }, TypeError);
|
||||
assert.equal(String.prototype.codePointAt.call(42, 0), 0x34);
|
||||
assert.equal(String.prototype.codePointAt.call(42, 1), 0x32);
|
||||
assert.equal(String.prototype.codePointAt.call({ 'toString': function() { return 'abc'; } }, 2), 0x63);
|
||||
|
||||
assert.throw(function() { String.prototype.codePointAt.apply(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.codePointAt.apply(undefined, [4]); }, TypeError);
|
||||
assert.throw(function() { String.prototype.codePointAt.apply(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.codePointAt.apply(null, [4]); }, TypeError);
|
||||
assert.equal(String.prototype.codePointAt.apply(42, [0]), 0x34);
|
||||
assert.equal(String.prototype.codePointAt.apply(42, [1]), 0x32);
|
||||
assert.equal(String.prototype.codePointAt.apply({ 'toString': function() { return 'abc'; } }, [2]), 0x63);
|
||||
217
test/fixtures/traceur/StringExtras/EndsWith.js
vendored
Normal file
217
test/fixtures/traceur/StringExtras/EndsWith.js
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
// Tests taken from https://mths.be/endswith
|
||||
|
||||
assert.equal(String.prototype.endsWith.length, 1);
|
||||
|
||||
assert.equal('undefined'.endsWith(), true);
|
||||
assert.equal('undefined'.endsWith(undefined), true);
|
||||
assert.equal('undefined'.endsWith(null), false);
|
||||
assert.equal('null'.endsWith(), false);
|
||||
assert.equal('null'.endsWith(undefined), false);
|
||||
assert.equal('null'.endsWith(null), true);
|
||||
|
||||
assert.equal('abc'.endsWith(), false);
|
||||
assert.equal('abc'.endsWith(''), true);
|
||||
assert.equal('abc'.endsWith('\0'), false);
|
||||
assert.equal('abc'.endsWith('c'), true);
|
||||
assert.equal('abc'.endsWith('b'), false);
|
||||
assert.equal('abc'.endsWith('ab'), false);
|
||||
assert.equal('abc'.endsWith('bc'), true);
|
||||
assert.equal('abc'.endsWith('abc'), true);
|
||||
assert.equal('abc'.endsWith('bcd'), false);
|
||||
assert.equal('abc'.endsWith('abcd'), false);
|
||||
assert.equal('abc'.endsWith('bcde'), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', NaN), true);
|
||||
assert.equal('abc'.endsWith('\0', NaN), false);
|
||||
assert.equal('abc'.endsWith('c', NaN), false);
|
||||
assert.equal('abc'.endsWith('b', NaN), false);
|
||||
assert.equal('abc'.endsWith('ab', NaN), false);
|
||||
assert.equal('abc'.endsWith('bc', NaN), false);
|
||||
assert.equal('abc'.endsWith('abc', NaN), false);
|
||||
assert.equal('abc'.endsWith('bcd', NaN), false);
|
||||
assert.equal('abc'.endsWith('abcd', NaN), false);
|
||||
assert.equal('abc'.endsWith('bcde', NaN), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', false), true);
|
||||
assert.equal('abc'.endsWith('\0', false), false);
|
||||
assert.equal('abc'.endsWith('c', false), false);
|
||||
assert.equal('abc'.endsWith('b', false), false);
|
||||
assert.equal('abc'.endsWith('ab', false), false);
|
||||
assert.equal('abc'.endsWith('bc', false), false);
|
||||
assert.equal('abc'.endsWith('abc', false), false);
|
||||
assert.equal('abc'.endsWith('bcd', false), false);
|
||||
assert.equal('abc'.endsWith('abcd', false), false);
|
||||
assert.equal('abc'.endsWith('bcde', false), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', undefined), true);
|
||||
assert.equal('abc'.endsWith('\0', undefined), false);
|
||||
assert.equal('abc'.endsWith('c', undefined), true);
|
||||
assert.equal('abc'.endsWith('b', undefined), false);
|
||||
assert.equal('abc'.endsWith('ab', undefined), false);
|
||||
assert.equal('abc'.endsWith('bc', undefined), true);
|
||||
assert.equal('abc'.endsWith('abc', undefined), true);
|
||||
assert.equal('abc'.endsWith('bcd', undefined), false);
|
||||
assert.equal('abc'.endsWith('abcd', undefined), false);
|
||||
assert.equal('abc'.endsWith('bcde', undefined), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', null), true);
|
||||
assert.equal('abc'.endsWith('\0', null), false);
|
||||
assert.equal('abc'.endsWith('c', null), false);
|
||||
assert.equal('abc'.endsWith('b', null), false);
|
||||
assert.equal('abc'.endsWith('ab', null), false);
|
||||
assert.equal('abc'.endsWith('bc', null), false);
|
||||
assert.equal('abc'.endsWith('abc', null), false);
|
||||
assert.equal('abc'.endsWith('bcd', null), false);
|
||||
assert.equal('abc'.endsWith('abcd', null), false);
|
||||
assert.equal('abc'.endsWith('bcde', null), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', -Infinity), true);
|
||||
assert.equal('abc'.endsWith('\0', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('c', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('b', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('ab', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('bc', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('abc', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('bcd', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('abcd', -Infinity), false);
|
||||
assert.equal('abc'.endsWith('bcde', -Infinity), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', -1), true);
|
||||
assert.equal('abc'.endsWith('\0', -1), false);
|
||||
assert.equal('abc'.endsWith('c', -1), false);
|
||||
assert.equal('abc'.endsWith('b', -1), false);
|
||||
assert.equal('abc'.endsWith('ab', -1), false);
|
||||
assert.equal('abc'.endsWith('bc', -1), false);
|
||||
assert.equal('abc'.endsWith('abc', -1), false);
|
||||
assert.equal('abc'.endsWith('bcd', -1), false);
|
||||
assert.equal('abc'.endsWith('abcd', -1), false);
|
||||
assert.equal('abc'.endsWith('bcde', -1), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', -0), true);
|
||||
assert.equal('abc'.endsWith('\0', -0), false);
|
||||
assert.equal('abc'.endsWith('c', -0), false);
|
||||
assert.equal('abc'.endsWith('b', -0), false);
|
||||
assert.equal('abc'.endsWith('ab', -0), false);
|
||||
assert.equal('abc'.endsWith('bc', -0), false);
|
||||
assert.equal('abc'.endsWith('abc', -0), false);
|
||||
assert.equal('abc'.endsWith('bcd', -0), false);
|
||||
assert.equal('abc'.endsWith('abcd', -0), false);
|
||||
assert.equal('abc'.endsWith('bcde', -0), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', +0), true);
|
||||
assert.equal('abc'.endsWith('\0', +0), false);
|
||||
assert.equal('abc'.endsWith('c', +0), false);
|
||||
assert.equal('abc'.endsWith('b', +0), false);
|
||||
assert.equal('abc'.endsWith('ab', +0), false);
|
||||
assert.equal('abc'.endsWith('bc', +0), false);
|
||||
assert.equal('abc'.endsWith('abc', +0), false);
|
||||
assert.equal('abc'.endsWith('bcd', +0), false);
|
||||
assert.equal('abc'.endsWith('abcd', +0), false);
|
||||
assert.equal('abc'.endsWith('bcde', +0), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', 1), true);
|
||||
assert.equal('abc'.endsWith('\0', 1), false);
|
||||
assert.equal('abc'.endsWith('c', 1), false);
|
||||
assert.equal('abc'.endsWith('b', 1), false);
|
||||
assert.equal('abc'.endsWith('ab', 1), false);
|
||||
assert.equal('abc'.endsWith('bc', 1), false);
|
||||
assert.equal('abc'.endsWith('abc', 1), false);
|
||||
assert.equal('abc'.endsWith('bcd', 1), false);
|
||||
assert.equal('abc'.endsWith('abcd', 1), false);
|
||||
assert.equal('abc'.endsWith('bcde', 1), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', 2), true);
|
||||
assert.equal('abc'.endsWith('\0', 2), false);
|
||||
assert.equal('abc'.endsWith('c', 2), false);
|
||||
assert.equal('abc'.endsWith('b', 2), true);
|
||||
assert.equal('abc'.endsWith('ab', 2), true);
|
||||
assert.equal('abc'.endsWith('bc', 2), false);
|
||||
assert.equal('abc'.endsWith('abc', 2), false);
|
||||
assert.equal('abc'.endsWith('bcd', 2), false);
|
||||
assert.equal('abc'.endsWith('abcd', 2), false);
|
||||
assert.equal('abc'.endsWith('bcde', 2), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', +Infinity), true);
|
||||
assert.equal('abc'.endsWith('\0', +Infinity), false);
|
||||
assert.equal('abc'.endsWith('c', +Infinity), true);
|
||||
assert.equal('abc'.endsWith('b', +Infinity), false);
|
||||
assert.equal('abc'.endsWith('ab', +Infinity), false);
|
||||
assert.equal('abc'.endsWith('bc', +Infinity), true);
|
||||
assert.equal('abc'.endsWith('abc', +Infinity), true);
|
||||
assert.equal('abc'.endsWith('bcd', +Infinity), false);
|
||||
assert.equal('abc'.endsWith('abcd', +Infinity), false);
|
||||
assert.equal('abc'.endsWith('bcde', +Infinity), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', true), true);
|
||||
assert.equal('abc'.endsWith('\0', true), false);
|
||||
assert.equal('abc'.endsWith('c', true), false);
|
||||
assert.equal('abc'.endsWith('b', true), false);
|
||||
assert.equal('abc'.endsWith('ab', true), false);
|
||||
assert.equal('abc'.endsWith('bc', true), false);
|
||||
assert.equal('abc'.endsWith('abc', true), false);
|
||||
assert.equal('abc'.endsWith('bcd', true), false);
|
||||
assert.equal('abc'.endsWith('abcd', true), false);
|
||||
assert.equal('abc'.endsWith('bcde', true), false);
|
||||
|
||||
assert.equal('abc'.endsWith('', 'x'), true);
|
||||
assert.equal('abc'.endsWith('\0', 'x'), false);
|
||||
assert.equal('abc'.endsWith('c', 'x'), false);
|
||||
assert.equal('abc'.endsWith('b', 'x'), false);
|
||||
assert.equal('abc'.endsWith('ab', 'x'), false);
|
||||
assert.equal('abc'.endsWith('bc', 'x'), false);
|
||||
assert.equal('abc'.endsWith('abc', 'x'), false);
|
||||
assert.equal('abc'.endsWith('bcd', 'x'), false);
|
||||
assert.equal('abc'.endsWith('abcd', 'x'), false);
|
||||
assert.equal('abc'.endsWith('bcde', 'x'), false);
|
||||
|
||||
assert.equal('[a-z]+(bar)?'.endsWith('(bar)?'), true);
|
||||
assert.throw(function() { '[a-z]+(bar)?'.endsWith(/(bar)?/); }, TypeError);
|
||||
assert.equal('[a-z]+(bar)?'.endsWith('[a-z]+', 6), true);
|
||||
assert.throw(function() { '[a-z]+(bar)?'.endsWith(/(bar)?/); }, TypeError);
|
||||
assert.throw(function() { '[a-z]+/(bar)?/'.endsWith(/(bar)?/); }, TypeError);
|
||||
|
||||
// https://mathiasbynens.be/notes/javascript-unicode#poo-test
|
||||
var string = 'I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\u2603\uD83D\uDCA9';
|
||||
assert.equal(string.endsWith(''), true);
|
||||
assert.equal(string.endsWith('\xF1t\xEBr'), false);
|
||||
assert.equal(string.endsWith('\xF1t\xEBr', 5), true);
|
||||
assert.equal(string.endsWith('\xE0liz\xE6'), false);
|
||||
assert.equal(string.endsWith('\xE0liz\xE6', 16), true);
|
||||
assert.equal(string.endsWith('\xF8n\u2603\uD83D\uDCA9'), true);
|
||||
assert.equal(string.endsWith('\xF8n\u2603\uD83D\uDCA9', 23), true);
|
||||
assert.equal(string.endsWith('\u2603'), false);
|
||||
assert.equal(string.endsWith('\u2603', 21), true);
|
||||
assert.equal(string.endsWith('\uD83D\uDCA9'), true);
|
||||
assert.equal(string.endsWith('\uD83D\uDCA9', 23), true);
|
||||
|
||||
assert.throw(function() { String.prototype.endsWith.call(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.call(undefined, 'b'); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.call(undefined, 'b', 4); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.call(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.call(null, 'b'); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.call(null, 'b', 4); }, TypeError);
|
||||
assert.equal(String.prototype.endsWith.call(42, '2'), true);
|
||||
assert.equal(String.prototype.endsWith.call(42, '4'), false);
|
||||
assert.equal(String.prototype.endsWith.call(42, 'b', 4), false);
|
||||
assert.equal(String.prototype.endsWith.call(42, '2', 1), false);
|
||||
assert.equal(String.prototype.endsWith.call(42, '2', 4), true);
|
||||
assert.equal(String.prototype.endsWith.call({ 'toString': function() { return 'abc'; } }, 'b', 0), false);
|
||||
assert.equal(String.prototype.endsWith.call({ 'toString': function() { return 'abc'; } }, 'b', 1), false);
|
||||
assert.equal(String.prototype.endsWith.call({ 'toString': function() { return 'abc'; } }, 'b', 2), true);
|
||||
assert.throw(function() { String.prototype.endsWith.call({ 'toString': function() { throw RangeError(); } }, /./); }, RangeError);
|
||||
|
||||
assert.throw(function() { String.prototype.endsWith.apply(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.apply(undefined, ['b']); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.apply(undefined, ['b', 4]); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.apply(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.apply(null, ['b']); }, TypeError);
|
||||
assert.throw(function() { String.prototype.endsWith.apply(null, ['b', 4]); }, TypeError);
|
||||
assert.equal(String.prototype.endsWith.apply(42, ['2']), true);
|
||||
assert.equal(String.prototype.endsWith.apply(42, ['4']), false);
|
||||
assert.equal(String.prototype.endsWith.apply(42, ['b', 4]), false);
|
||||
assert.equal(String.prototype.endsWith.apply(42, ['2', 1]), false);
|
||||
assert.equal(String.prototype.endsWith.apply(42, ['2', 4]), true);
|
||||
assert.equal(String.prototype.endsWith.apply({ 'toString': function() { return 'abc'; } }, ['b', 0]), false);
|
||||
assert.equal(String.prototype.endsWith.apply({ 'toString': function() { return 'abc'; } }, ['b', 1]), false);
|
||||
assert.equal(String.prototype.endsWith.apply({ 'toString': function() { return 'abc'; } }, ['b', 2]), true);
|
||||
assert.throw(function() { String.prototype.endsWith.apply({ 'toString': function() { throw RangeError(); } }, [/./]); }, RangeError);
|
||||
25
test/fixtures/traceur/StringExtras/FromCodePoint.js
vendored
Normal file
25
test/fixtures/traceur/StringExtras/FromCodePoint.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Tests taken from https://mths.be/fromcodepoint
|
||||
|
||||
assert.equal(String.fromCodePoint.length, 0);
|
||||
|
||||
assert.equal(String.fromCodePoint(''), '\0');
|
||||
assert.equal(String.fromCodePoint(), '');
|
||||
assert.equal(String.fromCodePoint(-0), '\0');
|
||||
assert.equal(String.fromCodePoint(0), '\0');
|
||||
assert.equal(String.fromCodePoint(0x1D306), '\uD834\uDF06');
|
||||
assert.equal(String.fromCodePoint(0x1D306, 0x61, 0x1D307), '\uD834\uDF06a\uD834\uDF07');
|
||||
assert.equal(String.fromCodePoint(0x61, 0x62, 0x1D307), 'ab\uD834\uDF07');
|
||||
assert.equal(String.fromCodePoint(false), '\0');
|
||||
assert.equal(String.fromCodePoint(null), '\0');
|
||||
|
||||
assert.throw(function() { String.fromCodePoint('_'); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint('+Infinity'); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint('-Infinity'); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint(-1); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint(0x10FFFF + 1); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint(3.14); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint(3e-2); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint(Infinity); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint(NaN); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint(undefined); }, RangeError);
|
||||
assert.throw(function() { String.fromCodePoint({}); }, RangeError);
|
||||
114
test/fixtures/traceur/StringExtras/Includes.js
vendored
Normal file
114
test/fixtures/traceur/StringExtras/Includes.js
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// Tests taken from https://mths.be/includes
|
||||
|
||||
assert.equal(String.prototype.includes.length, 1);
|
||||
assert.equal(String.prototype.propertyIsEnumerable('includes'), false);
|
||||
|
||||
assert.equal('abc'.includes(), false);
|
||||
assert.equal('aundefinedb'.includes(), true);
|
||||
assert.equal('abc'.includes(undefined), false);
|
||||
assert.equal('aundefinedb'.includes(undefined), true);
|
||||
assert.equal('abc'.includes(null), false);
|
||||
assert.equal('anullb'.includes(null), true);
|
||||
assert.equal('abc'.includes(false), false);
|
||||
assert.equal('afalseb'.includes(false), true);
|
||||
assert.equal('abc'.includes(NaN), false);
|
||||
assert.equal('aNaNb'.includes(NaN), true);
|
||||
assert.equal('abc'.includes('abc'), true);
|
||||
assert.equal('abc'.includes('def'), false);
|
||||
assert.equal('abc'.includes(''), true);
|
||||
assert.equal(''.includes(''), true);
|
||||
|
||||
assert.equal('abc'.includes('b', -Infinity), true);
|
||||
assert.equal('abc'.includes('b', -1), true);
|
||||
assert.equal('abc'.includes('b', -0), true);
|
||||
assert.equal('abc'.includes('b', +0), true);
|
||||
assert.equal('abc'.includes('b', NaN), true);
|
||||
assert.equal('abc'.includes('b', 'x'), true);
|
||||
assert.equal('abc'.includes('b', false), true);
|
||||
assert.equal('abc'.includes('b', undefined), true);
|
||||
assert.equal('abc'.includes('b', null), true);
|
||||
assert.equal('abc'.includes('b', 1), true);
|
||||
assert.equal('abc'.includes('b', 2), false);
|
||||
assert.equal('abc'.includes('b', 3), false);
|
||||
assert.equal('abc'.includes('b', 4), false);
|
||||
assert.equal('abc'.includes('b', +Infinity), false);
|
||||
assert.equal('abc'.includes('bc'), true);
|
||||
assert.equal('abc'.includes('bc\0'), false);
|
||||
|
||||
assert.equal('abc123def'.includes(1, -Infinity), true);
|
||||
assert.equal('abc123def'.includes(1, -1), true);
|
||||
assert.equal('abc123def'.includes(1, -0), true);
|
||||
assert.equal('abc123def'.includes(1, +0), true);
|
||||
assert.equal('abc123def'.includes(1, NaN), true);
|
||||
assert.equal('abc123def'.includes(1, 'x'), true);
|
||||
assert.equal('abc123def'.includes(1, false), true);
|
||||
assert.equal('abc123def'.includes(1, undefined), true);
|
||||
assert.equal('abc123def'.includes(1, null), true);
|
||||
assert.equal('abc123def'.includes(1, 1), true);
|
||||
assert.equal('abc123def'.includes(1, 2), true);
|
||||
assert.equal('abc123def'.includes(1, 3), true);
|
||||
assert.equal('abc123def'.includes(1, 4), false);
|
||||
assert.equal('abc123def'.includes(1, 5), false);
|
||||
assert.equal('abc123def'.includes(1, +Infinity), false);
|
||||
|
||||
assert.equal('abc123def'.includes(9, -Infinity), false);
|
||||
assert.equal('abc123def'.includes(9, -1), false);
|
||||
assert.equal('abc123def'.includes(9, -0), false);
|
||||
assert.equal('abc123def'.includes(9, +0), false);
|
||||
assert.equal('abc123def'.includes(9, NaN), false);
|
||||
assert.equal('abc123def'.includes(9, 'x'), false);
|
||||
assert.equal('abc123def'.includes(9, false), false);
|
||||
assert.equal('abc123def'.includes(9, undefined), false);
|
||||
assert.equal('abc123def'.includes(9, null), false);
|
||||
assert.equal('abc123def'.includes(9, 1), false);
|
||||
assert.equal('abc123def'.includes(9, 2), false);
|
||||
assert.equal('abc123def'.includes(9, 3), false);
|
||||
assert.equal('abc123def'.includes(9, 4), false);
|
||||
assert.equal('abc123def'.includes(9, 5), false);
|
||||
assert.equal('abc123def'.includes(9, +Infinity), false);
|
||||
|
||||
assert.equal('foo[a-z]+(bar)?'.includes('[a-z]+'), true);
|
||||
assert.throw(function() { 'foo[a-z]+(bar)?'.includes(/[a-z]+/); }, TypeError);
|
||||
assert.throw(function() { 'foo/[a-z]+/(bar)?'.includes(/[a-z]+/); }, TypeError);
|
||||
assert.equal('foo[a-z]+(bar)?'.includes('(bar)?'), true);
|
||||
assert.throw(function() { 'foo[a-z]+(bar)?'.includes(/(bar)?/); }, TypeError);
|
||||
assert.throw(function() { 'foo[a-z]+/(bar)?/'.includes(/(bar)?/); }, TypeError);
|
||||
|
||||
// https://mathiasbynens.be/notes/javascript-unicode#poo-test
|
||||
var string = 'I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\u2603\uD83D\uDCA9';
|
||||
assert.equal(string.includes(''), true);
|
||||
assert.equal(string.includes('\xF1t\xEBr'), true);
|
||||
assert.equal(string.includes('\xE0liz\xE6'), true);
|
||||
assert.equal(string.includes('\xF8n\u2603\uD83D\uDCA9'), true);
|
||||
assert.equal(string.includes('\u2603'), true);
|
||||
assert.equal(string.includes('\uD83D\uDCA9'), true);
|
||||
|
||||
assert.throw(function() { String.prototype.includes.call(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.call(undefined, 'b'); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.call(undefined, 'b', 4); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.call(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.call(null, 'b'); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.call(null, 'b', 4); }, TypeError);
|
||||
assert.equal(String.prototype.includes.call(42, '2'), true);
|
||||
assert.equal(String.prototype.includes.call(42, 'b', 4), false);
|
||||
assert.equal(String.prototype.includes.call(42, '2', 4), false);
|
||||
assert.equal(String.prototype.includes.call({ 'toString': function() { return 'abc'; } }, 'b', 0), true);
|
||||
assert.equal(String.prototype.includes.call({ 'toString': function() { return 'abc'; } }, 'b', 1), true);
|
||||
assert.equal(String.prototype.includes.call({ 'toString': function() { return 'abc'; } }, 'b', 2), false);
|
||||
assert.throw(function() { String.prototype.includes.call({ 'toString': function() { throw RangeError(); } }, /./); }, RangeError);
|
||||
assert.throw(function() { String.prototype.includes.call({ 'toString': function() { return 'abc'; } }, /./); }, TypeError);
|
||||
|
||||
assert.throw(function() { String.prototype.includes.apply(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.apply(undefined, ['b']); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.apply(undefined, ['b', 4]); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.apply(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.apply(null, ['b']); }, TypeError);
|
||||
assert.throw(function() { String.prototype.includes.apply(null, ['b', 4]); }, TypeError);
|
||||
assert.equal(String.prototype.includes.apply(42, ['2']), true);
|
||||
assert.equal(String.prototype.includes.apply(42, ['b', 4]), false);
|
||||
assert.equal(String.prototype.includes.apply(42, ['2', 4]), false);
|
||||
assert.equal(String.prototype.includes.apply({ 'toString': function() { return 'abc'; } }, ['b', 0]), true);
|
||||
assert.equal(String.prototype.includes.apply({ 'toString': function() { return 'abc'; } }, ['b', 1]), true);
|
||||
assert.equal(String.prototype.includes.apply({ 'toString': function() { return 'abc'; } }, ['b', 2]), false);
|
||||
assert.throw(function() { String.prototype.includes.apply({ 'toString': function() { throw RangeError(); } }, [/./]); }, RangeError);
|
||||
assert.throw(function() { String.prototype.includes.apply({ 'toString': function() { return 'abc'; } }, [/./]); }, TypeError);
|
||||
33
test/fixtures/traceur/StringExtras/Repeat.js
vendored
Normal file
33
test/fixtures/traceur/StringExtras/Repeat.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Tests taken from https://mths.be/repeat
|
||||
|
||||
assert.equal(String.prototype.repeat.length, 1);
|
||||
|
||||
assert.equal('abc'.repeat(), '');
|
||||
assert.equal('abc'.repeat(undefined), '');
|
||||
assert.equal('abc'.repeat(null), '');
|
||||
assert.equal('abc'.repeat(false), '');
|
||||
assert.equal('abc'.repeat(NaN), '');
|
||||
assert.equal('abc'.repeat('abc'), '');
|
||||
assert.throw(function() { 'abc'.repeat(-Infinity); }, RangeError);
|
||||
assert.throw(function() { 'abc'.repeat(-1); }, RangeError);
|
||||
assert.equal('abc'.repeat(-0), '');
|
||||
assert.equal('abc'.repeat(+0), '');
|
||||
assert.equal('abc'.repeat(1), 'abc');
|
||||
assert.equal('abc'.repeat(2), 'abcabc');
|
||||
assert.equal('abc'.repeat(3), 'abcabcabc');
|
||||
assert.equal('abc'.repeat(4), 'abcabcabcabc');
|
||||
assert.throw(function() { 'abc'.repeat(+Infinity); }, RangeError);
|
||||
|
||||
assert.throw(function() { String.prototype.repeat.call(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.repeat.call(undefined, 4); }, TypeError);
|
||||
assert.throw(function() { String.prototype.repeat.call(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.repeat.call(null, 4); }, TypeError);
|
||||
assert.equal(String.prototype.repeat.call(42, 4), '42424242');
|
||||
assert.equal(String.prototype.repeat.call({ 'toString': function() { return 'abc'; } }, 2), 'abcabc');
|
||||
|
||||
assert.throw(function() { String.prototype.repeat.apply(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.repeat.apply(undefined, [4]); }, TypeError);
|
||||
assert.throw(function() { String.prototype.repeat.apply(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.repeat.apply(null, [4]); }, TypeError);
|
||||
assert.equal(String.prototype.repeat.apply(42, [4]), '42424242');
|
||||
assert.equal(String.prototype.repeat.apply({ 'toString': function() { return 'abc'; } }, [2]), 'abcabc');
|
||||
210
test/fixtures/traceur/StringExtras/StartsWith.js
vendored
Normal file
210
test/fixtures/traceur/StringExtras/StartsWith.js
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
// Tests taken from https://mths.be/startswith
|
||||
|
||||
//Object.prototype[1] = 2; // try to break `arguments[1]`
|
||||
|
||||
//assert.equal(String.prototype.startsWith.length, 1);
|
||||
|
||||
assert.equal('undefined'.startsWith(), true);
|
||||
assert.equal('undefined'.startsWith(undefined), true);
|
||||
assert.equal('undefined'.startsWith(null), false);
|
||||
assert.equal('null'.startsWith(), false);
|
||||
assert.equal('null'.startsWith(undefined), false);
|
||||
assert.equal('null'.startsWith(null), true);
|
||||
|
||||
assert.equal('abc'.startsWith(), false);
|
||||
assert.equal('abc'.startsWith(''), true);
|
||||
assert.equal('abc'.startsWith('\0'), false);
|
||||
assert.equal('abc'.startsWith('a'), true);
|
||||
assert.equal('abc'.startsWith('b'), false);
|
||||
assert.equal('abc'.startsWith('ab'), true);
|
||||
assert.equal('abc'.startsWith('bc'), false);
|
||||
assert.equal('abc'.startsWith('abc'), true);
|
||||
assert.equal('abc'.startsWith('bcd'), false);
|
||||
assert.equal('abc'.startsWith('abcd'), false);
|
||||
assert.equal('abc'.startsWith('bcde'), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', NaN), true);
|
||||
assert.equal('abc'.startsWith('\0', NaN), false);
|
||||
assert.equal('abc'.startsWith('a', NaN), true);
|
||||
assert.equal('abc'.startsWith('b', NaN), false);
|
||||
assert.equal('abc'.startsWith('ab', NaN), true);
|
||||
assert.equal('abc'.startsWith('bc', NaN), false);
|
||||
assert.equal('abc'.startsWith('abc', NaN), true);
|
||||
assert.equal('abc'.startsWith('bcd', NaN), false);
|
||||
assert.equal('abc'.startsWith('abcd', NaN), false);
|
||||
assert.equal('abc'.startsWith('bcde', NaN), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', false), true);
|
||||
assert.equal('abc'.startsWith('\0', false), false);
|
||||
assert.equal('abc'.startsWith('a', false), true);
|
||||
assert.equal('abc'.startsWith('b', false), false);
|
||||
assert.equal('abc'.startsWith('ab', false), true);
|
||||
assert.equal('abc'.startsWith('bc', false), false);
|
||||
assert.equal('abc'.startsWith('abc', false), true);
|
||||
assert.equal('abc'.startsWith('bcd', false), false);
|
||||
assert.equal('abc'.startsWith('abcd', false), false);
|
||||
assert.equal('abc'.startsWith('bcde', false), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', undefined), true);
|
||||
assert.equal('abc'.startsWith('\0', undefined), false);
|
||||
assert.equal('abc'.startsWith('a', undefined), true);
|
||||
assert.equal('abc'.startsWith('b', undefined), false);
|
||||
assert.equal('abc'.startsWith('ab', undefined), true);
|
||||
assert.equal('abc'.startsWith('bc', undefined), false);
|
||||
assert.equal('abc'.startsWith('abc', undefined), true);
|
||||
assert.equal('abc'.startsWith('bcd', undefined), false);
|
||||
assert.equal('abc'.startsWith('abcd', undefined), false);
|
||||
assert.equal('abc'.startsWith('bcde', undefined), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', null), true);
|
||||
assert.equal('abc'.startsWith('\0', null), false);
|
||||
assert.equal('abc'.startsWith('a', null), true);
|
||||
assert.equal('abc'.startsWith('b', null), false);
|
||||
assert.equal('abc'.startsWith('ab', null), true);
|
||||
assert.equal('abc'.startsWith('bc', null), false);
|
||||
assert.equal('abc'.startsWith('abc', null), true);
|
||||
assert.equal('abc'.startsWith('bcd', null), false);
|
||||
assert.equal('abc'.startsWith('abcd', null), false);
|
||||
assert.equal('abc'.startsWith('bcde', null), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', -Infinity), true);
|
||||
assert.equal('abc'.startsWith('\0', -Infinity), false);
|
||||
assert.equal('abc'.startsWith('a', -Infinity), true);
|
||||
assert.equal('abc'.startsWith('b', -Infinity), false);
|
||||
assert.equal('abc'.startsWith('ab', -Infinity), true);
|
||||
assert.equal('abc'.startsWith('bc', -Infinity), false);
|
||||
assert.equal('abc'.startsWith('abc', -Infinity), true);
|
||||
assert.equal('abc'.startsWith('bcd', -Infinity), false);
|
||||
assert.equal('abc'.startsWith('abcd', -Infinity), false);
|
||||
assert.equal('abc'.startsWith('bcde', -Infinity), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', -1), true);
|
||||
assert.equal('abc'.startsWith('\0', -1), false);
|
||||
assert.equal('abc'.startsWith('a', -1), true);
|
||||
assert.equal('abc'.startsWith('b', -1), false);
|
||||
assert.equal('abc'.startsWith('ab', -1), true);
|
||||
assert.equal('abc'.startsWith('bc', -1), false);
|
||||
assert.equal('abc'.startsWith('abc', -1), true);
|
||||
assert.equal('abc'.startsWith('bcd', -1), false);
|
||||
assert.equal('abc'.startsWith('abcd', -1), false);
|
||||
assert.equal('abc'.startsWith('bcde', -1), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', -0), true);
|
||||
assert.equal('abc'.startsWith('\0', -0), false);
|
||||
assert.equal('abc'.startsWith('a', -0), true);
|
||||
assert.equal('abc'.startsWith('b', -0), false);
|
||||
assert.equal('abc'.startsWith('ab', -0), true);
|
||||
assert.equal('abc'.startsWith('bc', -0), false);
|
||||
assert.equal('abc'.startsWith('abc', -0), true);
|
||||
assert.equal('abc'.startsWith('bcd', -0), false);
|
||||
assert.equal('abc'.startsWith('abcd', -0), false);
|
||||
assert.equal('abc'.startsWith('bcde', -0), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', +0), true);
|
||||
assert.equal('abc'.startsWith('\0', +0), false);
|
||||
assert.equal('abc'.startsWith('a', +0), true);
|
||||
assert.equal('abc'.startsWith('b', +0), false);
|
||||
assert.equal('abc'.startsWith('ab', +0), true);
|
||||
assert.equal('abc'.startsWith('bc', +0), false);
|
||||
assert.equal('abc'.startsWith('abc', +0), true);
|
||||
assert.equal('abc'.startsWith('bcd', +0), false);
|
||||
assert.equal('abc'.startsWith('abcd', +0), false);
|
||||
assert.equal('abc'.startsWith('bcde', +0), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', 1), true);
|
||||
assert.equal('abc'.startsWith('\0', 1), false);
|
||||
assert.equal('abc'.startsWith('a', 1), false);
|
||||
assert.equal('abc'.startsWith('b', 1), true);
|
||||
assert.equal('abc'.startsWith('ab', 1), false);
|
||||
assert.equal('abc'.startsWith('bc', 1), true);
|
||||
assert.equal('abc'.startsWith('abc', 1), false);
|
||||
assert.equal('abc'.startsWith('bcd', 1), false);
|
||||
assert.equal('abc'.startsWith('abcd', 1), false);
|
||||
assert.equal('abc'.startsWith('bcde', 1), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', +Infinity), true);
|
||||
assert.equal('abc'.startsWith('\0', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('a', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('b', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('ab', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('bc', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('abc', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('bcd', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('abcd', +Infinity), false);
|
||||
assert.equal('abc'.startsWith('bcde', +Infinity), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', true), true);
|
||||
assert.equal('abc'.startsWith('\0', true), false);
|
||||
assert.equal('abc'.startsWith('a', true), false);
|
||||
assert.equal('abc'.startsWith('b', true), true);
|
||||
assert.equal('abc'.startsWith('ab', true), false);
|
||||
assert.equal('abc'.startsWith('bc', true), true);
|
||||
assert.equal('abc'.startsWith('abc', true), false);
|
||||
assert.equal('abc'.startsWith('bcd', true), false);
|
||||
assert.equal('abc'.startsWith('abcd', true), false);
|
||||
assert.equal('abc'.startsWith('bcde', true), false);
|
||||
|
||||
assert.equal('abc'.startsWith('', 'x'), true);
|
||||
assert.equal('abc'.startsWith('\0', 'x'), false);
|
||||
assert.equal('abc'.startsWith('a', 'x'), true);
|
||||
assert.equal('abc'.startsWith('b', 'x'), false);
|
||||
assert.equal('abc'.startsWith('ab', 'x'), true);
|
||||
assert.equal('abc'.startsWith('bc', 'x'), false);
|
||||
assert.equal('abc'.startsWith('abc', 'x'), true);
|
||||
assert.equal('abc'.startsWith('bcd', 'x'), false);
|
||||
assert.equal('abc'.startsWith('abcd', 'x'), false);
|
||||
assert.equal('abc'.startsWith('bcde', 'x'), false);
|
||||
|
||||
assert.equal('[a-z]+(bar)?'.startsWith('[a-z]+'), true);
|
||||
assert.throw(function() { '[a-z]+(bar)?'.startsWith(/[a-z]+/); }, TypeError);
|
||||
assert.equal('[a-z]+(bar)?'.startsWith('(bar)?', 6), true);
|
||||
assert.throw(function() { '[a-z]+(bar)?'.startsWith(/(bar)?/); }, TypeError);
|
||||
assert.throw(function() { '[a-z]+/(bar)?/'.startsWith(/(bar)?/); }, TypeError);
|
||||
|
||||
// https://mathiasbynens.be/notes/javascript-unicode#poo-test
|
||||
var string = 'I\xF1t\xEBrn\xE2ti\xF4n\xE0liz\xE6ti\xF8n\u2603\uD83D\uDCA9';
|
||||
assert.equal(string.startsWith(''), true);
|
||||
assert.equal(string.startsWith('\xF1t\xEBr'), false);
|
||||
assert.equal(string.startsWith('\xF1t\xEBr', 1), true);
|
||||
assert.equal(string.startsWith('\xE0liz\xE6'), false);
|
||||
assert.equal(string.startsWith('\xE0liz\xE6', 11), true);
|
||||
assert.equal(string.startsWith('\xF8n\u2603\uD83D\uDCA9'), false);
|
||||
assert.equal(string.startsWith('\xF8n\u2603\uD83D\uDCA9', 18), true);
|
||||
assert.equal(string.startsWith('\u2603'), false);
|
||||
assert.equal(string.startsWith('\u2603', 20), true);
|
||||
assert.equal(string.startsWith('\uD83D\uDCA9'), false);
|
||||
assert.equal(string.startsWith('\uD83D\uDCA9', 21), true);
|
||||
|
||||
assert.throw(function() { String.prototype.startsWith.call(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.call(undefined, 'b'); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.call(undefined, 'b', 4); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.call(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.call(null, 'b'); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.call(null, 'b', 4); }, TypeError);
|
||||
assert.equal(String.prototype.startsWith.call(42, '2'), false);
|
||||
assert.equal(String.prototype.startsWith.call(42, '4'), true);
|
||||
assert.equal(String.prototype.startsWith.call(42, 'b', 4), false);
|
||||
assert.equal(String.prototype.startsWith.call(42, '2', 1), true);
|
||||
assert.equal(String.prototype.startsWith.call(42, '2', 4), false);
|
||||
assert.equal(String.prototype.startsWith.call({ 'toString': function() { return 'abc'; } }, 'b', 0), false);
|
||||
assert.equal(String.prototype.startsWith.call({ 'toString': function() { return 'abc'; } }, 'b', 1), true);
|
||||
assert.equal(String.prototype.startsWith.call({ 'toString': function() { return 'abc'; } }, 'b', 2), false);
|
||||
assert.throw(function() { String.prototype.startsWith.call({ 'toString': function() { throw RangeError(); } }, /./); }, RangeError);
|
||||
|
||||
assert.throw(function() { String.prototype.startsWith.apply(undefined); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.apply(undefined, ['b']); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.apply(undefined, ['b', 4]); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.apply(null); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.apply(null, ['b']); }, TypeError);
|
||||
assert.throw(function() { String.prototype.startsWith.apply(null, ['b', 4]); }, TypeError);
|
||||
assert.equal(String.prototype.startsWith.apply(42, ['2']), false);
|
||||
assert.equal(String.prototype.startsWith.apply(42, ['4']), true);
|
||||
assert.equal(String.prototype.startsWith.apply(42, ['b', 4]), false);
|
||||
assert.equal(String.prototype.startsWith.apply(42, ['2', 1]), true);
|
||||
assert.equal(String.prototype.startsWith.apply(42, ['2', 4]), false);
|
||||
assert.equal(String.prototype.startsWith.apply({ 'toString': function() { return 'abc'; } }, ['b', 0]), false);
|
||||
assert.equal(String.prototype.startsWith.apply({ 'toString': function() { return 'abc'; } }, ['b', 1]), true);
|
||||
assert.equal(String.prototype.startsWith.apply({ 'toString': function() { return 'abc'; } }, ['b', 2]), false);
|
||||
assert.throw(function() { String.prototype.startsWith.apply({ 'toString': function() { throw RangeError(); } }, [/./]); }, RangeError);
|
||||
|
||||
delete Object.prototype[1];
|
||||
Reference in New Issue
Block a user