first commit

This commit is contained in:
2026-01-16 14:13:44 +08:00
commit 903ff8d495
34603 changed files with 8585054 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
describe('Date', function () {
describe('now', function () {
it('should be the current time', function () {
expect(Date.now() === new Date().getTime()).toBe(true);
});
});
describe("parse", function () {
// TODO: Write the rest of the test.
it('should support extended years', function () {
expect(Date.parse('0001-01-01T00:00:00Z')).toBe(-62135596800000);
expect(Date.parse('+275760-09-13T00:00:00.000Z')).toBe(8.64e15);
expect(Date.parse('+033658-09-27T01:46:40.000Z')).toBe(1e15);
expect(Date.parse('-000001-01-01T00:00:00Z')).toBe(-62198755200000);
expect(Date.parse('+002009-12-15T00:00:00Z')).toBe(1260835200000);
});
it('should work', function () {
//Chrome 19 Opera 12 Firefox 11 IE 9 Safari 5.1.1
expect(Date.parse("2012-11-31T23:59:59.000Z")).toBeFalsy(); //1354406399000 NaN NaN 1354406399000 NaN
expect(Date.parse("2012-12-31T23:59:59.000Z")).toBe(1356998399000); //1356998399000 1356998399000 1356998399000 1356998399000 1356998399000
expect(Date.parse("2012-12-31T23:59:60.000Z")).toBeFalsy(); //NaN NaN NaN NaN 1356998400000
expect(Date.parse("2012-04-04T05:02:02.170Z")).toBe(1333515722170); //1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(Date.parse("2012-04-04T05:02:02.170999Z")).toBe(1333515722170); //1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(Date.parse("2012-04-04T05:02:02.17Z")).toBe(1333515722170); //1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(Date.parse("2012-04-04T05:02:02.1Z")).toBe(1333515722100); //1333515722170 1333515722170 1333515722170 1333515722170 1333515722170
expect(Date.parse("2012-04-04T24:00:00.000Z")).toBe(1333584000000); //NaN 1333584000000 1333584000000 1333584000000 1333584000000
expect(Date.parse("2012-04-04T24:00:00.500Z")).toBeFalsy(); //NaN NaN 1333584000500 1333584000500 NaN
expect(Date.parse("2012-12-31T10:08:60.000Z")).toBeFalsy(); //NaN NaN NaN NaN 1356948540000
expect(Date.parse("2012-13-01T12:00:00.000Z")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("2012-12-32T12:00:00.000Z")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("2012-12-31T25:00:00.000Z")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("2012-12-31T24:01:00.000Z")).toBeFalsy(); //NaN NaN NaN 1356998460000 NaN
expect(Date.parse("2012-12-31T12:60:00.000Z")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("2012-12-31T12:00:60.000Z")).toBeFalsy(); //NaN NaN NaN NaN 1356955260000
expect(Date.parse("2012-00-31T23:59:59.000Z")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("2012-12-00T23:59:59.000Z")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("2012-02-29T12:00:00.000Z")).toBe(1330516800000); //1330516800000 1330516800000 1330516800000 1330516800000 1330516800000
expect(Date.parse("2011-02-29T12:00:00.000Z")).toBeFalsy(); //1298980800000 NaN NaN 1298980800000 NaN
expect(Date.parse("2011-03-01T12:00:00.000Z")).toBe(1298980800000); //1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
// extended years:
expect(Date.parse("0000-01-01T00:00:00.000Z")).toBe(-621672192e5); //-621672192e5 -621672192e5 -621672192e5 -621672192e5 -621672192e5
expect(Date.parse("+275760-09-13T00:00:00.000Z")).toBe(8.64e15); //8.64e15 NaN 8.64e15 8.64e15 8.64e15
expect(Date.parse("-271821-04-20T00:00:00.000Z")).toBe(-8.64e15); //-8.64e15 NaN -8.64e15 -8.64e15 -8.6400000864e15
expect(Date.parse("+275760-09-13T00:00:00.001Z")).toBeFalsy(); //NaN NaN NaN 8.64e15 + 1 8.64e15 + 1
expect(Date.parse("-271821-04-19T23:59:59.999Z")).toBeFalsy(); //NaN NaN NaN -8.64e15 - 1 -8.6400000864e15 - 1
// https://github.com/kriskowal/es5-shim/issues/80 Safari bug with leap day
expect(Date.parse("2034-03-01T00:00:00.000Z") -
Date.parse("2034-02-27T23:59:59.999Z")).toBe(86400001); //86400001 86400001 86400001 86400001 1
// Time Zone Offset
expect(Date.parse("2012-01-29T12:00:00.000+01:00")).toBe(132783480e4);//132783480e4 132783480e4 132783480e4 132783480e4 132783480e4
expect(Date.parse("2012-01-29T12:00:00.000-00:00")).toBe(132783840e4);//132783840e4 132783840e4 132783840e4 132783840e4 132783840e4
expect(Date.parse("2012-01-29T12:00:00.000+00:00")).toBe(132783840e4);//132783840e4 132783840e4 132783840e4 132783840e4 132783840e4
expect(Date.parse("2012-01-29T12:00:00.000+23:59")).toBe(132775206e4);//132775206e4 132775206e4 132775206e4 132775206e4 132775206e4
expect(Date.parse("2012-01-29T12:00:00.000-23:59")).toBe(132792474e4);//132792474e4 132792474e4 132792474e4 132792474e4 132792474e4
expect(Date.parse("2012-01-29T12:00:00.000+24:00")).toBeFalsy(); //NaN 1327752e6 NaN 1327752000000 1327752000000
expect(Date.parse("2012-01-29T12:00:00.000+24:01")).toBeFalsy(); //NaN NaN NaN 1327751940000 1327751940000
expect(Date.parse("2012-01-29T12:00:00.000+24:59")).toBeFalsy(); //NaN NaN NaN 1327748460000 1327748460000
expect(Date.parse("2012-01-29T12:00:00.000+25:00")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("2012-01-29T12:00:00.000+00:60")).toBeFalsy(); //NaN NaN NaN NaN NaN
expect(Date.parse("-271821-04-20T00:00:00.000+00:01")).toBeFalsy(); //NaN NaN NaN -864000000006e4 -864000008646e4
expect(Date.parse("-271821-04-20T00:01:00.000+00:01")).toBe(-8.64e15);//-8.64e15 NaN -8.64e15 -8.64e15 -864000008640e4
// When time zone is missed, local offset should be used (ES 5.1 bug)
// see https://bugs.ecmascript.org/show_bug.cgi?id=112
var tzOffset = Number(new Date(1970, 0));
// same as (new Date().getTimezoneOffset() * 60000)
expect(Date.parse('1970-01-01T00:00:00')).toBe(tzOffset); //tzOffset 0 0 0 NaN
});
it("should be able to coerce to a number", function(){
var actual = Number(new Date(1970, 0));
var expected = parseInt(actual, 10);
expect(actual).toBeDefined();
expect(actual).toEqual(expected);
expect(isNaN(actual)).toBeFalsy();
});
});
describe("toString", function(){
var actual = (new Date(1970, 0)).toString();
beforeEach(function(){
actual = (new Date(1970, 0)).toString();
});
it("should show correct date info for "+actual, function(){
expect(actual).toMatch(/1970/);
expect(actual).toMatch(/jan/i);
expect(actual).toMatch(/thu/i);
expect(actual).toMatch(/00:00:00/);
});
});
describe("valueOf", function(){
var actual = (new Date(1970, 0));
beforeEach(function(){
actual = (new Date(1970, 0)).valueOf();
});
it("should give an int value", function(){
expect(parseInt(actual, 10)).toBeTruthy();
});
});
describe("toISOString", function () {
// TODO: write the rest of the test.
it('should support extended years', function () {
expect(new Date(-62198755200000).toISOString().indexOf('-000001-01-01')).toBe(0);
expect(new Date(8.64e15).toISOString().indexOf('+275760-09-13')).toBe(0);
});
it('should return correct dates', function () {
expect(new Date(-1).toISOString()).toBe('1969-12-31T23:59:59.999Z');// Safari 5.1.5 "1969-12-31T23:59:59.-01Z"
expect(new Date(-3509827334573292).toISOString()).toBe('-109252-01-01T10:37:06.708Z'); // Opera 11.61/Opera 12 bug with Date#getUTCMonth
});
});
describe("toJSON", function () {
// Opera 11.6x/12 bug
it('should call toISOString', function () {
var date = new Date(0);
date.toISOString = function () {
return 1;
};
expect(date.toJSON()).toBe(1);
});
it('should return null for not finite dates', function () {
var date = new Date(NaN),
json;
try {
json = date.toJSON();
} catch (e) {}
expect(json).toBe(null);
});
it('should return the isoString when stringified', function () {
var date = new Date();
expect(JSON.stringify(date.toISOString())).toBe(JSON.stringify(date));
})
});
});

View File

@ -0,0 +1,147 @@
describe('Function', function() {
"use strict";
describe('bind', function() {
var actual, expected,
testSubject;
testSubject = {
push: function(o) {
this.a.push(o);
}
};
function func() {
Array.prototype.forEach.call(arguments, function(a) {
this.push(a);
}, this);
return this;
};
beforeEach(function() {
actual = [];
testSubject.a = [];
});
it('binds properly without a context', function() {
var context;
testSubject.func = function() {
context = this;
}.bind();
testSubject.func();
expect(context).toBe(function() {return this}.call());
});
it('binds properly without a context, and still supplies bound arguments', function() {
var a, context;
testSubject.func = function() {
a = Array.prototype.slice.call(arguments);
context = this;
}.bind(undefined, 1,2,3);
testSubject.func(1,2,3);
expect(a).toEqual([1,2,3,1,2,3]);
expect(context).toBe(function() {return this}.call());
});
it('binds a context properly', function() {
testSubject.func = func.bind(actual);
testSubject.func(1,2,3);
expect(actual).toEqual([1,2,3]);
expect(testSubject.a).toEqual([]);
});
it('binds a context and supplies bound arguments', function() {
testSubject.func = func.bind(actual, 1,2,3);
testSubject.func(4,5,6);
expect(actual).toEqual([1,2,3,4,5,6]);
expect(testSubject.a).toEqual([]);
});
it('returns properly without binding a context', function() {
testSubject.func = function() {
return this;
}.bind();
var context = testSubject.func();
expect(context).toBe(function() {return this}.call());
});
it('returns properly without binding a context, and still supplies bound arguments', function() {
var context;
testSubject.func = function() {
context = this;
return Array.prototype.slice.call(arguments);
}.bind(undefined, 1,2,3);
actual = testSubject.func(1,2,3);
expect(context).toBe(function() {return this}.call());
expect(actual).toEqual([1,2,3,1,2,3]);
});
it('returns properly while binding a context properly', function() {
var ret;
testSubject.func = func.bind(actual);
ret = testSubject.func(1,2,3);
expect(ret).toBe(actual);
expect(ret).not.toBe(testSubject);
});
it('returns properly while binding a context and supplies bound arguments', function() {
var ret;
testSubject.func = func.bind(actual, 1,2,3);
ret = testSubject.func(4,5,6);
expect(ret).toBe(actual);
expect(ret).not.toBe(testSubject);
});
it('passes the correct arguments as a constructor', function() {
var ret, expected = { name: "Correct" };
testSubject.func = function(arg) {
return arg;
}.bind({ name: "Incorrect" });
ret = new testSubject.func(expected);
expect(ret).toBe(expected);
});
it('returns the return value of the bound function when called as a constructor', function () {
var oracle = [1, 2, 3];
var subject = function () {
return oracle;
}.bind(null);
var result = new subject;
expect(result).toBe(oracle);
});
it('returns the correct value if constructor returns primitive', function() {
var oracle = [1, 2, 3];
var subject = function () {
return oracle;
}.bind(null);
var result = new subject;
expect(result).toBe(oracle);
oracle = {};
result = new subject;
expect(result).toBe(oracle);
oracle = function(){};
result = new subject;
expect(result).toBe(oracle);
oracle = "asdf";
result = new subject;
expect(result).not.toBe(oracle);
oracle = null;
result = new subject;
expect(result).not.toBe(oracle);
oracle = true;
result = new subject;
expect(result).not.toBe(oracle);
oracle = 1;
result = new subject;
expect(result).not.toBe(oracle);
});
it('returns the value that instance of original "class" when called as a constructor', function() {
var classA = function(x) {
this.name = x || "A";
}
var classB = classA.bind(null, "B");
var result = new classB;
expect(result instanceof classA).toBe(true);
expect(result instanceof classB).toBe(true);
});
});
});

View File

@ -0,0 +1,14 @@
describe('Number', function () {
'use strict';
describe('toFixed', function () {
it('should convert numbers correctly', function () {
expect((0.00008).toFixed(3)).toBe('0.000');
expect((0.9).toFixed(0)).toBe('1');
expect((1.255).toFixed(2)).toBe('1.25');
expect((1843654265.0774949).toFixed(5)).toBe('1843654265.07749');
expect((1000000000000000128).toFixed(0)).toBe('1000000000000000128');
});
});
});

View File

@ -0,0 +1,181 @@
describe('Object', function () {
"use strict";
describe("Object.keys", function () {
var obj = {
"str": "boz",
"obj": { },
"arr": [],
"bool": true,
"num": 42,
"null": null,
"undefined": undefined
};
var loopedValues = [];
for (var k in obj) {
loopedValues.push(k);
}
var keys = Object.keys(obj);
it('should have correct length', function () {
expect(keys.length).toBe(7);
});
it('should return an Array', function () {
expect(Array.isArray(keys)).toBe(true);
});
it('should return names which are own properties', function () {
keys.forEach(function (name) {
expect(obj.hasOwnProperty(name)).toBe(true);
});
});
it('should return names which are enumerable', function () {
keys.forEach(function (name) {
expect(loopedValues.indexOf(name)).toNotBe(-1);
})
});
it('should throw error for non object', function () {
var e = {};
expect(function () {
try {
Object.keys(42)
} catch (err) {
throw e;
}
}).toThrow(e);
});
});
describe("Object.isExtensible", function () {
var obj = { };
it('should return true if object is extensible', function () {
expect(Object.isExtensible(obj)).toBe(true);
});
it('should return false if object is not extensible', function () {
expect(Object.isExtensible(Object.preventExtensions(obj))).toBe(false);
});
it('should return false if object is seal', function () {
expect(Object.isExtensible(Object.seal(obj))).toBe(false);
});
it('should return false if object is freeze', function () {
expect(Object.isExtensible(Object.freeze(obj))).toBe(false);
});
it('should throw error for non object', function () {
var e1 = {};
expect(function () {
try {
Object.isExtensible(42)
} catch (err) {
throw e1;
}
}).toThrow(e1);
});
});
describe("Object.defineProperty", function () {
var obj;
beforeEach(function() {
obj = {};
Object.defineProperty(obj, 'name', {
value : 'Testing',
configurable: true,
enumerable: true,
writable: true
});
});
it('should return the initial value', function () {
expect(obj.hasOwnProperty('name')).toBeTruthy();
expect(obj.name).toBe('Testing');
});
it('should be setable', function () {
obj.name = 'Other';
expect(obj.name).toBe('Other');
});
it('should return the parent initial value', function () {
var child = Object.create(obj, {});
expect(child.name).toBe('Testing');
expect(child.hasOwnProperty('name')).toBeFalsy();
});
it('should not override the parent value', function () {
var child = Object.create(obj, {});
Object.defineProperty(child, 'name', {
value : 'Other'
});
expect(obj.name).toBe('Testing');
expect(child.name).toBe('Other');
});
it('should throw error for non object', function () {
expect(function () {
Object.defineProperty(42, 'name', {});
}).toThrow();
});
});
describe("Object.getOwnPropertyDescriptor", function () {
it('should return undefined because the object does not own the property', function () {
var descr = Object.getOwnPropertyDescriptor({}, 'name');
expect(descr).toBeUndefined()
});
it('should return a data descriptor', function () {
var descr = Object.getOwnPropertyDescriptor({name: 'Testing'}, 'name');
expect(descr).not.toBeUndefined();
expect(descr.value).toBe('Testing');
expect(descr.writable).toBe(true);
expect(descr.enumerable).toBe(true);
expect(descr.configurable).toBe(true);
});
it('should return undefined because the object does not own the property', function () {
var descr = Object.getOwnPropertyDescriptor(Object.create({name: 'Testing'}, {}), 'name');
expect(descr).toBeUndefined()
});
it('should return a data descriptor', function () {
var obj = Object.create({}, {
name: {
value : 'Testing',
configurable: true,
enumerable: true,
writable: true
}
});
var descr = Object.getOwnPropertyDescriptor(obj, 'name');
expect(descr).not.toBeUndefined();
expect(descr.value).toBe('Testing');
expect(descr.writable).toBe(true);
expect(descr.enumerable).toBe(true);
expect(descr.configurable).toBe(true);
});
it('should throw error for non object', function () {
expect(function () {
Object.getOwnPropertyDescriptor(42, 'name');
}).toThrow();
});
});
});

View File

@ -0,0 +1,204 @@
describe('String', function() {
"use strict";
describe("trim", function() {
var test = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF";
it('trims all ES5 whitespace', function() {
expect(test.trim()).toEqual("Hello, World!");
expect(test.trim().length).toEqual(13);
});
});
describe("split", function() {
var test = "ab";
it('If "separator" is undefined must return Array with one String - "this" string', function() {
expect(test.split()).toEqual([test]);
expect(test.split(void 0)).toEqual([test]);
});
it('If "separator" is undefined and "limit" set to 0 must return Array[]', function() {
expect(test.split(void 0, 0)).toEqual([]);
});
describe('Tests from Steven Levithan', function () {
it("''.split() results in ['']", function () {
expect(''.split()).toEqual(['']);
});
it("''.split(/./) results in ['']", function () {
expect(''.split(/./)).toEqual(['']);
});
it("''.split(/.?/) results in []", function () {
expect(''.split(/.?/)).toEqual([]);
});
it("''.split(/.??/) results in []", function () {
expect(''.split(/.??/)).toEqual([]);
});
it("'ab'.split(/a*/) results in ['', 'b']", function () {
expect('ab'.split(/a*/)).toEqual(['', 'b']);
});
it("'ab'.split(/a*?/) results in ['a', 'b']", function () {
expect('ab'.split(/a*?/)).toEqual(['a', 'b']);
});
it("'ab'.split(/(?:ab)/) results in ['', '']", function () {
expect('ab'.split(/(?:ab)/)).toEqual(['', '']);
});
it("'ab'.split(/(?:ab)*/) results in ['', '']", function () {
expect('ab'.split(/(?:ab)*/)).toEqual(['', '']);
});
it("'ab'.split(/(?:ab)*?/) results in ['a', 'b']", function () {
expect('ab'.split(/(?:ab)*?/)).toEqual(['a', 'b']);
});
it("'test'.split('') results in ['t', 'e', 's', 't']", function () {
expect('test'.split('')).toEqual(['t', 'e', 's', 't']);
});
it("'test'.split() results in ['test']", function () {
expect('test'.split()).toEqual(['test']);
});
it("'111'.split(1) results in ['', '', '', '']", function () {
expect('111'.split(1)).toEqual(['', '', '', '']);
});
it("'test'.split(/(?:)/, 2) results in ['t', 'e']", function () {
expect('test'.split(/(?:)/, 2)).toEqual(['t', 'e']);
});
it("'test'.split(/(?:)/, -1) results in ['t', 'e', 's', 't']", function () {
expect('test'.split(/(?:)/, -1)).toEqual(['t', 'e', 's', 't']);
});
it("'test'.split(/(?:)/, undefined) results in ['t', 'e', 's', 't']", function () {
expect('test'.split(/(?:)/, undefined)).toEqual(['t', 'e', 's', 't']);
});
it("'test'.split(/(?:)/, null) results in []", function () {
expect('test'.split(/(?:)/, null)).toEqual([]);
});
it("'test'.split(/(?:)/, NaN) results in []", function () {
expect('test'.split(/(?:)/, NaN)).toEqual([]);
});
it("'test'.split(/(?:)/, true) results in ['t']", function () {
expect('test'.split(/(?:)/, true)).toEqual(['t']);
});
it("'test'.split(/(?:)/, '2') results in ['t', 'e']", function () {
expect('test'.split(/(?:)/, '2')).toEqual(['t', 'e']);
});
it("'test'.split(/(?:)/, 'two') results in []", function () {
expect('test'.split(/(?:)/, 'two')).toEqual([]);
});
it("'a'.split(/-/) results in ['a']", function () {
expect('a'.split(/-/)).toEqual(['a']);
});
it("'a'.split(/-?/) results in ['a']", function () {
expect('a'.split(/-?/)).toEqual(['a']);
});
it("'a'.split(/-??/) results in ['a']", function () {
expect('a'.split(/-??/)).toEqual(['a']);
});
it("'a'.split(/a/) results in ['', '']", function () {
expect('a'.split(/a/)).toEqual(['', '']);
});
it("'a'.split(/a?/) results in ['', '']", function () {
expect('a'.split(/a?/)).toEqual(['', '']);
});
it("'a'.split(/a??/) results in ['a']", function () {
expect('a'.split(/a??/)).toEqual(['a']);
});
it("'ab'.split(/-/) results in ['ab']", function () {
expect('ab'.split(/-/)).toEqual(['ab']);
});
it("'ab'.split(/-?/) results in ['a', 'b']", function () {
expect('ab'.split(/-?/)).toEqual(['a', 'b']);
});
it("'ab'.split(/-??/) results in ['a', 'b']", function () {
expect('ab'.split(/-??/)).toEqual(['a', 'b']);
});
it("'a-b'.split(/-/) results in ['a', 'b']", function () {
expect('a-b'.split(/-/)).toEqual(['a', 'b']);
});
it("'a-b'.split(/-?/) results in ['a', 'b']", function () {
expect('a-b'.split(/-?/)).toEqual(['a', 'b']);
});
it("'a-b'.split(/-??/) results in ['a', '-', 'b']", function () {
expect('a-b'.split(/-??/)).toEqual(['a', '-', 'b']);
});
it("'a--b'.split(/-/) results in ['a', '', 'b']", function () {
expect('a--b'.split(/-/)).toEqual(['a', '', 'b']);
});
it("'a--b'.split(/-?/) results in ['a', '', 'b']", function () {
expect('a--b'.split(/-?/)).toEqual(['a', '', 'b']);
});
it("'a--b'.split(/-??/) results in ['a', '-', '-', 'b']", function () {
expect('a--b'.split(/-??/)).toEqual(['a', '-', '-', 'b']);
});
it("''.split(/()()/) results in []", function () {
expect(''.split(/()()/)).toEqual([]);
});
it("'.'.split(/()()/) results in ['.']", function () {
expect('.'.split(/()()/)).toEqual(['.']);
});
it("'.'.split(/(.?)(.?)/) results in ['', '.', '', '']", function () {
expect('.'.split(/(.?)(.?)/)).toEqual(['', '.', '', '']);
});
it("'.'.split(/(.??)(.??)/) results in ['.']", function () {
expect('.'.split(/(.??)(.??)/)).toEqual(['.']);
});
it("'.'.split(/(.)?(.)?/) results in ['', '.', undefined, '']", function () {
expect('.'.split(/(.)?(.)?/)).toEqual(['', '.', undefined, '']);
});
it("'A<B>bold</B>and<CODE>coded</CODE>'.split(/<(\\/)?([^<>]+)>/) results in ['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']", function () {
expect('A<B>bold</B>and<CODE>coded</CODE>'.split(/<(\/)?([^<>]+)>/)).toEqual(['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']);
});
it("'tesst'.split(/(s)*/) results in ['t', undefined, 'e', 's', 't']", function () {
expect('tesst'.split(/(s)*/)).toEqual(['t', undefined, 'e', 's', 't']);
});
it("'tesst'.split(/(s)*?/) results in ['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']", function () {
expect('tesst'.split(/(s)*?/)).toEqual(['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']);
});
it("'tesst'.split(/(s*)/) results in ['t', '', 'e', 'ss', 't']", function () {
expect('tesst'.split(/(s*)/)).toEqual(['t', '', 'e', 'ss', 't']);
});
it("'tesst'.split(/(s*?)/) results in ['t', '', 'e', '', 's', '', 's', '', 't']", function () {
expect('tesst'.split(/(s*?)/)).toEqual(['t', '', 'e', '', 's', '', 's', '', 't']);
});
it("'tesst'.split(/(?:s)*/) results in ['t', 'e', 't']", function () {
expect('tesst'.split(/(?:s)*/)).toEqual(['t', 'e', 't']);
});
it("'tesst'.split(/(?=s+)/) results in ['te', 's', 'st']", function () {
expect('tesst'.split(/(?=s+)/)).toEqual(['te', 's', 'st']);
});
it("'test'.split('t') results in ['', 'es', '']", function () {
expect('test'.split('t')).toEqual(['', 'es', '']);
});
it("'test'.split('es') results in ['t', 't']", function () {
expect('test'.split('es')).toEqual(['t', 't']);
});
it("'test'.split(/t/) results in ['', 'es', '']", function () {
expect('test'.split(/t/)).toEqual(['', 'es', '']);
});
it("'test'.split(/es/) results in ['t', 't']", function () {
expect('test'.split(/es/)).toEqual(['t', 't']);
});
it("'test'.split(/(t)/) results in ['', 't', 'es', 't', '']", function () {
expect('test'.split(/(t)/)).toEqual(['', 't', 'es', 't', '']);
});
it("'test'.split(/(es)/) results in ['t', 'es', 't']", function () {
expect('test'.split(/(es)/)).toEqual(['t', 'es', 't']);
});
it("'test'.split(/(t)(e)(s)(t)/) results in ['', 't', 'e', 's', 't', '']", function () {
expect('test'.split(/(t)(e)(s)(t)/)).toEqual(['', 't', 'e', 's', 't', '']);
});
it("'.'.split(/(((.((.??)))))/) results in ['', '.', '.', '.', '', '', '']", function () {
expect('.'.split(/(((.((.??)))))/)).toEqual(['', '.', '.', '.', '', '', '']);
});
it("'.'.split(/(((((.??)))))/) results in ['.']", function () {
expect('.'.split(/(((((.??)))))/)).toEqual(['.']);
});
it("'a b c d'.split(/ /, -(Math.pow(2, 32) - 1)) results in ['a']", function () {
expect('a b c d'.split(/ /, -(Math.pow(2, 32) - 1))).toEqual(['a']);
});
it("'a b c d'.split(/ /, Math.pow(2, 32) + 1) results in ['a']", function () {
expect('a b c d'.split(/ /, Math.pow(2, 32) + 1)).toEqual(['a']);
});
it("'a b c d'.split(/ /, Infinity) results in []", function () {
expect('a b c d'.split(/ /, Infinity)).toEqual([]);
});
});
});
});