diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/split')
118 files changed, 4139 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-new-reg-exp-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-new-reg-exp-and-instance-is-string-hello.js new file mode 100644 index 0000000000..d4776d407d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-new-reg-exp-and-instance-is-string-hello.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T10 +description: Argument is new RegExp, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re); + +var __expected = ["h", "e", "l", "l", "o"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-null-and-instance-is-function-call-that-returned-string.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-null-and-instance-is-function-call-that-returned-string.js new file mode 100644 index 0000000000..5fe24e5820 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-null-and-instance-is-function-call-that-returned-string.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T5 +description: > + Argument is null, and instance is function call that returned + string +---*/ + +//since ToString(null) evaluates to "null" split(null) evaluates to split("null",0) +var __split = function() { + return "gnulluna" +}().split(null); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "g", 'The value of __split[0] is "g"'); +assert.sameValue(__split[1], "una", 'The value of __split[1] is "una"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-reg-exp-a-z-and-instance-is-string-abc.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-reg-exp-a-z-and-instance-is-string-abc.js new file mode 100644 index 0000000000..1a68255647 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-reg-exp-a-z-and-instance-is-string-abc.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T25 +description: Argument is RegExp('[a-z]'), and instance is String("abc") +---*/ + +var __string = new String("abc"); + +var __re = new RegExp('[a-z]'); + +var __split = __string.split(__re); + +var __expected = ["", "", "", ""]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-a-z-and-instance-is-string-abc.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-a-z-and-instance-is-string-abc.js new file mode 100644 index 0000000000..9540daed46 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-a-z-and-instance-is-string-abc.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T24 +description: Argument is regexp /[a-z]/, and instance is String("abc") +---*/ + +var __string = new String("abc"); + +var __re = /[a-z]/; + +var __split = __string.split(__re); + +var __expected = ["", "", "", ""]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-and-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-and-instance-is-number.js new file mode 100644 index 0000000000..bc958c246d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-and-instance-is-number.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T17 +description: Argument is regexp, and instance is Number +---*/ + +var __re = /\u0037\u0037/g; + +Number.prototype.split = String.prototype.split; + +var __split = (6776767677.006771122677555).split(__re); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 4, 'The value of __split.length is 4'); +assert.sameValue(__split[0], "6", 'The value of __split[0] is "6"'); +assert.sameValue(__split[1], "67676", 'The value of __split[1] is "67676"'); +assert.sameValue(__split[2], ".006", 'The value of __split[2] is ".006"'); +assert.sameValue(__split[3], "1", 'The value of __split[3] is "1"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-d-and-instance-is-string-dfe23iu-34-65.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-d-and-instance-is-string-dfe23iu-34-65.js new file mode 100644 index 0000000000..2d5e255a69 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-d-and-instance-is-string-dfe23iu-34-65.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T22 +description: > + Argument is regexp /\d+/, and instance is String("dfe23iu 34 + =+65--") +---*/ + +var __string = new String("dfe23iu 34 =+65--"); + +var __re = /\d+/; + +var __split = __string.split(__re); + +var __expected = ["dfe", "iu ", " =+", "--"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-l-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-l-and-instance-is-string-hello.js new file mode 100644 index 0000000000..3b8db5c5e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-l-and-instance-is-string-hello.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T1 +description: Argument is regexp /l/, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 3, 'The value of __split.length is 3'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); +assert.sameValue(__split[2], "o", 'The value of __split[2] is "o"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-reg-exp-d-and-instance-is-string-dfe23iu-34-65.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-reg-exp-d-and-instance-is-string-dfe23iu-34-65.js new file mode 100644 index 0000000000..15e6940007 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-reg-exp-d-and-instance-is-string-dfe23iu-34-65.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T23 +description: > + Argument is regexp RegExp('\\d+'), and instance is String("dfe23iu + 34 =+65--") +---*/ + +var __string = new String("dfe23iu 34 =+65--"); + +var __re = new RegExp('\\d+'); + +var __split = __string.split(__re); + +var __expected = ["dfe", "iu ", " =+", "--"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-s-and-instance-is-string-a-b-c-de-f.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-s-and-instance-is-string-a-b-c-de-f.js new file mode 100644 index 0000000000..88d2d09181 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-s-and-instance-is-string-a-b-c-de-f.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T19 +description: Argument is regexp /\s/, and instance is String("a b c de f") +---*/ + +var __string = new String("a b c de f"); + +var __re = /\s/; + +var __split = __string.split(__re); + +var __expected = ["a", "b", "c", "de", "f"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-x-and-instance-is-string-a-b-c-de-f.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-x-and-instance-is-string-a-b-c-de-f.js new file mode 100644 index 0000000000..cdc71fda05 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-regexp-x-and-instance-is-string-a-b-c-de-f.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T21 +description: Argument is regexp /\X/, and instance is String("a b c de f") +---*/ + +var __string = new String("a b c de f"); + +var __re = /X/; + +var __split = __string.split(__re); + +var __expected = ["a b c de f"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-undefined-and-instance-is-string.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-undefined-and-instance-is-string.js new file mode 100644 index 0000000000..654318a985 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-undefined-and-instance-is-string.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T7 +description: Argument is undefined, and instance is String +---*/ + +var __split = String("undefinedd").split(undefined); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "undefinedd", 'The value of __split[0] is "undefinedd"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/argument-is-void-0-and-instance-is-string-object-object-have-overrided-to-string-function.js b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-void-0-and-instance-is-string-object-object-have-overrided-to-string-function.js new file mode 100644 index 0000000000..56ba974fa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/argument-is-void-0-and-instance-is-string-object-object-have-overrided-to-string-function.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T8 +description: > + Argument is void 0, and instance is String(object), object have + overrided toString function +---*/ + +var __obj = { + toString: function() {} +}; + +var __split = String(__obj).split(void 0); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "undefined", 'The value of __split[0] is "undefined"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-boolean-expression-function-call-and-null-and-instance-is-boolean.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-boolean-expression-function-call-and-null-and-instance-is-boolean.js new file mode 100644 index 0000000000..d92c21c4b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-boolean-expression-function-call-and-null-and-instance-is-boolean.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T2 +description: > + Arguments are boolean expression, function call and null, and + instance is Boolean +---*/ + +var __instance = new Boolean; + +__instance.split = String.prototype.split; + +var __split = __instance.split("A" !== "\u0041", function() { + return 0; +}(), null); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 0, 'The value of __split.length is 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-false-and-true-and-instance-is-object.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-false-and-true-and-instance-is-object.js new file mode 100644 index 0000000000..c5206d2e4e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-false-and-true-and-instance-is-object.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T1 +description: Arguments are false and true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.split = String.prototype.split; + +var __split = __instance.split(true, false); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 0, 'The value of __split.length is 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-0-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-0-and-instance-is-string-hello.js new file mode 100644 index 0000000000..bd92f4ec0b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-0-and-instance-is-string-hello.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T11 +description: Arguments are new RegExp and 0, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, 0); + +var __expected = []; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-1-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-1-and-instance-is-string-hello.js new file mode 100644 index 0000000000..a00eb4d15e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-1-and-instance-is-string-hello.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T12 +description: Arguments are new RegExp and 1, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, 1); + +var __expected = ["h"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-2-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-2-and-instance-is-string-hello.js new file mode 100644 index 0000000000..fbb5b9b0be --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-2-and-instance-is-string-hello.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T13 +description: Arguments are new RegExp and 2, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, 2); + +var __expected = ["h", "e"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-3-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-3-and-instance-is-string-hello.js new file mode 100644 index 0000000000..f4b454e7a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-3-and-instance-is-string-hello.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T14 +description: Arguments are new RegExp and 3, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, 3); + +var __expected = ["h", "e", "l"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-4-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-4-and-instance-is-string-hello.js new file mode 100644 index 0000000000..1aa2db70d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-4-and-instance-is-string-hello.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T15 +description: Arguments are new RegExp and 4, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, 4); + +var __expected = ["h", "e", "l", "l"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-hi-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-hi-and-instance-is-string-hello.js new file mode 100644 index 0000000000..3d3f2779fa --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-hi-and-instance-is-string-hello.js @@ -0,0 +1,48 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T18 +description: Arguments are new RegExp and "hi", and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, "hi"); + +var __expected = []; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-undefined-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-undefined-and-instance-is-string-hello.js new file mode 100644 index 0000000000..a74349e475 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-undefined-and-instance-is-string-hello.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T17 +description: > + Arguments are new RegExp and undefined, and instance is + String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, undefined); + +var __expected = ["h", "e", "l", "l", "o"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-void-0-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-void-0-and-instance-is-string-hello.js new file mode 100644 index 0000000000..805d58c864 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-new-reg-exp-and-void-0-and-instance-is-string-hello.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T16 +description: > + Arguments are new RegExp and void 0, and instance is + String("hello") +---*/ + +var __string = new String("hello"); + +var __re = new RegExp; + +var __split = __string.split(__re, void 0); + +var __expected = ["h", "e", "l", "l", "o"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-0-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-0-and-instance-is-string-hello.js new file mode 100644 index 0000000000..15ca404c65 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-0-and-instance-is-string-hello.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T2 +description: Arguments are regexp /l/ and 0, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, 0); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 0, 'The value of __split.length is 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-1-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-1-and-instance-is-string-hello.js new file mode 100644 index 0000000000..ddf4d9d37e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-1-and-instance-is-string-hello.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T3 +description: Arguments are regexp /l/ and 1, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, 1); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-2-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-2-and-instance-is-string-hello.js new file mode 100644 index 0000000000..22892d3772 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-2-and-instance-is-string-hello.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T4 +description: Arguments are regexp /l/ and 2, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, 2); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-3-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-3-and-instance-is-string-hello.js new file mode 100644 index 0000000000..4dab82db93 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-3-and-instance-is-string-hello.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T5 +description: Arguments are regexp /l/ and 3, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, 3); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 3, 'The value of __split.length is 3'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); +assert.sameValue(__split[2], "o", 'The value of __split[2] is "o"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-4-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-4-and-instance-is-string-hello.js new file mode 100644 index 0000000000..aecc5cee2b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-4-and-instance-is-string-hello.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T6 +description: Arguments are regexp /l/ and 4, and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, 4); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 3, 'The value of __split.length is 3'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); +assert.sameValue(__split[2], "o", 'The value of __split[2] is "o"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-hi-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-hi-and-instance-is-string-hello.js new file mode 100644 index 0000000000..6ae072cb74 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-hi-and-instance-is-string-hello.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T8 +description: Arguments are regexp /l/ and "hi", and instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, "hi"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 0, 'The value of __split.length is 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-undefined-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-undefined-and-instance-is-string-hello.js new file mode 100644 index 0000000000..596e6c669b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-undefined-and-instance-is-string-hello.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T9 +description: > + Arguments are regexp /l/ and undefined, and instance is + String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, undefined); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 3, 'The value of __split.length is 3'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); +assert.sameValue(__split[2], "o", 'The value of __split[2] is "o"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-void-0-and-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-void-0-and-instance-is-string-hello.js new file mode 100644 index 0000000000..af5121e832 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-l-and-void-0-and-instance-is-string-hello.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T7 +description: > + Arguments are regexp /l/ and void 0, and instance is + String("hello") +---*/ + +var __string = new String("hello"); + +var __re = /l/; + +var __split = __string.split(__re, void 0); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 3, 'The value of __split.length is 3'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); +assert.sameValue(__split[2], "o", 'The value of __split[2] is "o"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-s-and-3-and-instance-is-string-a-b-c-de-f.js b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-s-and-3-and-instance-is-string-a-b-c-de-f.js new file mode 100644 index 0000000000..dfad06efc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/arguments-are-regexp-s-and-3-and-instance-is-string-a-b-c-de-f.js @@ -0,0 +1,50 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. If separator is a regular expression then + inside of SplitMatch helper the [[Match]] method of R is called giving it the arguments corresponding +es5id: 15.5.4.14_A4_T20 +description: > + Arguments are regexp /\s/ and 3, and instance is String("a b c de + f") +---*/ + +var __string = new String("a b c de f"); + +var __re = /\s/; + +var __split = __string.split(__re, 3); + +var __expected = ["a", "b", "c"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/browser.js b/js/src/tests/test262/built-ins/String/prototype/split/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-0-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-0-instance-is-number.js new file mode 100644 index 0000000000..32c3cb4fd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-0-instance-is-number.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T32 +description: Call split(1,0), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, 0); + +var __expected = []; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-1-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-1-instance-is-number.js new file mode 100644 index 0000000000..a90b9f50a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-1-instance-is-number.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T30 +description: Call split(1,1), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, 1); + +var __expected = [""]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-100-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-100-instance-is-number.js new file mode 100644 index 0000000000..dcbf89d5f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-100-instance-is-number.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T33 +description: Call split(1,100), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, 100); + +var __expected = ["", "00", "", "", "", "22", "33", "44", "60"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-2-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-2-instance-is-number.js new file mode 100644 index 0000000000..f47b60b4fb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-2-instance-is-number.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T31 +description: Call split(1,2), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, 2); + +var __expected = ["", "00"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-boo-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-boo-instance-is-number.js new file mode 100644 index 0000000000..1287bfd97c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-boo-instance-is-number.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T36 +description: Call split(1,"boo"), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, "boo"); + +var __expected = []; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-instance-is-number.js new file mode 100644 index 0000000000..58f39573fe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-instance-is-number.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T29 +description: Call split(1), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1); + +var __expected = ["", "00", "", "", "", "22", "33", "44", "60"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-math-pow-2-32-1-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-math-pow-2-32-1-instance-is-number.js new file mode 100644 index 0000000000..f651f80262 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-math-pow-2-32-1-instance-is-number.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T37 +description: Call split(1,-Math.pow(2,32)+1), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, -Math.pow(2, 32) + 1); + +var __expected = [""]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-void-0-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-void-0-instance-is-number.js new file mode 100644 index 0000000000..f60ded8079 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-1-void-0-instance-is-number.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T34 +description: Call split(1,void 0), instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, void 0); + +var __expected = ["", "00", "", "", "", "22", "33", "44", "60"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-123-instance-is-this123is123a123string123object.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-123-instance-is-this123is123a123string123object.js new file mode 100644 index 0000000000..d524ed8d4e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-123-instance-is-this123is123a123string123object.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T10 +description: Call split(123), instance is "this123is123a123string123object" +---*/ + +var __string = "this123is123a123string123object"; +var __expected = ["this", "is", "a", "string", "object"]; + +var __split = __string.split(123); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var i = 0; i < __expected.length; i++) { + assert.sameValue(__expected[i], __split[i], 'The value of __expected[i] is expected to equal the value of __split[i]'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-2-instance-is-string-one-two-three-four-five.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-2-instance-is-string-one-two-three-four-five.js new file mode 100644 index 0000000000..99c67b6595 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-2-instance-is-string-one-two-three-four-five.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T3 +description: Call split(/ /,2), instance is String("one two three four five") +---*/ + +var __string = new String("one two three four five"); + +var __split = __string.split(/ /, 2); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "one", 'The value of __split[0] is "one"'); +assert.sameValue(__split[1], "two", 'The value of __split[1] is "two"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-4-instance-is-string-one-1-two-2-four-4.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-4-instance-is-string-one-1-two-2-four-4.js new file mode 100644 index 0000000000..2df56a28ea --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-4-instance-is-string-one-1-two-2-four-4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T13 +description: Call split("-4"), instance is String("one-1 two-2 four-4") +---*/ + +var __string = new String("one-1 two-2 four-4"); + +var __split = __string.split("-4"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "one-1 two-2 four", 'The value of __split[0] is "one-1 two-2 four"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-h-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-h-instance-is-string-hello.js new file mode 100644 index 0000000000..162fbfb2a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-h-instance-is-string-hello.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T24 +description: Call split("h"), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split("h"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); +assert.sameValue(__split[1], "ello", 'The value of __split[1] is "ello"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-hello-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-hello-instance-is-string-hello.js new file mode 100644 index 0000000000..0765fa6752 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-hello-instance-is-string-hello.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T26 +description: Call split("hello"), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split("hello"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-hellothere-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-hellothere-instance-is-string-hello.js new file mode 100644 index 0000000000..8eac8b824b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-hellothere-instance-is-string-hello.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T28 +description: Call split("hellothere"), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split("hellothere"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "hello", 'The value of __split[0] is "hello"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-empty-string-object.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-empty-string-object.js new file mode 100644 index 0000000000..cbb3024480 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-empty-string-object.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T16 +description: Call split(" "), instance is empty String object +---*/ + +var __string = new String(); + +var __split = __string.split(" "); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-1-two-2-four-4.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-1-two-2-four-4.js new file mode 100644 index 0000000000..90c30450fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-1-two-2-four-4.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T6 +description: Call split(''), instance is String("one-1 two-2 four-4") +---*/ + +var __string = new String("one-1 two-2 three-3"); + +var __split = __string.split(''); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __string.length, + 'The value of __split.length is expected to equal the value of __string.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var i = 0; i < __string.length; i++) { + assert.sameValue( + __split[i], + __string.charAt(i), + 'The value of __split[i] must return the same value returned by __string.charAt(i)' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-two-three-four-five.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-two-three-four-five.js new file mode 100644 index 0000000000..597a35aca5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-two-three-four-five.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T2 +description: Call split(" "), instance is String("one two three four five") +---*/ + +var __string = new String("one two three four five"); + +var __split = __string.split(" "); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 5, 'The value of __split.length is 5'); +assert.sameValue(__split[0], "one", 'The value of __split[0] is "one"'); +assert.sameValue(__split[1], "two", 'The value of __split[1] is "two"'); +assert.sameValue(__split[2], "three", 'The value of __split[2] is "three"'); +assert.sameValue(__split[3], "four", 'The value of __split[3] is "four"'); +assert.sameValue(__split[4], "five", 'The value of __split[4] is "five"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-two-three.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-two-three.js new file mode 100644 index 0000000000..d61e224c40 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string-one-two-three.js @@ -0,0 +1,35 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T4 +description: Call split(""), instance is String("one two three") +---*/ + +var __string = new String("one two three"); + +var __split = __string.split(""); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __string.length, + 'The value of __split.length is expected to equal the value of __string.length' +); + +assert.sameValue(__split[0], "o", 'The value of __split[0] is "o"'); +assert.sameValue(__split[1], "n", 'The value of __split[1] is "n"'); +assert.sameValue(__split[11], "e", 'The value of __split[11] is "e"'); +assert.sameValue(__split[12], "e", 'The value of __split[12] is "e"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string.js new file mode 100644 index 0000000000..a556e496fe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-instance-is-string.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T18 +description: Call split(" "), instance is String(" ") +---*/ + +var __string = new String(" "); + +var __split = __string.split(" "); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-0-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-0-instance-is-string-hello.js new file mode 100644 index 0000000000..de4c6c8d6c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-0-instance-is-string-hello.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T39 +description: Call split("l",0), instance is String("hello") +---*/ + +var __instance = new String("hello"); + +var __split = __instance.split("l", 0); + +var __expected = []; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-1-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-1-instance-is-string-hello.js new file mode 100644 index 0000000000..aaf146be6c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-1-instance-is-string-hello.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T40 +description: Call split("l",1), instance is String("hello") +---*/ + +var __instance = new String("hello"); + +var __split = __instance.split("l", 1); + +var __expected = ["he"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-2-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-2-instance-is-string-hello.js new file mode 100644 index 0000000000..aa693ae1e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-2-instance-is-string-hello.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T41 +description: Call split("l",2), instance is String("hello") +---*/ + +var __instance = new String("hello"); + +var __split = __instance.split("l", 2); + +var __expected = ["he", ""]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-3-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-3-instance-is-string-hello.js new file mode 100644 index 0000000000..34d4facb2c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-3-instance-is-string-hello.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T42 +description: Call split("l",3), instance is String("hello") +---*/ + +var __instance = new String("hello"); + +var __split = __instance.split("l", 3); + +var __expected = ["he", "", "o"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-4-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-4-instance-is-string-hello.js new file mode 100644 index 0000000000..b8606c4453 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-4-instance-is-string-hello.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T43 +description: Call split("l",4), instance is String("hello") +---*/ + +var __instance = new String("hello"); + +var __split = __instance.split("l", 4); + +var __expected = ["he", "", "o"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-instance-is-string-hello.js new file mode 100644 index 0000000000..7b0be6c939 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-instance-is-string-hello.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T22 +description: Call split("l"), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split("l"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 3, 'The value of __split.length is 3'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); +assert.sameValue(__split[2], "o", 'The value of __split[2] is "o"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-na-n-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-na-n-instance-is-string-hello.js new file mode 100644 index 0000000000..4d436b2eac --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-l-na-n-instance-is-string-hello.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T38 +description: Call split("l",NaN), instance is String("hello") +---*/ + +var __instance = new String("hello"); + +var __split = __instance.split("l", NaN); + +var __expected = []; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +assert.sameValue(__split[0], __expected[0], 'The value of __split[0] is expected to equal the value of __expected[0]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-ll-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-ll-instance-is-string-hello.js new file mode 100644 index 0000000000..7cbe9035a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-ll-instance-is-string-hello.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T21 +description: Call split("ll"), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split("ll"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "he", 'The value of __split[0] is "he"'); +assert.sameValue(__split[1], "o", 'The value of __split[1] is "o"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-new-reg-exp.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-new-reg-exp.js new file mode 100644 index 0000000000..fbc4612a4a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-new-reg-exp.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T20 +description: Call split(new RegExp) +---*/ + +var __string = new String("one-1 two-2 three-3"); + +var __split = __string.split(new RegExp); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __string.length, + 'The value of __split.length is expected to equal the value of __string.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var i = 0; i < __string.length; i++) { + assert.sameValue(__string.charAt(i), __split[i], '__string.charAt("0") must return the value of __split[i]'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-null-instance-is-thisnullisnullanullstringnullobject.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-null-instance-is-thisnullisnullanullstringnullobject.js new file mode 100644 index 0000000000..1a3545c568 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-null-instance-is-thisnullisnullanullstringnullobject.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T8 +description: Call split(null), instance is "thisnullisnullanullstringnullobject" +---*/ + +var __string = "thisnullisnullanullstringnullobject"; +var __expected = ["this", "is", "a", "string", "object"]; + +var __split = __string.split(null); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var i = 0; i < __expected.length; i++) { + assert.sameValue(__expected[i], __split[i], 'The value of __expected[i] is expected to equal the value of __split[i]'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-o-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-o-instance-is-string-hello.js new file mode 100644 index 0000000000..3fcd338fb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-o-instance-is-string-hello.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T25 +description: Call split("o"), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split("o"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "hell", 'The value of __split[0] is "hell"'); +assert.sameValue(__split[1], "", 'The value of __split[1] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-on-instance-is-string-one-1-two-2-four-4.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-on-instance-is-string-one-1-two-2-four-4.js new file mode 100644 index 0000000000..4feaf246c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-on-instance-is-string-one-1-two-2-four-4.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T14 +description: Call split("on"), instance is String("one-1 two-2 four-4") +---*/ + +var __string = new String("one-1 two-2 four-4"); + +var __split = __string.split("on"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); +assert.sameValue(__split[1], "e-1 two-2 four-4", 'The value of __split[1] is "e-1 two-2 four-4"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-r-42-instance-is-string-one-1-two-2-four-4.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-r-42-instance-is-string-one-1-two-2-four-4.js new file mode 100644 index 0000000000..edd19b05df --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-r-42-instance-is-string-one-1-two-2-four-4.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T12 +description: Call split("r-42"), instance is String("one-1 two-2 four-4") +---*/ + +var __string = new String("one-1 two-2 four-4"); + +var __split = __string.split("r-42"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "one-1 two-2 four-4", 'The value of __split[0] is "one-1 two-2 four-4"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-true-instance-is-thistrueistrueatruestringtrueobject.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-true-instance-is-thistrueistrueatruestringtrueobject.js new file mode 100644 index 0000000000..e57db41e19 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-true-instance-is-thistrueistrueatruestringtrueobject.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T9 +description: Call split(true), instance is "thistrueistrueatruestringtrueobject" +---*/ + +var __string = "thistrueistrueatruestringtrueobject"; +var __expected = ["this", "is", "a", "string", "object"]; + +var __split = __string.split(true); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var i = 0; i < __expected.length; i++) { + assert.sameValue(__expected[i], __split[i], 'The value of __expected[i] is expected to equal the value of __split[i]'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-undefined-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-undefined-instance-is-string-hello.js new file mode 100644 index 0000000000..42f31b038a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-undefined-instance-is-string-hello.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T27 +description: Call split(undefined), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split(undefined); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "hello", 'The value of __split[0] is "hello"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-void-0-instance-is-thisundefinedisundefinedaundefinedstringundefinedobject.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-void-0-instance-is-thisundefinedisundefinedaundefinedstringundefinedobject.js new file mode 100644 index 0000000000..a1b9436924 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-void-0-instance-is-thisundefinedisundefinedaundefinedstringundefinedobject.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T7 +description: > + Call split(void 0), instance is + "thisundefinedisundefinedaundefinedstringundefinedobject" +---*/ + +var __string = "thisundefinedisundefinedaundefinedstringundefinedobject"; +var __expected = [__string]; + +var __split = __string.split(void 0); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var i = 0; i < __expected.length; i++) { + assert.sameValue(__expected[i], __split[i], 'The value of __expected[i] is expected to equal the value of __split[i]'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-without-arguments-and-instance-is-empty-string.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-without-arguments-and-instance-is-empty-string.js new file mode 100644 index 0000000000..5b60299418 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-without-arguments-and-instance-is-empty-string.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T4 +description: Call split without arguments, and instance is empty string +---*/ + +//since ToString() evaluates to "" split() evaluates to split("",0) +var __split = "".split(); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-x-instance-is-empty-string.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-x-instance-is-empty-string.js new file mode 100644 index 0000000000..ef00d33da6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-x-instance-is-empty-string.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T19 +description: Call split("x"), instance is empty string +---*/ + +var __string = ""; + +var __split = __string.split("x"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/call-split-x-instance-is-string-hello.js b/js/src/tests/test262/built-ins/String/prototype/split/call-split-x-instance-is-string-hello.js new file mode 100644 index 0000000000..da2544c959 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/call-split-x-instance-is-string-hello.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T23 +description: Call split("x"), instance is String("hello") +---*/ + +var __string = new String("hello"); + +var __split = __string.split("x"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "hello", 'The value of __split[0] is "hello"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/checking-by-using-eval.js b/js/src/tests/test262/built-ins/String/prototype/split/checking-by-using-eval.js new file mode 100644 index 0000000000..f7a4cbd146 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/checking-by-using-eval.js @@ -0,0 +1,47 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T3 +description: Checking by using eval +---*/ + +var split = String.prototype.split.bind(this); + +var __obj__lim = { + valueOf: function() { + return 5; + } +}; + +try { + toString = Object.prototype.toString; +} catch (e) {; +} + +//Checks are only valid if we can overwrite the global object's toString method +//(which ES5 doesn't even require to exist) +if (toString === Object.prototype.toString) { + var __class__ = toString(); + + var __split = split(eval("\"[\""), __obj__lim); + + assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + + assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' + ); + + assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); + assert.sameValue(__split[1].substring(0, 6), "object", '__split[1].substring(0, 6) must return "object"'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/checking-if-creating-the-string-prototype-split-object-fails.js b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-creating-the-string-prototype-split-object-fails.js new file mode 100644 index 0000000000..64f6ca94e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-creating-the-string-prototype-split-object-fails.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.split can't be used as constructor +es5id: 15.5.4.14_A7 +description: Checking if creating the String.prototype.split object fails +---*/ + +var __FACTORY = String.prototype.split; + +try { + var __instance = new __FACTORY; + Test262Error.thrower('#1: __FACTORY = String.prototype.split; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/checking-if-deleting-the-string-prototype-split-length-property-fails.js b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-deleting-the-string-prototype-split-length-property-fails.js new file mode 100644 index 0000000000..fb4decb365 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-deleting-the-string-prototype-split-length-property-fails.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The String.prototype.split.length property does not have the attribute + DontDelete +es5id: 15.5.4.14_A9 +description: > + Checking if deleting the String.prototype.split.length property + fails +---*/ + +assert( + String.prototype.split.hasOwnProperty('length'), + 'String.prototype.split.hasOwnProperty(\'length\') must return true' +); + +assert(delete String.prototype.split.length, 'The value of `delete String.prototype.split.length` is true'); + +assert( + !String.prototype.split.hasOwnProperty('length'), + 'The value of `!String.prototype.split.hasOwnProperty(\'length\')` is true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/checking-if-enumerating-the-string-prototype-split-length-property-fails.js b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-enumerating-the-string-prototype-split-length-property-fails.js new file mode 100644 index 0000000000..a71e5c4d21 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-enumerating-the-string-prototype-split-length-property-fails.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The String.prototype.split.length property has the attribute DontEnum +es5id: 15.5.4.14_A8 +description: > + Checking if enumerating the String.prototype.split.length property + fails +---*/ + +assert( + String.prototype.split.hasOwnProperty('length'), + 'String.prototype.split.hasOwnProperty(\'length\') must return true' +); + +assert( + !String.prototype.split.propertyIsEnumerable('length'), + 'The value of `!String.prototype.split.propertyIsEnumerable(\'length\')` is true' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.split) { + if (p === "length") { + count++; + } +} + +assert.sameValue(count, 0, 'The value of `count` is 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/checking-if-varying-the-string-prototype-split-length-property-fails.js b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-varying-the-string-prototype-split-length-property-fails.js new file mode 100644 index 0000000000..0e44e7df62 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/checking-if-varying-the-string-prototype-split-length-property-fails.js @@ -0,0 +1,30 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The String.prototype.split.length property has the attribute ReadOnly +es5id: 15.5.4.14_A10 +description: > + Checking if varying the String.prototype.split.length property + fails +includes: [propertyHelper.js] +---*/ + +assert( + String.prototype.split.hasOwnProperty('length'), + 'String.prototype.split.hasOwnProperty(\'length\') must return true' +); + +var __obj = String.prototype.split.length; + +verifyNotWritable(String.prototype.split, "length", null, function() { + return "shifted"; +}); + +assert.sameValue( + String.prototype.split.length, + __obj, + 'The value of String.prototype.split.length is expected to equal the value of __obj' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/checking-string-prototype-split-length.js b/js/src/tests/test262/built-ins/String/prototype/split/checking-string-prototype-split-length.js new file mode 100644 index 0000000000..41a0089525 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/checking-string-prototype-split-length.js @@ -0,0 +1,17 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the split method is 2 +es5id: 15.5.4.14_A11 +description: Checking String.prototype.split.length +---*/ + +assert( + String.prototype.split.hasOwnProperty("length"), + 'String.prototype.split.hasOwnProperty("length") must return true' +); + +assert.sameValue(String.prototype.split.length, 2, 'The value of String.prototype.split.length is 2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/checking-string-prototype-split-prototype.js b/js/src/tests/test262/built-ins/String/prototype/split/checking-string-prototype-split-prototype.js new file mode 100644 index 0000000000..fcf1b1d93c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/checking-string-prototype-split-prototype.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.split has not prototype property +es5id: 15.5.4.14_A6 +description: Checking String.prototype.split.prototype +---*/ + +assert.sameValue( + String.prototype.split.prototype, + undefined, + 'The value of String.prototype.split.prototype is expected to equal `undefined`' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-get-err.js b/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-get-err.js new file mode 100644 index 0000000000..770a8094d9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-get-err.js @@ -0,0 +1,26 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Behavior when error is thrown accessing @@split property +es6id: 21.1.3.17 +info: | + [...] + 3. If separator is neither undefined nor null, then + a. Let splitter be GetMethod(separator, @@split). + b. ReturnIfAbrupt(splitter). +features: [Symbol.split] +---*/ + +var poisonedSplit = {}; +Object.defineProperty(poisonedSplit, Symbol.split, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.split(poisonedSplit); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-invocation.js b/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-invocation.js new file mode 100644 index 0000000000..87c0abb7b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-invocation.js @@ -0,0 +1,36 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Invocation of @@split property of user-supplied objects +es6id: 21.1.3.17 +info: | + [...] + 3. If separator is neither undefined nor null, then + a. Let splitter be GetMethod(separator, @@split). + b. ReturnIfAbrupt(splitter). + c. If splitter is not undefined, then + i. Return Call(splitter, separator, «O, limit»). +features: [Symbol.split] +---*/ + +var separator = {}; +var returnVal = {}; +var callCount = 0; +var thisVal, args; + +separator[Symbol.split] = function() { + callCount += 1; + thisVal = this; + args = arguments; + return returnVal; +}; + +assert.sameValue(''.split(separator, 'limit'), returnVal); +assert.sameValue(thisVal, separator); +assert.notSameValue(args, undefined); +assert.sameValue(args.length, 2); +assert.sameValue(args[0], ''); +assert.sameValue(args[1], 'limit'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-is-null.js b/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-is-null.js new file mode 100644 index 0000000000..07f3976264 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/cstm-split-is-null.js @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.split +description: > + If separator's Symbol.split property is null, no error is thrown. +info: | + String.prototype.split ( separator, limit ) + + [...] + 2. If separator is neither undefined nor null, then + a. Let splitter be ? GetMethod(separator, @@split). + b. If splitter is not undefined, then + [...] + [...] + 17. Return A. + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. +includes: [compareArray.js] +features: [Symbol.split] +---*/ + +var separator = {}; +separator[Symbol.split] = null; +separator.toString = function() { return "2"; }; +separator.valueOf = function() { throw new Test262Error("should not be called"); }; + +assert.compareArray("a2b2c".split(separator), ["a", "b", "c"]); +assert.compareArray("a2b2c".split(separator, 1), ["a"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-array-1-2-3-4-5.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-array-1-2-3-4-5.js new file mode 100644 index 0000000000..3228841a91 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-array-1-2-3-4-5.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T8 +description: Instance is Array(1,2,3,4,5) +---*/ + +var __instance = new Array(1, 2, 3, 4, 5); + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "1,2,3,4,5", 'The value of __split[0] is "1,2,3,4,5"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-boolean.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-boolean.js new file mode 100644 index 0000000000..27132ca436 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-boolean.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T9 +description: Instance is Boolean +---*/ + +var __instance = new Boolean; + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "false", 'The value of __split[0] is "false"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-function.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-function.js new file mode 100644 index 0000000000..c3b28fe210 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-function.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T3 +description: Instance is function(){} +---*/ + +var __instance = { + toString: function() { + return "function(){}"; + } +}; + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0].substring(0, 8), "function", '__split[0].substring(0, 8) must return "function"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-math.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-math.js new file mode 100644 index 0000000000..8c5416f0de --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-math.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T7 +description: Instance is Math +---*/ + +var __instance = Math; + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "[object Math]", 'The value of __split[0] is "[object Math]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-new-string.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-new-string.js new file mode 100644 index 0000000000..e614af44c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-new-string.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T10 +description: Instance is new String +---*/ + +var __string = new String; + +var __split = __string.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "", 'The value of __split[0] is ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-1234567890.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-1234567890.js new file mode 100644 index 0000000000..71743f45e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-1234567890.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T5 +description: Instance is Number(-1234567890) +---*/ + +var __instance = new Number(-1234567890); + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "-1234567890", 'The value of __split[0] is "-1234567890"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-1e21.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-1e21.js new file mode 100644 index 0000000000..7ee929e935 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-1e21.js @@ -0,0 +1,33 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T6 +description: Instance is Number(-1e21) +---*/ + +var __instance = new Number(-1e21); + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); + +assert.sameValue( + __split[0], + __instance.toString(), + 'The value of __split[0] must return the same value returned by __instance.toString()' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-na-n.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-na-n.js new file mode 100644 index 0000000000..e363c7247c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-number-na-n.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T4 +description: Instance is Number(NaN) +---*/ + +var __instance = new Number(NaN); + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "NaN", 'The value of __split[0] is "NaN"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-object.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-object.js new file mode 100644 index 0000000000..37702d2b8d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-object.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T2 +description: Instance is Object() +---*/ + +var __instance = new Object(); + +__instance.split = String.prototype.split; + +var __split = __instance.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "[object Object]", 'The value of __split[0] is "[object Object]"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-string-one-two-three-four-five.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-string-one-two-three-four-five.js new file mode 100644 index 0000000000..691c02e134 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-string-one-two-three-four-five.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T1 +description: Instance is String("one,two,three,four,five") +---*/ + +var __string = new String("one,two,three,four,five"); + +var __split = __string.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "one,two,three,four,five", 'The value of __split[0] is "one,two,three,four,five"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/instance-is-string.js b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-string.js new file mode 100644 index 0000000000..0f14e2df1c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/instance-is-string.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split() returns an Array object with: + i) length equaled to 1, + ii) [[Get]](0) equaled to the result of converting this object to a string +es5id: 15.5.4.14_A3_T11 +description: Instance is String(" ") +---*/ + +var __string = new String(" "); + +var __split = __string.split(); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], " ", 'The value of __split[0] is " "'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/limit-touint32-error.js b/js/src/tests/test262/built-ins/String/prototype/split/limit-touint32-error.js new file mode 100644 index 0000000000..69435c390f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/limit-touint32-error.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: Abrupt completion from ToUint32 on the limit +info: | + 1. If _limit_ is *undefined*, let _lim_ be 2<sup>32</sup> - 1; else let _lim_ be ? ToUint32(_limit_). + 1. Let _R_ be ? ToString(_separator_). + 1. If _lim_ = 0, return _A_. +features: [Symbol, Symbol.toPrimitive] +---*/ + +function ExpectedError(message) { + this.message = message || ""; +} +ExpectedError.prototype.toString = function () { + return "ExpectedError: " + this.message; +}; + +var nonStringableSeparator = {}; +nonStringableSeparator[Symbol.toPrimitive] = + function() { throw new Test262Error("separator[Symbol.toPrimitive]"); }; +nonStringableSeparator.toString = function() { throw new Test262Error("separator.toString"); }; +nonStringableSeparator.valueOf = function() { throw new Test262Error("separator.valueOf"); }; + +var nonNumberableLimit = {}; +nonNumberableLimit[Symbol.toPrimitive] = function() { throw new ExpectedError(); }; + +assert.throws(ExpectedError, function() { + "foo".split(nonStringableSeparator, nonNumberableLimit); +}, 'ToUint32 should be called on the limit before ToString on the separator.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/name.js b/js/src/tests/test262/built-ins/String/prototype/split/name.js new file mode 100644 index 0000000000..e5ab74fed8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 21.1.3.17 +description: > + String.prototype.split.name is "split". +info: | + String.prototype.split ( separator, limit ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(String.prototype.split.name, "split"); + +verifyNotEnumerable(String.prototype.split, "name"); +verifyNotWritable(String.prototype.split, "name"); +verifyConfigurable(String.prototype.split, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/split/not-a-constructor.js new file mode 100644 index 0000000000..09e41d6233 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + String.prototype.split does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(String.prototype.split), + false, + 'isConstructor(String.prototype.split) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.split(); +}, '`new String.prototype.split()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-colon-instance-is-string-one-1-two-2-four-4.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-colon-instance-is-string-one-1-two-2-four-4.js new file mode 100644 index 0000000000..062d1ee45c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-colon-instance-is-string-one-1-two-2-four-4.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T11 +description: Separator colon, instance is String(\"one-1,two-2,four-4\") +---*/ + +var __string = new String("one-1,two-2,four-4"); + +var __split = __string.split(":"); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "one-1,two-2,four-4", 'The value of __split[0] is "one-1,two-2,four-4"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-comma-instance-is-string-one-two-three-four-five.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-comma-instance-is-string-one-two-three-four-five.js new file mode 100644 index 0000000000..f8db39d4e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-comma-instance-is-string-one-two-three-four-five.js @@ -0,0 +1,31 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T1 +description: Separator comma, instance is String("one,two,three,four,five") +---*/ + +var __string = new String("one,two,three,four,five"); + +var __split = __string.split(","); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 5, 'The value of __split.length is 5'); +assert.sameValue(__split[0], "one", 'The value of __split[0] is "one"'); +assert.sameValue(__split[1], "two", 'The value of __split[1] is "two"'); +assert.sameValue(__split[2], "three", 'The value of __split[2] is "three"'); +assert.sameValue(__split[3], "four", 'The value of __split[3] is "four"'); +assert.sameValue(__split[4], "five", 'The value of __split[4] is "five"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-empty-string-instance-is-string.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-empty-string-instance-is-string.js new file mode 100644 index 0000000000..0eea79cbfc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-empty-string-instance-is-string.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T17 +description: Separator empty string, instance is String(" ") +---*/ + +var __string = new String(" "); + +var __split = __string.split(""); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], " ", 'The value of __split[0] is " "'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-number-limit-math-pow-2-32-1-instance-is-number.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-number-limit-math-pow-2-32-1-instance-is-number.js new file mode 100644 index 0000000000..0d35ed934f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-number-limit-math-pow-2-32-1-instance-is-number.js @@ -0,0 +1,49 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T35 +description: Separator number, limit Math.pow(2,32)-1, instance is Number +---*/ + +var __instance = new Number(100111122133144155); + +Number.prototype.split = String.prototype.split; + +var __split = __instance.split(1, Math.pow(2, 32) - 1); + +var __expected = ["", "00", "", "", "", "22", "33", "44", "60"]; + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue( + __split.length, + __expected.length, + 'The value of __split.length is expected to equal the value of __expected.length' +); + +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var index = 0; index < __expected.length; index++) { + assert.sameValue( + __split[index], + __expected[index], + 'The value of __split[index] is expected to equal the value of __expected[index]' + ); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-throws.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-throws.js new file mode 100644 index 0000000000..574af6775f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-throws.js @@ -0,0 +1,41 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T11 +description: > + Arguments are objects, and instance is string. First object have + overrided toString function. Second object have overrided valueOf + function, that throw exception +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + throw "intointeger"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.split(__obj, __obj2); + Test262Error.thrower('#1: "var x = __str.split(__obj, __obj2)" lead to throwing exception'); +} catch (e) { + assert.sameValue(e, "intointeger", 'The value of `e` is "intointeger"'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring-throws.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring-throws.js new file mode 100644 index 0000000000..d4c3557476 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring-throws.js @@ -0,0 +1,44 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T12 +description: > + Arguments are objects, and instance is string. First object have + overrided toString function. Second object have overrided valueOf + function and toString function, that throw exception +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return {}; + }, + toString: function() { + throw "intointeger"; + } +} +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.split(__obj, __obj2); + Test262Error.thrower('#1: "var x = __str.split(__obj, __obj2)" lead to throwing exception'); +} catch (e) { + assert.sameValue(e, "intointeger", 'The value of `e` is "intointeger"'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring.js new file mode 100644 index 0000000000..45c3b9f7a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof-tostring.js @@ -0,0 +1,46 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T13 +description: > + Arguments are objects, and instance is string. First object have + overrided toString function. Second object have overrided valueOf + and toString functions +---*/ + +var __obj = { + toString: function() { + return "\u0042\u0042"; + } +} +var __obj2 = { + valueOf: function() { + return {}; + }, + toString: function() { + return "2"; + } +} + +var __split = "ABB\u0041BABAB\u0042cc^^\u0042Bvv%%B\u0042xxx".split(__obj, __obj2); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 2, 'The value of __split.length is 2'); +assert.sameValue(__split[0], "A", 'The value of __split[0] is "A"'); +assert.sameValue(__split[1], "ABABA", 'The value of __split[1] is "ABABA"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof.js new file mode 100644 index 0000000000..b42b8beb4a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-limit-override-valueof.js @@ -0,0 +1,43 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T10 +description: > + Arguments are objects, and instance is string. First object have + overrided toString function. Second object have overrided valueOf + function +---*/ + +var __obj = { + toString: function() { + return "\u0042B"; + } +} +var __obj2 = { + valueOf: function() { + return true; + } +} +var __str = "ABB\u0041BABAB"; + +var __split = __str.split(__obj, __obj2); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "A", 'The value of __split[0] is "A"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-throws-limit-override-valueof-throws.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-throws-limit-override-valueof-throws.js new file mode 100644 index 0000000000..ccd53356db --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-tostring-throws-limit-override-valueof-throws.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T14 +description: > + Arguments are objects, and instance is string. First object have + overrided toString function, that throw exception. Second object + have overrided valueOf function, that throw exception +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +}; +var __obj2 = { + valueOf: function() { + throw "intoint"; + } +}; +var __instance = new Number(10001.10001); +Number.prototype.split = String.prototype.split; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.split(__obj, __obj2); + Test262Error.thrower('#1: "var x = __instance.split(__obj, __obj2)" lead to throwing exception'); +} catch (e) { + assert.sameValue(e, "intoint", 'The value of `e` is "intoint"'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-override-valueof.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-valueof.js new file mode 100644 index 0000000000..3e5852ac68 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-override-valueof.js @@ -0,0 +1,36 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T9 +description: > + Argument is function(){}(), and instance is String(object), object + have overrided toString and valueOf functions +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +//since ToString(undefined) evaluates to "undefined" +var __split = new String(__obj).split(function() {}()); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "undefined", 'The value of __split[0] is "undefined"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp-comma-instance-is-string-one-1-two-2-four-4.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp-comma-instance-is-string-one-1-two-2-four-4.js new file mode 100644 index 0000000000..05fc565ca7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp-comma-instance-is-string-one-1-two-2-four-4.js @@ -0,0 +1,29 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T5 +description: Separator /,/ (regexp comma), instance is String("one-1,two-2,four-4") +---*/ + +var __string = new String("one-1,two-2,four-4"); + +var __split = __string.split(/,/); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 3, 'The value of __split.length is 3'); +assert.sameValue(__split[0], "one-1", 'The value of __split[0] is "one-1"'); +assert.sameValue(__split[1], "two-2", 'The value of __split[1] is "two-2"'); +assert.sameValue(__split[2], "four-4", 'The value of __split[2] is "four-4"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp-limit-string-via-eval.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp-limit-string-via-eval.js new file mode 100644 index 0000000000..5bb6696c77 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp-limit-string-via-eval.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T18 +description: Separator regexp, limit string via eval +---*/ + +var __re = new RegExp("00"); + +Number.prototype.split = String.prototype.split; + +var __split = (6776767677.006771122677555).split(__re, eval("\"1\"")); + +assert.sameValue(typeof __split, "object", 'The value of `typeof __split` is "object"'); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 1, 'The value of __split.length is 1'); +assert.sameValue(__split[0], "6776767677.", 'The value of __split[0] is "6776767677."'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js new file mode 100644 index 0000000000..3d5a6f9cc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-regexp.js @@ -0,0 +1,59 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: Separator is a regexp +info: | + String.prototype.split ( separator, limit ) + + If separator is neither undefined nor null, then + Let splitter be ? GetMethod(separator, @@split). + If splitter is not undefined, then + Return ? Call(splitter, separator, « O, limit »). + + RegExp.prototype [ @@split ] ( string, limit ) + + Let C be ? SpeciesConstructor(rx, %RegExp%). + +includes: [compareArray.js] +---*/ + +assert.compareArray("x".split(/^/), ["x"], '"x".split(/^/) must return ["x"]'); +assert.compareArray("x".split(/$/), ["x"], '"x".split(/$/) must return ["x"]'); +assert.compareArray("x".split(/.?/), ["", ""], '"x".split(/.?/) must return ["", ""]'); +assert.compareArray("x".split(/.*/), ["", ""], '"x".split(/.*/) must return ["", ""]'); +assert.compareArray("x".split(/.+/), ["", ""], '"x".split(/.+/) must return ["", ""]'); +assert.compareArray("x".split(/.*?/), ["x"], '"x".split(/.*?/) must return ["x"]'); +assert.compareArray("x".split(/.{1}/), ["", ""], '"x".split(/.{1}/) must return ["", ""]'); +assert.compareArray("x".split(/.{1,}/), ["", ""], '"x".split(/.{1,}/) must return ["", ""]'); +assert.compareArray("x".split(/.{1,2}/), ["", ""], '"x".split(/.{1,2}/) must return ["", ""]'); +assert.compareArray("x".split(/()/), ["x"], '"x".split(/()/) must return ["x"]'); +assert.compareArray("x".split(/./), ["",""], '"x".split(/./) must return ["",""]'); +assert.compareArray("x".split(/(?:)/), ["x"], '"x".split(/(?:)/) must return ["x"]'); +assert.compareArray("x".split(/(...)/), ["x"], '"x".split(/(...)/) must return ["x"]'); +assert.compareArray("x".split(/(|)/), ["x"], '"x".split(/(|)/) must return ["x"]'); +assert.compareArray("x".split(/[]/), ["x"], '"x".split(/[]/) must return ["x"]'); +assert.compareArray("x".split(/[^]/), ["", ""], '"x".split(/[^]/) must return ["", ""]'); +assert.compareArray("x".split(/[.-.]/), ["x"], '"x".split(/[.-.]/) must return ["x"]'); +assert.compareArray("x".split(/\0/), ["x"], '"x".split(/\\0/) must return ["x"]'); +assert.compareArray("x".split(/\b/), ["x"], '"x".split(/\\b/) must return ["x"]'); +assert.compareArray("x".split(/\B/), ["x"], '"x".split(/\\B/) must return ["x"]'); +assert.compareArray("x".split(/\d/), ["x"], '"x".split(/\\d/) must return ["x"]'); +assert.compareArray("x".split(/\D/), ["", ""], '"x".split(/\\D/) must return ["", ""]'); +assert.compareArray("x".split(/\n/), ["x"], '"x".split(/\\n/) must return ["x"]'); +assert.compareArray("x".split(/\r/), ["x"], '"x".split(/\\r/) must return ["x"]'); +assert.compareArray("x".split(/\s/), ["x"], '"x".split(/\\s/) must return ["x"]'); +assert.compareArray("x".split(/\S/), ["", ""], '"x".split(/\\S/) must return ["", ""]'); +assert.compareArray("x".split(/\v/), ["x"], '"x".split(/\\v/) must return ["x"]'); +assert.compareArray("x".split(/\w/), ["", ""], '"x".split(/\\w/) must return ["", ""]'); +assert.compareArray("x".split(/\W/), ["x"], '"x".split(/\\W/) must return ["x"]'); +assert.compareArray("x".split(/\k<x>/), ["x"], '"x".split(/\\k<x>/) must return ["x"]'); +assert.compareArray("x".split(/\xA0/), ["x"], '"x".split(/\\xA0/) must return ["x"]'); +assert.compareArray("x".split(/\XA0/), ["x"], '"x".split(/\\XA0/) must return ["x"]'); +assert.compareArray("x".split(/\ddd/), ["x"], '"x".split(/\\ddd/) must return ["x"]'); +assert.compareArray("x".split(/\cY/), ["x"], '"x".split(/\\cY/) must return ["x"]'); +assert.compareArray("x".split(/[\b]/), ["x"], '"x".split(/[\\b]/) must return ["x"]'); +assert.compareArray("x".split(/\x/), ["", ""], '"x".split(/\\x/) must return ["", ""]'); +assert.compareArray("x".split(/\X/), ["x"], '"x".split(/\\X/) must return ["x"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-string-instance-is-empty-string-object.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-string-instance-is-empty-string-object.js new file mode 100644 index 0000000000..bd144fa25b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-string-instance-is-empty-string-object.js @@ -0,0 +1,27 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split (separator, limit) returns an Array object into which substrings of the result of converting this object to a string have + been stored. The substrings are determined by searching from left to right for occurrences of + separator; these occurrences are not part of any substring in the returned array, but serve to divide up + the string value. The value of separator may be a string of any length or it may be a RegExp object +es5id: 15.5.4.14_A2_T15 +description: Separator string, instance is empty String object +---*/ + +var __string = new String(); + +var __split = __string.split(""); + +assert.sameValue( + __split.constructor, + Array, + 'The value of __split.constructor is expected to equal the value of Array' +); + +assert.sameValue(__split.length, 0, 'The value of __split.length is 0'); +assert.sameValue(__split[0], undefined, 'The value of __split[0] is expected to equal `undefined`'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-tostring-error.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-tostring-error.js new file mode 100644 index 0000000000..2224f2b538 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-tostring-error.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: Abrupt completion from ToString on the separator +info: | + 1. Let _R_ be ? ToString(_separator_). + 1. If _lim_ = 0, return _A_. +---*/ + +function ExpectedError(message) { + this.message = message || ""; +} +ExpectedError.prototype.toString = function () { + return "ExpectedError: " + this.message; +}; + +var nonStringableSeparator = {}; +nonStringableSeparator.toString = function() { throw new ExpectedError(); }; + +assert.throws(ExpectedError, function() { + "foo".split(nonStringableSeparator, 0); +}, 'ToString should be called on the separator before checking if the limit is zero.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-undef-limit-custom.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-undef-limit-custom.js new file mode 100644 index 0000000000..f711c7f123 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-undef-limit-custom.js @@ -0,0 +1,69 @@ +// Copyright (C) 2020 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: Separator is undefined, limit is a positive number, return a new array with the string +info: | + ... + 3. Let S be ? ToString(O). + 4. Let A be ! ArrayCreate(0). + ... + 6. If limit is undefined, let lim be 232 - 1; else let lim be ? ToUint32(limit). + 7. Let R be ? ToString(separator). + 8. If lim = 0, return A. + 9. If separator is undefined, then + a. Perform ! CreateDataPropertyOrThrow(A, "0", S). + b. Return A. +---*/ + +var str = 'undefined is not a function'; + +var result = str.split(undefined, 1); + +assert.sameValue(Array.isArray(result), true, '1, result is array'); +assert.sameValue(result.length, 1, '1, result.length'); +assert.sameValue(result[0], str, '1, [0] is the same string'); + +result = str.split(undefined, 2); + +assert.sameValue(Array.isArray(result), true, '2, result is array'); +assert.sameValue(result.length, 1, '2, result.length'); +assert.sameValue(result[0], str, '2, [0] is the same string'); + +result = str.split(undefined, undefined); + +assert.sameValue(Array.isArray(result), true, 'undefined, result is array'); +assert.sameValue(result.length, 1, 'undefined, result.length'); +assert.sameValue(result[0], str, 'undefined, [0] is the same string'); + +result = str.split(undefined, true); + +assert.sameValue(Array.isArray(result), true, 'boolean, result is array'); +assert.sameValue(result.length, 1, 'boolean, result.length'); +assert.sameValue(result[0], str, 'boolean, [0] is the same string'); + +result = str.split(undefined, 2 ** 32 + 1); + +assert.sameValue(Array.isArray(result), true, 'ToUint32 2 ** 32 + 1, result is array'); +assert.sameValue(result.length, 1, 'ToUint32 2 ** 32 + 1, result.length'); +assert.sameValue(result[0], str, 'ToUint32 2 ** 32 + 1, [0] is the same string'); + +result = str.split(undefined, 2 ** 31); + +assert.sameValue(Array.isArray(result), true, 'ToUint32 2 ** 31, result is array'); +assert.sameValue(result.length, 1, 'ToUint32 2 ** 31, result.length'); +assert.sameValue(result[0], str, 'ToUint32 2 ** 31, [0] is the same string'); + +result = str.split(undefined, 2 ** 16); + +assert.sameValue(Array.isArray(result), true, 'ToUint32 2 ** 16, result is array'); +assert.sameValue(result.length, 1, 'ToUint32 2 ** 16, result.length'); +assert.sameValue(result[0], str, 'ToUint32 2 ** 16, [0] is the same string'); + +result = str.split(undefined, {valueOf() { return 1; }}); + +assert.sameValue(Array.isArray(result), true, 'boolean, result is array'); +assert.sameValue(result.length, 1, 'boolean, result.length'); +assert.sameValue(result[0], str, 'boolean, [0] is the same string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-undef-limit-zero.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-undef-limit-zero.js new file mode 100644 index 0000000000..972816493d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-undef-limit-zero.js @@ -0,0 +1,66 @@ +// Copyright (C) 2020 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: Separator is undefined, limit is zero, return a new empty array +info: | + ... + 3. Let S be ? ToString(O). + 4. Let A be ! ArrayCreate(0). + ... + 6. If limit is undefined, let lim be 2**32 - 1; else let lim be ? ToUint32(limit). + 7. Let R be ? ToString(separator). + 8. If lim = 0, return A. + + ToUint32 ( argument ) + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, +0, -0, +∞, or -∞, return +0. + 3. Let int be the Number value that is the same sign as number and whose magnitude is floor(abs(number)). + 4. Let int32bit be int modulo 2**32. + 5. Return int32bit. +---*/ + +var str = 'undefined is not a function'; + +var result = str.split(undefined, 0); + +assert.sameValue(Array.isArray(result), true, 'result is array'); +assert.sameValue(result.length, 0, 'result.length'); + +result = str.split(undefined, false); + +assert.sameValue(Array.isArray(result), true, 'boolean, result is array'); +assert.sameValue(result.length, 0, 'boolean, result.length'); + +result = str.split(undefined, null); + +assert.sameValue(Array.isArray(result), true, 'null, result is array'); +assert.sameValue(result.length, 0, 'null, result.length'); + +result = str.split(undefined, {valueOf() { return undefined; }}); + +assert.sameValue(Array.isArray(result), true, 'obj > undefined, result is array'); +assert.sameValue(result.length, 0, 'obj > undefined, result.length'); + +result = str.split(undefined, {valueOf() { return 0; }}); + +assert.sameValue(Array.isArray(result), true, 'obj > 0, result is array'); +assert.sameValue(result.length, 0, 'obj > 0, result.length'); + +result = str.split(undefined, NaN); + +assert.sameValue(Array.isArray(result), true, 'NaN, result is array'); +assert.sameValue(result.length, 0, 'NaN, result.length'); + +result = str.split(undefined, 2 ** 32); + +assert.sameValue(Array.isArray(result), true, '2 ** 32, result is array'); +assert.sameValue(result.length, 0, '2 ** 32, result.length'); + +result = str.split(undefined, 2 ** 33); + +assert.sameValue(Array.isArray(result), true, '2 ** 33, result is array'); +assert.sameValue(result.length, 0, '2 ** 33, result.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/separator-undef.js b/js/src/tests/test262/built-ins/String/prototype/split/separator-undef.js new file mode 100644 index 0000000000..c0a6454153 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/separator-undef.js @@ -0,0 +1,33 @@ +// Copyright (C) 2020 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: Separator is undefined, return a new array with the string +info: | + ... + 3. Let S be ? ToString(O). + 4. Let A be ! ArrayCreate(0). + ... + 6. If limit is undefined, let lim be 232 - 1; else let lim be ? ToUint32(limit). + 7. Let R be ? ToString(separator). + 8. If lim = 0, return A. + 9. If separator is undefined, then + a. Perform ! CreateDataPropertyOrThrow(A, "0", S). + b. Return A. +---*/ + +var str = 'undefined is not a function'; + +var result = str.split(); + +assert.sameValue(Array.isArray(result), true, 'implicit separator, result is array'); +assert.sameValue(result.length, 1, 'implicit separator, result.length'); +assert.sameValue(result[0], str, 'implicit separator, [0] is the same string'); + +result = str.split(undefined); + +assert.sameValue(Array.isArray(result), true, 'explicit separator, result is array'); +assert.sameValue(result.length, 1, 'explicit separator, result.length'); +assert.sameValue(result[0], str, 'explicit separator, [0] is the same string'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/shell.js b/js/src/tests/test262/built-ins/String/prototype/split/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/split/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/split/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..4870dfaf8e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/this-value-not-obj-coercible.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var split = String.prototype.split; + +assert.sameValue(typeof split, 'function'); + +assert.throws(TypeError, function() { + split.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + split.call(null, ''); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/this-value-tostring-error.js b/js/src/tests/test262/built-ins/String/prototype/split/this-value-tostring-error.js new file mode 100644 index 0000000000..a03b9ebaf7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/this-value-tostring-error.js @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Richard Gibson. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: Abrupt completion from ToString on the "this" value +info: | + 1. Let _O_ be ? RequireObjectCoercible(*this* value). + 1. If _separator_ is neither *undefined* nor *null*, then + 1. Let _splitter_ be ? GetMethod(_separator_, @@split). + 1. If _splitter_ is not *undefined*, then + 1. Return ? Call(_splitter_, _separator_, « _O_, _limit_ »). + 1. Let _S_ be ? ToString(_O_). +features: [Symbol, Symbol.split, Symbol.toPrimitive] +---*/ + +function ExpectedError(message) { + this.message = message || ""; +} +ExpectedError.prototype.toString = function () { + return "ExpectedError: " + this.message; +}; + +var split = String.prototype.split; + +var nonStringableReceiver = {}; +nonStringableReceiver.toString = function() { throw new ExpectedError("receiver.toString"); }; + +var splitter = {}; +splitter[Symbol.split] = function() {}; + +try { + split.call(nonStringableReceiver, splitter, Symbol()); +} catch (e) { + assert.sameValue(e, undefined, + 'ToString should not be called on the receiver when the separator has a @@split method.'); +} + +var nonStringableSeparator = {}; +nonStringableSeparator[Symbol.toPrimitive] = + function() { throw new Test262Error("separator[Symbol.toPrimitive]"); }; +nonStringableSeparator.toString = function() { throw new Test262Error("separator.toString"); }; +nonStringableSeparator.valueOf = function() { throw new Test262Error("separator.valueOf"); }; + +assert.throws(ExpectedError, function() { + split.call(nonStringableReceiver, nonStringableSeparator, Symbol()); +}, 'ToString should be called on the receiver before processing the separator or limit.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/transferred-to-custom.js b/js/src/tests/test262/built-ins/String/prototype/split/transferred-to-custom.js new file mode 100644 index 0000000000..fc9ec30167 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/transferred-to-custom.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.split +description: > + split method can be "transferred" to another object + whose this value can be coerced to a string. +info: | + String.prototype.split(separator, limit): + + Let O be ? RequireObjectCoercible(this value). + ... + Let S be ? ToString(O). + +includes: [compareArray.js] +---*/ + + +function Splittable(value) { + this.toString = function() { + return value + ""; + }; + this.valueOf = function() { + throw new Test262Error(); + }; +} + +Splittable.prototype.split = String.prototype.split; + +let splittable = new Splittable(void 0); + +assert.compareArray(splittable.split(""), ["u","n","d","e","f","i","n","e","d"]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/transferred-to-number-separator-override-tostring-returns-regexp.js b/js/src/tests/test262/built-ins/String/prototype/split/transferred-to-number-separator-override-tostring-returns-regexp.js new file mode 100644 index 0000000000..ae90427c91 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/transferred-to-number-separator-override-tostring-returns-regexp.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.split(separator, limit): + i) can be transferred to other kinds of objects for use as a method. + separator and limit can be any kinds of object since: + ii) if separator is not RegExp ToString(separator) performs and + iii) ToInteger(limit) performs +es5id: 15.5.4.14_A1_T16 +description: > + Argument is object, and instance is Number. Object have overrided + toString function, that return regexp +---*/ + +var __obj = { + toString: function() { + return /\u0037\u0037/g; + } +}; + +Number.prototype.split = String.prototype.split; + +try { + var __split = (6776767677.006771122677555).split(__obj); + Test262Error.thrower('#1: "__split = 6776767677.006771122677555.split(__obj)" lead to throwing exception'); +} catch (e) { + assert(e instanceof TypeError, 'The result of `(e instanceof TypeError)` is true'); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js b/js/src/tests/test262/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js new file mode 100644 index 0000000000..9e9b71d43e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/split/valueOf-is-called-for-limit-argument.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.split +description: > + Calls valueOf() of limit argument +info: | + String.prototype.split(separator, limit): + + If limit is undefined, let lim be 232 - 1; else let lim be ℝ(? ToUint32(limit)). +features: [arrow-function] +---*/ + + +let limit = { + toString() {}, + valueOf() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, () => { + "".split("", limit); +}); + +reportCompare(0, 0); |