diff options
Diffstat (limited to '')
1275 files changed, 37525 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-1-1.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-1-1.js new file mode 100644 index 0000000000..d8c01ae28e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-1-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-1-1 +description: > + String object supports bracket notation to lookup of data + properties +---*/ + +var s = new String("hello world"); +s.foo = 1; + + +assert.sameValue(s["foo"], 1, 's["foo"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-1-2.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-1-2.js new file mode 100644 index 0000000000..4f44b7fa2d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-1-2.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-1-2 +description: String value supports bracket notation to lookup data properties +---*/ + +var s = String("hello world"); + + +assert.sameValue(s["foo"], undefined, 's["foo"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-1.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-1.js new file mode 100644 index 0000000000..74223daeb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-1.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-1 +description: > + String object indexing returns undefined for missing data + properties +---*/ + +var s = new String("hello world"); + + +assert.sameValue(s["foo"], undefined, 's["foo"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-2.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-2.js new file mode 100644 index 0000000000..5dfbf5b5b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-2.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-2 +description: String value indexing returns undefined for missing data properties +---*/ + +var s = String("hello world"); + + +assert.sameValue(s["foo"], undefined, 's["foo"]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-3.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-3.js new file mode 100644 index 0000000000..f3da064154 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-3 +description: > + String object indexing returns undefined if the numeric index + (NaN) is not an array index +---*/ + +var s = new String("hello world"); + +assert.sameValue(s[NaN], undefined, 's[NaN]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-4.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-4.js new file mode 100644 index 0000000000..32f78fe289 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-4.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-4 +description: > + String object indexing returns undefined if the numeric index + (Infinity) is not an array index +---*/ + +var s = new String("hello world"); + +assert.sameValue(s[Infinity], undefined, 's[Infinity]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-5.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-5.js new file mode 100644 index 0000000000..ff60686831 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-5 +description: > + String object indexing returns undefined if the numeric index ( + 2^32-1) is not an array index +---*/ + +var s = new String("hello world"); + +assert.sameValue(s[Math.pow(2, 32) - 1], undefined, 's[Math.pow(2, 32)-1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-6.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-6.js new file mode 100644 index 0000000000..59c12ba166 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-6.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-6 +description: > + String value indexing returns undefined if the numeric index (NaN) + is not an array index +---*/ + +var s = String("hello world"); + +assert.sameValue(s[NaN], undefined, 's[NaN]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-7.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-7.js new file mode 100644 index 0000000000..89139ea8ca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-7.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-7 +description: > + String value indexing returns undefined if the numeric index + (Infinity) is not an array index +---*/ + +var s = String("hello world"); + +assert.sameValue(s[Infinity], undefined, 's[Infinity]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-8.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-8.js new file mode 100644 index 0000000000..51a7865fbb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-3-8.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-3-8 +description: > + String value indexing returns undefined if the numeric index ( >= + 2^32-1) is not an array index +---*/ + +var s = String("hello world"); + +assert.sameValue(s[Math.pow(2, 32) - 1], undefined, 's[Math.pow(2, 32)-1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-1.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-1.js new file mode 100644 index 0000000000..501483dc8b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-1.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-7-1 +description: > + String object indexing returns undefined if the numeric index is + less than 0 +---*/ + +var s = new String("hello world"); + +assert.sameValue(s[-1], undefined, 's[-1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-2.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-2.js new file mode 100644 index 0000000000..d2c623f881 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-2.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-7-2 +description: > + String value indexing returns undefined if the numeric index is + less than 0 +---*/ + +var s = String("hello world"); + +assert.sameValue(s[-1], undefined, 's[-1]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-3.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-3.js new file mode 100644 index 0000000000..b4ce4705c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-7-3 +description: > + String object indexing returns undefined if the numeric index is + greater than the string length +---*/ + +var s = new String("hello world"); + +assert.sameValue(s[11], undefined, 's[11]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-4.js b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-4.js new file mode 100644 index 0000000000..c8c36ec577 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/15.5.5.5.2-7-4.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + 15.5.5.2 defines [[GetOwnProperty]] for Strings. It supports using indexing + notation to look up non numeric property names. +es5id: 15.5.5.5.2-7-4 +description: > + String value indexing returns undefined if the numeric index is + greater than the string length +---*/ + +var s = String("hello world"); + +assert.sameValue(s[11], undefined, 's[11]'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T1.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T1.js new file mode 100644 index 0000000000..15139f0b63 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T1.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T1 +description: Call String(function(){}()) +---*/ + +var __str = String(function() {}()); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(function(){}()); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "undefined") { + throw new Test262Error('#2: __str = String(function(){}()); __str === "undefined". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T10.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T10.js new file mode 100644 index 0000000000..d1ff46c813 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T10.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T10 +description: Call String(1) and String(-1) +---*/ + +var __str = String(1); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(1); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "1") { + throw new Test262Error('#2: __str = String(1); __str === "1". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(-1); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String(-1); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "-1") { + throw new Test262Error('#4: __str = String(-1); __str === "-1". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T11.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T11.js new file mode 100644 index 0000000000..aacea800a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T11.js @@ -0,0 +1,120 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T11 +description: Call String(1/0) and String(-1/0), and call with +/-Infinity +---*/ + +var __str = String(1 / 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(1/0); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "Infinity") { + throw new Test262Error('#2: __str = String(1/0); __str === "Infinity". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(-1 / 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String(-1/0); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str !== "-Infinity") { + throw new Test262Error('#4: __str = String(-1/0); __str === "-Infinity". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(Infinity); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __str !== "string") { + throw new Test262Error('#5: __str = String(Infinity); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__str !== "Infinity") { + throw new Test262Error('#6: __str = String(Infinity); __str === "Infinity". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(-Infinity); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if (typeof __str !== "string") { + throw new Test262Error('#7: __str = String(-Infinity); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if (__str !== "-Infinity") { + throw new Test262Error('#8: __str = String(-Infinity); __str === "-Infinity". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(Number.POSITIVE_INFINITY); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#9 +if (typeof __str !== "string") { + throw new Test262Error('#9: __str = String(Number.POSITIVE_INFINITY); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#10 +if (__str !== "Infinity") { + throw new Test262Error('#10: __str = String(Number.POSITIVE_INFINITY); __str === "Infinity". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(Number.NEGATIVE_INFINITY); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#11 +if (typeof __str !== "string") { + throw new Test262Error('#11: __str = String(Number.NEGATIVE_INFINITY); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#12 +if (__str !== "-Infinity") { + throw new Test262Error('#12: __str = String(Number.NEGATIVE_INFINITY); __str === "-Infinity". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T12.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T12.js new file mode 100644 index 0000000000..e58860413e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T12.js @@ -0,0 +1,66 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T12 +description: Call String(1/"a"), String("b"* null) and String(Number.NaN) +---*/ + +var __str = String(1 / "a"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(1/"a"); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "NaN") { + throw new Test262Error('#2: __str = String(1/"a"); __str === "NaN". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String("b" * null); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String("b"*null); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str !== "NaN") { + throw new Test262Error('#4: __str = String("b"*null); __str === "NaN". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(Number.NaN); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __str !== "string") { + throw new Test262Error('#5: __str = String(Number.NaN); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__str !== "NaN") { + throw new Test262Error('#6: __str = String(Number.NaN); __str === "NaN". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T13.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T13.js new file mode 100644 index 0000000000..fbfb7f8d3c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T13.js @@ -0,0 +1,84 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T13 +description: Call String(true) and String(false) +---*/ + +var __str = String(true); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(true); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "true") { + throw new Test262Error('#2: __str = String(true); __str === "true". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(false); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String(false); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str !== "false") { + throw new Test262Error('#4: __str = String(false); __str === "false". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(Boolean(true)); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __str !== "string") { + throw new Test262Error('#5: __str = String(Boolean(true)); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__str !== "true") { + throw new Test262Error('#6: __str = String(Boolean(true)); __str === "true". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(Boolean(false)); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if (typeof __str !== "string") { + throw new Test262Error('#7: __str = String(Boolean(false)); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if (__str !== "false") { + throw new Test262Error('#8: __str = String(Boolean(false)); __str === "false". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T14.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T14.js new file mode 100644 index 0000000000..af6ac5cad1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T14.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T14 +description: Call String(0) and String(-0) +---*/ + +var __str = String(0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(0); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "0") { + throw new Test262Error('#2: __str = String(0); __str === "0". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(-0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String(-0); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "0") { + throw new Test262Error('#4: __str = String(-0); __str === "0". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T15.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T15.js new file mode 100644 index 0000000000..1f7760e8cb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T15.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T15 +description: Call String(string_object) +---*/ + +var __obj__str = "caps"; + +//__obj__str.prop=1; + +var __str = String(__obj__str); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str !== __obj__str) { + throw new Test262Error('#1: __obj__str = "caps"; __str = String(__obj__str); __str === __obj__str. Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T16.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T16.js new file mode 100644 index 0000000000..248ab10c2f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T16.js @@ -0,0 +1,84 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T16 +description: Call String() with .12345 and analogous numbers +---*/ + +var __str = String(.12345); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(.12345); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "0.12345") { + throw new Test262Error('#2: __str = String(.12345); __str === "0.12345". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(.012345); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String(.012345); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str !== "0.012345") { + throw new Test262Error('#4: __str = String(.012345); __str === "0.012345". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(.0012345); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __str !== "string") { + throw new Test262Error('#5: __str = String(.0012345); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__str !== "0.0012345") { + throw new Test262Error('#6: __str = String(.0012345); __str === "0.0012345". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(.00000012345); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if (typeof __str !== "string") { + throw new Test262Error('#7: __str = String(.00000012345); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if (__str !== "1.2345e-7") { + throw new Test262Error('#8: __str = String(.00000012345); __str === "1.2345e-7". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T17.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T17.js new file mode 100644 index 0000000000..58bd145158 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T17.js @@ -0,0 +1,68 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T17 +description: > + Call String() with numbers that have more than 1 significant digit + after point +---*/ + +var __str = String(1.2345); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(1.2345); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "1.2345") { + throw new Test262Error('#2: __str = String(1.2345); __str === "1.2345". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(1.234567890); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String(1.234567890); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str !== "1.23456789") { + throw new Test262Error('#4: __str = String(1.234567890); __str === "1.23456789". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(1.234500000000000000000000000); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __str !== "string") { + throw new Test262Error('#5: __str = String(1.234500000000000000000000000); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__str !== "1.2345") { + throw new Test262Error('#6: __str = String(1.234500000000000000000000000); __str === "1.2345". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T18.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T18.js new file mode 100644 index 0000000000..e9d08ad1a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T18.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T18 +description: Call String() with numbers that have more than 1 significant digit +---*/ + +var __str = String(1000000000000000000000); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(1000000000000000000000); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "1e+21") { + throw new Test262Error('#2: __str = String(1000000000000000000000); __str === "1e+21". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = String(10000000000000000000000); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "string") { + throw new Test262Error('#3: __str = String(10000000000000000000000); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str !== "1e+22") { + throw new Test262Error('#4: __str = String(10000000000000000000000); __str === "1e+22". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T19.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T19.js new file mode 100644 index 0000000000..0030f18cac --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T19.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T19 +description: Call String() with Array of numbers +---*/ + +var __str = String(new Array(1, 2, 3)); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(new Array(1,2,3)); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "1,2,3") { + throw new Test262Error('#2: __str = String(new Array(1,2,3)); __str === "1,2,3". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T2.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T2.js new file mode 100644 index 0000000000..3f193721f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T2.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T2 +description: Call String(null) +---*/ + +var __str = String(null); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(null); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "null") { + throw new Test262Error('#2: __str = String(null); __str === "null". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T3.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T3.js new file mode 100644 index 0000000000..6b4275690c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T3.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T3 +description: Call String(void 0) +---*/ + +var __str = String(void 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(void 0); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "undefined") { + throw new Test262Error('#2: __str = String(void 0); __str === "undefined". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T4.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T4.js new file mode 100644 index 0000000000..9d83b2ed7f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T4.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T4 +description: Call String(undefined) +---*/ + +var __str = String(undefined); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(undefined); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "undefined") { + throw new Test262Error('#2: __str = String(undefined); __str === "undefined". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T5.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T5.js new file mode 100644 index 0000000000..0960c7c50d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T5.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T5 +description: Call String(x), where x is undefined variable +---*/ + +var __str = String(x); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: var x; __str = String(x); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "undefined") { + throw new Test262Error('#2: var x; __str = String(x); __str === "undefined". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T6.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T6.js new file mode 100644 index 0000000000..16e558f5b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T6.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T6 +description: Checking by using eval, Call String(eval()); +---*/ + +var __str = String(eval()); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(eval()); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "undefined") { + throw new Test262Error('#2: __str = String(eval()); __str === "undefined". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T7.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T7.js new file mode 100644 index 0000000000..a42acd3796 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T7.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T7 +description: Call String({}) +---*/ + +var __str = String({}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String({}); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "[object " + "Object" + "]") { + throw new Test262Error('#2: __str = String({}); __str === "[object Object]". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T8.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T8.js new file mode 100644 index 0000000000..3db63dc221 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T8.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T8 +description: Call String(new Array) +---*/ + +var __old__Array__prototype__toString = Array.prototype.toString; + +Array.prototype.toString = function() { + return "__ARRAY__"; +}; + +var __str = String(new Array); + +// restore old toString method just in case +Array.prototype.toString = __old__Array__prototype__toString; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(new Array); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "__ARRAY__") { + throw new Test262Error('#2: Array.prototype.toString=function(){return "__ARRAY__";}; __str = String(new Array); __str === "__ARRAY__". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T9.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T9.js new file mode 100644 index 0000000000..beac37fd00 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A1_T9.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: | + When String is called as a function rather than as a constructor, it + performs a type conversion +es5id: 15.5.1.1_A1_T9 +description: Call String(this) +---*/ + +var toString = function() { + return "__THIS__"; +}; + +var __str = String(this); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(this); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "__THIS__") { + throw new Test262Error('#2: toString=function(){return "__THIS__";}; __str = String(this); __str === "__THIS__". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.1.1_A2_T1.js b/js/src/tests/test262/built-ins/String/S15.5.1.1_A2_T1.js new file mode 100644 index 0000000000..d114b54054 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.1.1_A2_T1.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: If value is not supplied, the empty string "" is returned +es5id: 15.5.1.1_A2_T1 +description: Call String() +---*/ + +var __str = String(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "string") { + throw new Test262Error('#1: __str = String(); typeof __str === "string". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str !== "") { + throw new Test262Error('#2: __str = String(); __str === "". Actual: __str ===' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T1.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T1.js new file mode 100644 index 0000000000..d5b18f83be --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T1.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: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T1 +description: Creating string object with expression "new String" +---*/ + +var __str = new String; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String; typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String; __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "") { + throw new Test262Error('#2: __str = new String; __str == "". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__str === "") { + throw new Test262Error('#3: __str = new String; __str !== ""'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T10.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T10.js new file mode 100644 index 0000000000..50a8fea683 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T10.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: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T10 +description: > + Creating string object with "new String(function object)" as the + function object's prototype.toString property was changed +---*/ + +function __FACTORY() {}; + +__FACTORY.prototype.toString = function() { + return "tostr" +}; + +var __obj = new __FACTORY; + +var __str = new String(__obj); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(__obj); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(__obj); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "tostr") { + throw new Test262Error('#2: __str = new String(__obj); __str =="tostr". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T11.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T11.js new file mode 100644 index 0000000000..a34cd6eb0b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T11.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T11 +description: > + Creating string object with "new String(function object)" after + changing function object's valueOf and toString properties +---*/ + +function __obj() {}; + +__obj.valueOf = function() { + return true; +}; + +__obj.toString = function() { + return {}; +}; + +var __str = new String(__obj); + + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: function __obj(){}; __str = new String(__obj); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(__obj); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "true") { + throw new Test262Error('#2: function __obj(){}; __str = new String(__obj); __str =="true". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T12.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T12.js new file mode 100644 index 0000000000..3be225db35 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T12.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T12 +description: > + Creating string object with "new String(function object)", after + changing the function object toString property, which causes + exception throw +---*/ + +var __obj = { + toString: function() { + throw "intostr" + } +}; + +__obj.valueOf = function() { + return true +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var __str = new String(__obj); + throw new Test262Error('#1: var __obj = {toString:function(){throw "intostr"}}; __str = new String(__obj) lead throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: e==="intostr". Actual: e===' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T13.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T13.js new file mode 100644 index 0000000000..1a82a86d2b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T13.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T13 +description: > + Creating string object with "new String(function object)" after + changing function object's valueOf property, which causes + exception throw +---*/ + +var __obj = { + toString: function() { + return f; + + function f() {} + } +}; + +__obj.valueOf = function() { + throw "invalueof" +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var __str = new String(__obj); + throw new Test262Error('#1: __obj.valueOf=function(){throw "invalueof"}; __str = new String(__obj) lead throwing exception'); +} catch (e) { + if (e !== "invalueof") { + throw new Test262Error('#1.1: e==="invalueof". Actual: e===' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T16.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T16.js new file mode 100644 index 0000000000..87090b591f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T16.js @@ -0,0 +1,114 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T16 +description: > + Creating string object with "new String()" initialized with .12345 + and other numbers +---*/ + +var __str = new String(.12345); +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str =new String(.12345); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str =new String(.12345); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "0.12345") { + throw new Test262Error('#2: __str =new String(.12345); __str =="0.12345". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = new String(.012345); +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "object") { + throw new Test262Error('#3: __str =new String(.012345); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2.5 +if (__str.constructor !== String) { + throw new Test262Error('#3.5: __str =new String(.012345); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str != "0.012345") { + throw new Test262Error('#4: __str =new String(.012345); __str =="0.012345". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = new String(.0012345); +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __str !== "object") { + throw new Test262Error('#5: __str =new String(.0012345); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5.5 +if (__str.constructor !== String) { + throw new Test262Error('#5.5: __str =new String(.0012345); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__str != "0.0012345") { + throw new Test262Error('#6: __str =new String(.0012345); __str =="0.0012345". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = new String(.00000012345); +////////////////////////////////////////////////////////////////////////////// +//CHECK#7 +if (typeof __str !== "object") { + throw new Test262Error('#7: __str =new String(.00000012345); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#7.5 +if (__str.constructor !== String) { + throw new Test262Error('#7.5: __str =new String(.00000012345); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#8 +if (__str != "1.2345e-7") { + throw new Test262Error('#8: __str =new String(.00000012345); __str =="1.2345e-7". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T17.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T17.js new file mode 100644 index 0000000000..f0b4d6c322 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T17.js @@ -0,0 +1,89 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T17 +description: > + Creating string object with "new String()" initialized with + numbers that have more than 1 significant digit following the point +---*/ + +var __str = new String(1.2345); +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(1.2345); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(1.2345); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "1.2345") { + throw new Test262Error('#2: __str = new String(1.2345); __str =="1.2345". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = new String(1.234567890); +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "object") { + throw new Test262Error('#3: __str = new String(1.234567890); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3.5 +if (__str.constructor !== String) { + throw new Test262Error('#3.5: __str = new String(1.234567890); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str != "1.23456789") { + throw new Test262Error('#4: __str = new String(1.234567890); __str =="1.23456789". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = new String(1.234500000000000000000000000); +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (typeof __str !== "object") { + throw new Test262Error('#5: __str = new String(1.234500000000000000000000000); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5.5 +if (__str.constructor !== String) { + throw new Test262Error('#5.5: __str = new String(1.234500000000000000000000000); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__str != "1.2345") { + throw new Test262Error('#6: __str = new String(1.234500000000000000000000000); __str =="1.2345". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T18.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T18.js new file mode 100644 index 0000000000..53f732abc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T18.js @@ -0,0 +1,64 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T18 +description: > + Create string object with "new String()" initialized with numbers + that have more than 1 significant digit +---*/ + +var __str = new String(1000000000000000000000); +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(1000000000000000000000); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(1000000000000000000000); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "1e+21") { + throw new Test262Error('#2: __str = new String(1000000000000000000000); __str =="1e+21". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str = new String(10000000000000000000000); +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (typeof __str !== "object") { + throw new Test262Error('#3: __str = new String(10000000000000000000000); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3.5 +if (__str.constructor !== String) { + throw new Test262Error('#3.5: __str = new String(10000000000000000000000); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str != "1e+22") { + throw new Test262Error('#4: __str = new String(10000000000000000000000); __str =="1e+22". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T19.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T19.js new file mode 100644 index 0000000000..2cc892e7c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T19.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T19 +description: > + Creating string object with "new String()" initialized with Array + of numbers +---*/ + +var __str = new String(new Array(1, 2, 3)); +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(new Array(1,2,3)); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(new Array(1,2,3)); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "1,2,3") { + throw new Test262Error('#2: __str = new String(new Array(1,2,3)); __str =="1,2,3". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T2.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T2.js new file mode 100644 index 0000000000..490e562e52 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T2.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: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T2 +description: Creating string object with "new String()" +---*/ + +var __str = new String(); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "") { + throw new Test262Error('#2: __str = new String(); __str =="". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__str === "") { + throw new Test262Error('#3: __str = new String(); __str !== ""'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T3.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T3.js new file mode 100644 index 0000000000..0a0321df79 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T3.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: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T3 +description: Creating string object with "new String("")" +---*/ + +var __str = new String(""); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(""); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(""); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "") { + throw new Test262Error('#2: __str = new String(""); __str =="". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__str === "") { + throw new Test262Error('#3: __str = new String(""); __str !== ""'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T4.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T4.js new file mode 100644 index 0000000000..0aa2e44bca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T4.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T4 +description: Create string object with "new String(1.0)" +---*/ + +var __str = new String(1.0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(1.0); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(1.0); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != 1.0 + "") { + throw new Test262Error('#2: __str = new String(1.0); __str ==1.0+"". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T5.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T5.js new file mode 100644 index 0000000000..335b994e44 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T5.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T5 +description: Creating string object with "new String(NaN)" +---*/ + +var __str = new String(NaN); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(NaN); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(NaN); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != (1 / "s") + "") { + throw new Test262Error('#2: __str = new String(NaN); __str ==(1/"s")+"". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T6.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T6.js new file mode 100644 index 0000000000..bb59c4ce6f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T6.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T6 +description: Creating string object with "new String(false)" +---*/ + +var __str = new String(false); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(false); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(false); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != false + "") { + throw new Test262Error('#2: __str = new String(false); __str ==false+"". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T7.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T7.js new file mode 100644 index 0000000000..94fa61f576 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T7.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: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T7 +description: Creating string object with "new String({})" +---*/ + +var __stored__Object__prototype__toString = Object.prototype.toString; + +Object.prototype.toString = function() { + return "SHIFTED" +}; + +var __str = new String({}); + +Object.prototype.toString = __stored__Object__prototype__toString; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String({}); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String({}); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "SHIFTED") { + throw new Test262Error('#2: Object.prototype.toString=function(){return "SHIFTED"}; __str = new String({}); __str =="SHIFTED". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T8.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T8.js new file mode 100644 index 0000000000..894aa92f31 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T8.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: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T8 +description: Creating string object with "new String(function(){})" +---*/ + +var __stored__Function__prototype__toString = Function.prototype.toString; + +Function.prototype.toString = function() { + return "SHIFTED" +}; + +var __str = new String(function() {}); + +Function.prototype.toString = __stored__Function__prototype__toString; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(function(){}); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(function(){}); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "SHIFTED") { + throw new Test262Error('#2: Function.prototype.toString=function(){return "SHIFTED"}; __str = new String(function(){}); __str =="SHIFTED". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T9.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T9.js new file mode 100644 index 0000000000..391e1d8f4a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A1_T9.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: | + When "String" is called as part of a new expression, it is a constructor: it initialises the newly created object and + The [[Value]] property of the newly constructed object is set to ToString(value), or to the empty string if value is not supplied +es5id: 15.5.2.1_A1_T9 +description: > + Creating string object with "new String(function(){return + [1,2,3]}())" +---*/ + +var __str = new String(function() { + return [1, 2, 3] +}()); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __str !== "object") { + throw new Test262Error('#1: __str = new String(function(){return [1,2,3]}()); typeof __str === "object". Actual: typeof __str ===' + typeof __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1.5 +if (__str.constructor !== String) { + throw new Test262Error('#1.5: __str = new String(function(){return [1,2,3]}()); __str.constructor === String. Actual: __str.constructor ===' + __str.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str != "1,2,3") { + throw new Test262Error('#2: __str = new String(function(){return [1,2,3]}()); __str =="1,2,3". Actual: __str ==' + __str); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A2_T1.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A2_T1.js new file mode 100644 index 0000000000..1c37c7b36b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A2_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The [[Prototype]] property of the newly constructed object is set to the + original String prototype object +es5id: 15.5.2.1_A2_T1 +description: Creating string object with "new String(string)" to check prototype +---*/ + +var __str__obj = new String("abba"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.isPrototypeOf(__str__obj))) { + throw new Test262Error('#1: var __str__obj = new String("abba"); String.prototype.isPrototypeOf(__str__obj)===true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A2_T2.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A2_T2.js new file mode 100644 index 0000000000..8fe9def0f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A2_T2.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: | + The [[Prototype]] property of the newly constructed object is set to the + original String prototype object +es5id: 15.5.2.1_A2_T2 +description: > + Creating string object with "new String(string)" adding custom + property +---*/ + +var __str__obj = new String("shocking blue"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str__obj["__custom__prop"] !== undefined) { + throw new Test262Error('#1: var __str__obj = new String("shocking blue"); __str__obj["__custom__prop"]===undefined. Actual: __str__obj["__custom__prop"]===' + __str__obj["__custom__prop"]); +} +// +////////////////////////////////////////////////////////////////////////////// + +String.prototype.__custom__prop = "bor"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str__obj["__custom__prop"] !== "bor") { + throw new Test262Error('#2: var __str__obj = new String("shocking blue"); String.prototype.__custom__prop = "bor"; __str__obj["__custom__prop"]==="bor". Actual: __str__obj["__custom__prop"]===' + __str__obj["__custom__prop"]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.2.1_A3.js b/js/src/tests/test262/built-ins/String/S15.5.2.1_A3.js new file mode 100644 index 0000000000..d2aa2ffef6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.2.1_A3.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The [[Class]] property of the newly constructed object is set to "String" +es5id: 15.5.2.1_A3 +description: > + Creating string object with "new String(string)" and changing + toString property to Object.prototype.toString +---*/ + +var __str__obj = new String("seamaid"); + +__str__obj.toString = Object.prototype.toString; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str__obj.toString() !== "[object " + "String" + "]") { + throw new Test262Error('#1: var __str__obj = new String("seamaid"); __str__obj.toString = Object.prototype.toString; __str__obj.toString() === "[object String]". Actual: __str__obj.toString() ===' + __str__obj.toString()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.3_A1.js b/js/src/tests/test262/built-ins/String/S15.5.3_A1.js new file mode 100644 index 0000000000..b91a5f79b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.3_A1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String has length property whose value is 1 +es5id: 15.5.3_A1 +description: Checking String.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK# +if (String.length !== 1) { + throw new Test262Error('String has length property whose value is 1. Actual: String.length===' + String.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.3_A2_T1.js b/js/src/tests/test262/built-ins/String/S15.5.3_A2_T1.js new file mode 100644 index 0000000000..f7bcb0b118 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.3_A2_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the String + constructor is the Function prototype object +es5id: 15.5.3_A2_T1 +description: Checking Function.prototype.isPrototypeOf(String) +---*/ + +////////////////////////////////////////////////////////////////////////////// +// CHECK# +if (!(Function.prototype.isPrototypeOf(String))) { + throw new Test262Error('#1: Function.prototype.isPrototypeOf(String) return true. Actual: ' + Function.prototype.isPrototypeOf(String)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.3_A2_T2.js b/js/src/tests/test262/built-ins/String/S15.5.3_A2_T2.js new file mode 100644 index 0000000000..1a2ba9dbc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.3_A2_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The value of the internal [[Prototype]] property of the String + constructor is the Function prototype object +es5id: 15.5.3_A2_T2 +description: Add custom property to Function.prototype and check it at String +---*/ + +Function.prototype.indicator = 1; + +////////////////////////////////////////////////////////////////////////////// +// CHECK# +if (String.indicator !== 1) { + throw new Test262Error('#1: Function.prototype.indicator = 1; String.indicator === 1. Actual: String.indicator ===' + String.indicator); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5.1_A1.js b/js/src/tests/test262/built-ins/String/S15.5.5.1_A1.js new file mode 100644 index 0000000000..ad50eca189 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5.1_A1.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: | + length property contains the number of characters in the String value + represented by this String object +es5id: 15.5.5.1_A1 +description: Create strings and check its length +---*/ + +var __str__instance = new String("ABC\u0041\u0042\u0043"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str__instance.length !== 6) { + throw new Test262Error('#1: var __str__instance = new String("ABC\\u0041\\u0042\\u0043"); __str__instance.length === 6, where __str__instance is new String("ABC\\u0041\\u0042\\u0043"). Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str__instance = new String; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str__instance.length !== 0) { + throw new Test262Error('#2: __str__instance = new String; __str__instance.length === 0, where __str__instance is new String. Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5.1_A2.js b/js/src/tests/test262/built-ins/String/S15.5.5.1_A2.js new file mode 100644 index 0000000000..fb8ba37b20 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5.1_A2.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: length property has the attributes {DontEnum} +es5id: 15.5.5.1_A2 +description: Checking if enumerating the length property of String fails +---*/ + +var __str__instance = new String("globglob"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__str__instance.hasOwnProperty("length"))) { + throw new Test262Error('#1: var __str__instance = new String("globglob"); __str__instance.hasOwnProperty("length") return true. Actual: ' + __str__instance.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var prop in __str__instance) { + if (prop === "length") { + throw new Test262Error('#2: length property has the attributes {DontEnum}'); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5.1_A3.js b/js/src/tests/test262/built-ins/String/S15.5.5.1_A3.js new file mode 100644 index 0000000000..5dc35d4667 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5.1_A3.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: length property has the attributes {DontDelete} +es5id: 15.5.5.1_A3 +description: Checking if deleting the length property of String fails +includes: [propertyHelper.js] +---*/ + +var __str__instance = new String("globglob"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__str__instance.hasOwnProperty("length"))) { + throw new Test262Error('#1: var __str__instance = new String("globglob"); __str__instance.hasOwnProperty("length") return true. Actual: ' + __str__instance.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +verifyNotConfigurable(__str__instance, "length"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if (delete __str__instance.length === true) { + throw new Test262Error('#2: var __str__instance = new String("globglob"); delete __str__instance.length !== true'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (!(__str__instance.hasOwnProperty("length"))) { + throw new Test262Error('#3: var __str__instance = new String("globglob"); delete __str__instance.length; __str__instance.hasOwnProperty("length") return true. Actual: ' + __str__instance.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5.1_A4_T1.js b/js/src/tests/test262/built-ins/String/S15.5.5.1_A4_T1.js new file mode 100644 index 0000000000..604d924095 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5.1_A4_T1.js @@ -0,0 +1,60 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: length property has the attributes {ReadOnly} +es5id: 15.5.5.1_A4_T1 +description: Checking if varying the length property of String fails +flags: [noStrict] +---*/ + +var __str__instance = new String("globglob"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__str__instance.hasOwnProperty("length"))) { + throw new Test262Error('#1: var __str__instance = new String("globglob"); __str__instance.hasOwnProperty("length") return true. Actual: ' + __str__instance.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str__instance.length !== 8) { + throw new Test262Error('#2: var __str__instance = new String("globglob"); __str__instance.length === 8. Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str__instance.length = -1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__str__instance.length !== 8) { + throw new Test262Error('#3: var __str__instance = new String("globglob"); __str__instance.length=-1; __str__instance.length === 8(after redefine length property). Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +with(__str__instance) +length = 0; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__str__instance.length !== 8) { + throw new Test262Error('#4: var __str__instance = new String("globglob"); with(__str__instance) length = 0; __str__instance.length === 8(after redefine length property with using "with"). Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str__instance.length++; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (__str__instance.length !== 8) { + throw new Test262Error('#5: var __str__instance = new String("globglob"); __str__instance.length++; __str__instance.length === 8(after redefine length property with using "++"). Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5.1_A4_T2.js b/js/src/tests/test262/built-ins/String/S15.5.5.1_A4_T2.js new file mode 100644 index 0000000000..f8587cb41b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5.1_A4_T2.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: length property has the attributes {ReadOnly} +es5id: 15.5.5.1_A4_T2 +description: Checking if varying the length property of String fails +includes: [propertyHelper.js] +---*/ + +var __str__instance = new String("globglob"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(__str__instance.hasOwnProperty("length"))) { + throw new Test262Error('#1: var __str__instance = new String("globglob"); __str__instance.hasOwnProperty("length") return true. Actual: ' + __str__instance.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str__instance.length !== 8) { + throw new Test262Error('#2: var __str__instance = new String("globglob"); __str__instance.length === 8. Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +verifyNotWritable(__str__instance, "length", null, -1); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__str__instance.length !== 8) { + throw new Test262Error('#3: var __str__instance = new String("globglob"); __str__instance.length=-1; __str__instance.length === 8(after redefine length property). Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5.1_A5.js b/js/src/tests/test262/built-ins/String/S15.5.5.1_A5.js new file mode 100644 index 0000000000..b87c8c4c6c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5.1_A5.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: Once a String object is created, the length property is unchanging +es5id: 15.5.5.1_A5 +description: > + Change valueOf and toString of String object and check length + property +---*/ + +var __str__instance = new String("ABC\u0041\u0042\u0043"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str__instance.length !== 6) { + throw new Test262Error('#1: var __str__instance = new String("ABC\\u0041\\u0042\\u0043"); __str__instance.length === 6. Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +__str__instance.valueOf = function() { + return "ed" +}; +__str__instance.toString = function() { + return "ed" +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__str__instance != "ed") { + throw new Test262Error('#2: var __str__instance = new String("ABC\\u0041\\u0042\\u0043"); __str__instance.valueOf = function(){return "ed"}; __str__instance.toString = function(){return "ed"}; __str__instance =="ed". Actual: __str__instance ==' + __str__instance); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__str__instance.length !== 6) { + throw new Test262Error('#3: var __str__instance = new String("ABC\\u0041\\u0042\\u0043"); __str__instance.valueOf = function(){return "ed"}; __str__instance.toString = function(){return "ed"}; __str__instance.length === 6. Actual: __str__instance.length ===' + __str__instance.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5_A1_T1.js b/js/src/tests/test262/built-ins/String/S15.5.5_A1_T1.js new file mode 100644 index 0000000000..03e0a70c8e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5_A1_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String instance has not [[call]] property +es5id: 15.5.5_A1_T1 +description: Create new String and try call it +---*/ + +var __str = new String; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + __str(); + throw new Test262Error('#1: __str = new String; __str() lead to throwing exception'); +} catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error('#1.1: Exception is instance of TypeError. Actual: exception is ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5_A1_T2.js b/js/src/tests/test262/built-ins/String/S15.5.5_A1_T2.js new file mode 100644 index 0000000000..0c73f70a08 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5_A1_T2.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String instance has not [[call]] property +es5id: 15.5.5_A1_T2 +description: Checking if creating new "String("a|b")()" fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + String("a|b")(); + throw new Test262Error('#1: String("a|b")() lead to throwing exception'); +} catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error('#1.1: Exception is instance of TypeError. Actual: exception is ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5_A2_T1.js b/js/src/tests/test262/built-ins/String/S15.5.5_A2_T1.js new file mode 100644 index 0000000000..c6750731c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5_A2_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String instance has not [[construct]] property +es5id: 15.5.5_A2_T1 +description: Create new string object and try new created_string +---*/ + +var __str = new Object(""); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + new __str; + throw new Test262Error('#1: __str = new Object(""); "new __str" lead to throwing exception'); +} catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error('#1.1: Exception is instance of TypeError. Actual: exception is ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S15.5.5_A2_T2.js b/js/src/tests/test262/built-ins/String/S15.5.5_A2_T2.js new file mode 100644 index 0000000000..82fd6b1002 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S15.5.5_A2_T2.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String instance has not [[construct]] property +es5id: 15.5.5_A2_T2 +description: Checking if creating "new String" fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + new new String; + throw new Test262Error('#1: "new new String" lead to throwing exception'); +} catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error('#1.1: Exception is instance of TypeError. Actual: exception is ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S8.12.8_A1.js b/js/src/tests/test262/built-ins/String/S8.12.8_A1.js new file mode 100644 index 0000000000..9a8c86881d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S8.12.8_A1.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: | + This should generate a TypeError, + Cause we overload toString method so it return non Primitive value + See ECMA reference at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 +es5id: 8.12.8_A1 +description: Try to overload toString method +---*/ + +try +{ + var __obj = { + toString: function() { + return new Object(); + } + } + String(__obj); + throw new Test262Error('#1.1: var __obj = {toString: function() {return new Object();}}; String(__obj) throw TypeError. Actual: ' + (String(__obj))); +} +catch (e) +{ + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: var __obj = {toString: function() {return new Object();}}; String(__obj) throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S8.12.8_A2.js b/js/src/tests/test262/built-ins/String/S8.12.8_A2.js new file mode 100644 index 0000000000..fdabbe29a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S8.12.8_A2.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: | + This should generate no TypeError, + Cause we overload toString method so it return non Primitive value + but we overloaded valueOf method too. + See ECMA reference at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 +es5id: 8.12.8_A2 +description: > + Try to overload toString, that returned new Object, and valueOf + methods +---*/ + +try +{ + var __obj = { + toString: function() { + return new Object(); + }, + valueOf: function() { + return 1; + } + } + if (String(__obj) !== "1") { + throw new Test262Error('#1.1: var __obj = {toString: function() {return new Object();}, valueOf: function() {return 1;}}; String(__obj) === "1". Actual: ' + (String(__obj))); + } +} +catch (e) +{ + throw new Test262Error('#1.2: var __obj = {toString: function() {return new Object();}, valueOf: function() {return 1;}}; String(__obj) === "1". Actual: ' + (e)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.1_A1_T2.js b/js/src/tests/test262/built-ins/String/S9.1_A1_T2.js new file mode 100644 index 0000000000..a2f4cde9e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.1_A1_T2.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of primitive conversion from object is a default value for the + Object +es5id: 9.1_A1_T2 +description: > + Using operator Number. This operator calls ToPrimitive with hint + Number +---*/ + +// CHECK#1 +var object = { + valueOf: function() { + return 0 + }, + toString: function() { + return 1 + } +}; +if (String(object) !== "1") { + throw new Test262Error('#1: var object = {valueOf: function() {return 0}, toString: function() {return 1}}; String(object) === "1". Actual: ' + (String(object))); +} + +// CHECK#2 +var object = { + valueOf: function() { + return 0 + }, + toString: function() { + return {} + } +}; +if (String(object) !== "0") { + throw new Test262Error('#2: var object = {valueOf: function() {return 0}, toString: function() {return {}}}; String(object) === "0". Actual: ' + (String(object))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A1.js b/js/src/tests/test262/built-ins/String/S9.8.1_A1.js new file mode 100644 index 0000000000..1d8fea77c0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If m is NaN, return the string "NaN" +es5id: 9.8.1_A1 +description: NaN convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(NaN) !== "NaN") { + throw new Test262Error('#1: String(NaN) === Not-a-Number Actual: ' + (String(NaN))); +} + +// CHECK#2 +if (String(Number.NaN) !== "NaN") { + throw new Test262Error('#2: String(Number.NaN) === Not-a-Number Actual: ' + (String(Number.NaN))); +} + +// CHECK#3 +if (String(Number("asasa")) !== "NaN") { + throw new Test262Error('#3: String(Number("asasa")) === Not-a-Number Actual: ' + (String(Number("asasa")))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A10.js b/js/src/tests/test262/built-ins/String/S9.8.1_A10.js new file mode 100644 index 0000000000..819878d046 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A10.js @@ -0,0 +1,61 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Return the string consisting of the most significant + digit of the decimal representation of s, followed by a decimal point '.', + followed by the remaining k-1 digits of the decimal representation of s, + followed by the lowercase character 'e', followed by a plus sign '+' or + minus sign '-' according to whether n-1 is positive or negative, followed + by the decimal representation of the integer abs(n-1) (with no leading zeros) +es5id: 9.8.1_A10 +description: Various float numbers convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(1.2345) !== "1.2345") { + throw new Test262Error('#1: String(1.2345) === "1.2345". Actual: ' + (String(1.2345))); +} + +// CHECK#2 +if (String(1.234567890) !== "1.23456789") { + throw new Test262Error('#2: String(1.234567890) === "1.23456789". Actual: ' + (String(1.234567890))); +} + +// CHECK#3 +if (String(0.12345) !== "0.12345") { + throw new Test262Error('#3: String(0.12345) === "0.12345". Actual: ' + (String(0.12345))); +} + +// CHECK#4 +if (String(.012345) !== "0.012345") { + throw new Test262Error('#4: String(.012345) === "0.012345". Actual: ' + (String(.012345))); +} + +// CHECK#5 +if (String(.0012345) !== "0.0012345") { + throw new Test262Error('#5: String(.0012345) === "0.0012345". Actual: ' + (String(.0012345))); +} + +// CHECK#6 +if (String(.00012345) !== "0.00012345") { + throw new Test262Error('#6: String(.00012345) === "0.00012345". Actual: ' + (String(.00012345))); +} + +// CHECK#7 +if (String(.000012345) !== "0.000012345") { + throw new Test262Error('#7: String(.000012345) === "0.000012345". Actual: ' + (String(.000012345))); +} + +// CHECK#8 +if (String(.0000012345) !== "0.0000012345") { + throw new Test262Error('#8: String(.0000012345) === "0.0000012345". Actual: ' + (String(.0000012345))); +} + +// CHECK#9 +if (String(.00000012345) !== "1.2345e-7") { + throw new Test262Error('#9: String(.00000012345) === "1.2345e-7". Actual: ' + (String(.00000012345))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A2.js b/js/src/tests/test262/built-ins/String/S9.8.1_A2.js new file mode 100644 index 0000000000..cd9bbef606 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If m is +0 or -0, return the string "0" +es5id: 9.8.1_A2 +description: +0 and -0 convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(+0) !== "0") { + throw new Test262Error('#1: String(+0) === "0". Actual: ' + (String(+0))); +} + +// CHECK#2 +if (String(-0) !== "0") { + throw new Test262Error('#2: String(-0) === "0". Actual: ' + (String(-0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A3.js b/js/src/tests/test262/built-ins/String/S9.8.1_A3.js new file mode 100644 index 0000000000..49e4fd3efb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If m is less than zero, return the string concatenation of the + string "-" and ToString(-m) +es5id: 9.8.1_A3 +description: -1234567890 convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(-1234567890) !== "-1234567890") { + throw new Test262Error('#1: String(-1234567890) === "-1234567890". Actual: ' + (String(-1234567890))); +} + +// CHECK#2 +if ("-" + String(-(-1234567890)) !== "-1234567890") { + throw new Test262Error('#2: "-"+String(-(-1234567890)) === "-1234567890". Actual: ' + ("-" + String(-(-1234567890)))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A4.js b/js/src/tests/test262/built-ins/String/S9.8.1_A4.js new file mode 100644 index 0000000000..4aeeed1112 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A4.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: If m is infinity, return the string "Infinity" +es5id: 9.8.1_A4 +description: +/-Infinity convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(Infinity) !== "Infinity") { + throw new Test262Error('#1: String(Infinity) === "Infinity". Actual: ' + (String(Infinity))); +} + +// CHECK#2 +if (String(Number.POSITIVE_INFINITY) !== "Infinity") { + throw new Test262Error('#2: String(Number.POSITIVE_INFINITY) === "Infinity". Actual: ' + (String(Number.POSITIVE_INFINITY))); +} + +// CHECK#3 +if (String(-Infinity) !== "-Infinity") { + throw new Test262Error('#3: String(-Infinity) === "-Infinity". Actual: ' + (String(-Infinity))); +} + +// CHECK#4 +if (String(Number.NEGATIVE_INFINITY) !== "-Infinity") { + throw new Test262Error('#4: String(Number.NEGATIVE_INFINITY) === "-Infinity". Actual: ' + (String(Number.NEGATIVE_INFINITY))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A6.js b/js/src/tests/test262/built-ins/String/S9.8.1_A6.js new file mode 100644 index 0000000000..ad8e4057d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A6.js @@ -0,0 +1,95 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If 1 <= s < 1e21 or -1e21 s < -1, return the string + consisting of the k digits of the decimal representation of s (in order, + with no leading zeroes), followed by n-k occurrences of the character '0' +es5id: 9.8.1_A6 +description: > + Various integer numbers convert to String by explicit + transformation +---*/ + +// CHECK#1 +if (String(1) !== "1") { + throw new Test262Error('#1: String(1) === "1". Actual: ' + (String(1))); +} + +// CHECK#2 +if (String(10) !== "10") { + throw new Test262Error('#2: String(10) === "10". Actual: ' + (String(10))); +} + +// CHECK#3 +if (String(100) !== "100") { + throw new Test262Error('#3: String(100) === "100". Actual: ' + (String(100))); +} + +// CHECK#4 +if (String(100000000000000000000) !== "100000000000000000000") { + throw new Test262Error('#4: String(100000000000000000000) === "100000000000000000000". Actual: ' + (String(100000000000000000000))); +} + +// CHECK#5 +if (String(1e20) !== "100000000000000000000") { + throw new Test262Error('#5: String(1e20) === "100000000000000000000". Actual: ' + (String(1e20))); +} + +// CHECK#6 +if (String(12345) !== "12345") { + throw new Test262Error('#6: String(12345) === "12345". Actual: ' + (String(12345))); +} + +// CHECK#7 +if (String(12345000) !== "12345000") { + throw new Test262Error('#7: String(12345000) === "12345000". Actual: ' + (String(12345000))); +} + +// CHECK#8 +if (String(-1) !== "-1") { + throw new Test262Error('#8: String(-1) === "-1". Actual: ' + (String(-1))); +} + +// CHECK#9 +if (String(-10) !== "-10") { + throw new Test262Error('#9: String(-10) === "-10". Actual: ' + (String(-10))); +} + +// CHECK#10 +if (String(-100) !== "-100") { + throw new Test262Error('#3: String(-100) === "-100". Actual: ' + (String(-100))); +} + +// CHECK#10 +if (String(-100000000000000000000) !== "-100000000000000000000") { + throw new Test262Error('#10: String(-100000000000000000000) === "-100000000000000000000". Actual: ' + (String(-100000000000000000000))); +} + +// CHECK#11 +if (String(-1e20) !== "-100000000000000000000") { + throw new Test262Error('#11: String(-1e20) === "-100000000000000000000". Actual: ' + (String(-1e20))); +} + +// CHECK#12 +if (String(-12345) !== "-12345") { + throw new Test262Error('#12: String(-12345) === "-12345". Actual: ' + (String(-12345))); +} + +// CHECK#13 +if (String(-12345000) !== "-12345000") { + throw new Test262Error('#13: String(-12345000) === "-12345000". Actual: ' + (String(-12345000))); +} + +// CHECK#14 +if (String(1E20) !== "100000000000000000000") { + throw new Test262Error('#14: String(1E20) === "100000000000000000000". Actual: ' + (String(1E20))); +} + +// CHECK#15 +if (String(-1E20) !== "-100000000000000000000") { + throw new Test262Error('#15: String(-1E20) === "-100000000000000000000". Actual: ' + (String(-1E20))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A7.js b/js/src/tests/test262/built-ins/String/S9.8.1_A7.js new file mode 100644 index 0000000000..7479bc59e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A7.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: | + If 1 <= s < 1e21 or -1e21 s < -1 and s has a fractional + component, return the string consisting of the most significant n digits of + the decimal representation of s, followed by a decimal point '.', + followed by the remaining k-n digits of the decimal representation of s +es5id: 9.8.1_A7 +description: > + 1.0000001 and -1.0000001 convert to String by explicit + transformation +---*/ + +// CHECK#1 +if (String(1.0000001) !== "1.0000001") { + throw new Test262Error('#1: String(1.0000001) === "1.0000001". Actual: ' + (String(1.0000001))); +} + +// CHECK#2 +if (String(-1.0000001) !== "-1.0000001") { + throw new Test262Error('#2: String(-1.0000001) === "-1.0000001". Actual: ' + (String(-1.0000001))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A8.js b/js/src/tests/test262/built-ins/String/S9.8.1_A8.js new file mode 100644 index 0000000000..218025ec1d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A8.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If 1 > s > -1, and -6 < n <= 0, return the string consisting of the + character '0', followed by a decimal point '.', followed by -n occurrences + of the character '0', followed by the k digits of the decimal + representation of s +es5id: 9.8.1_A8 +description: Various float numbers convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(0.1) !== "0.1") { + throw new Test262Error('#1: String(0.1) === "0.1". Actual: ' + (String(0.1))); +} + +// CHECK#2 +if (String(0.000001) !== "0.000001") { + throw new Test262Error('#2: String(0.000001) === "0.000001". Actual: ' + (String(0.000001))); +} + +// CHECK#3 +if (String(1e-6) !== "0.000001") { + throw new Test262Error('#3: String(1e-6) === "0.000001". Actual: ' + (String(1e-6))); +} + +// CHECK#4 +if (String(1E-6) !== "0.000001") { + throw new Test262Error('#4: String(1E-6) === "0.000001". Actual: ' + (String(1E-6))); +} + +// CHECK#5 +if (String(-0.1) !== "-0.1") { + throw new Test262Error('#5: String(-0.1) === "-0.1". Actual: ' + (String(-0.1))); +} + +// CHECK#6 +if (String(-0.000001) !== "-0.000001") { + throw new Test262Error('#6: String(-0.000001) === "-0.000001". Actual: ' + (String(-0.000001))); +} + +// CHECK#7 +if (String(-1e-6) !== "-0.000001") { + throw new Test262Error('#7: String(-1e-6) === "0.000001". Actual: ' + (String(-1e-6))); +} + +// CHECK#8 +if (String(-1E-6) !== "-0.000001") { + throw new Test262Error('#8: String(-1E-6) === "0.000001". Actual: ' + (String(-1E-6))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A9_T1.js b/js/src/tests/test262/built-ins/String/S9.8.1_A9_T1.js new file mode 100644 index 0000000000..51c35eb03b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A9_T1.js @@ -0,0 +1,74 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Return the string consisting of the single digit of s, + followed by lowercase character 'e', followed by a plus sign '+' or minus + sign '-' according to whether n-1 is positive or negative, followed by the + decimal representation of the integer abs(n-1) (with no leading zeros) +es5id: 9.8.1_A9_T1 +description: Various big numbers convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(1000000000000000000000) !== "1e+21") { + throw new Test262Error('#1: String(1000000000000000000000) === "1e+21". Actual: ' + (String(1000000000000000000000))); +} + +// CHECK#2 +if (String(10000000000000000000000) !== "1e+22") { + throw new Test262Error('#2: String(10000000000000000000000) === "1e+22". Actual: ' + (String(10000000000000000000000))); +} + +// CHECK#3 +if (String(1e21) !== "1e+21") { + throw new Test262Error('#3: String(1e21) === "1e+21". Actual: ' + (String(1e21))); +} + +// CHECK#4 +if (String(1.0e22) !== "1e+22") { + throw new Test262Error('#4: String(1.0e22) === "1e+22". Actual: ' + (String(1.0e22))); +} + +// CHECK#5 +if (String(1E21) !== "1e+21") { + throw new Test262Error('#5: String(1E21) === "1e+21". Actual: ' + (String(1E21))); +} + +// CHECK#6 +if (String(1.0E22) !== "1e+22") { + throw new Test262Error('#6: String(1.0E22) === "1e+22". Actual: ' + (String(1.0E22))); +} + +// CHECK#7 +if (String(-1000000000000000000000) !== "-1e+21") { + throw new Test262Error('#7: String(-1000000000000000000000) === "-1e+21". Actual: ' + (String(-1000000000000000000000))); +} + +// CHECK#8 +if (String(-10000000000000000000000) !== "-1e+22") { + throw new Test262Error('#8: String(-10000000000000000000000) === "-1e+22". Actual: ' + (String(-10000000000000000000000))); +} + +// CHECK#9 +if (String(-1e21) !== "-1e+21") { + throw new Test262Error('#9: String(-1e21) === "-1e+21". Actual: ' + (String(-1e21))); +} + +// CHECK#10 +if (String(-1.0e22) !== "-1e+22") { + throw new Test262Error('#10: String(-1.0e22) === "-1e+22". Actual: ' + (String(-1.0e22))); +} + +// CHECK#11 +if (String(-1E21) !== "-1e+21") { + throw new Test262Error('#11: String(-1E21) === "-1e+21". Actual: ' + (String(-1E21))); +} + +// CHECK#12 +if (String(-1.0E22) !== "-1e+22") { + throw new Test262Error('#12: String(-1.0E22) === "-1e+22". Actual: ' + (String(-1.0E22))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8.1_A9_T2.js b/js/src/tests/test262/built-ins/String/S9.8.1_A9_T2.js new file mode 100644 index 0000000000..736e4c461b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8.1_A9_T2.js @@ -0,0 +1,76 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Return the string consisting of the single digit of s, + followed by lowercase character 'e', followed by a plus sign '+' or minus + sign '-' according to whether n-1 is positive or negative, followed by the + decimal representation of the integer abs(n-1) (with no leading zeros) +es5id: 9.8.1_A9_T2 +description: > + Various float numbers with many zeros convert to String by + explicit transformation +---*/ + +// CHECK#1 +if (String(0.0000001) !== "1e-7") { + throw new Test262Error('#1: String(0.0000001) === "1e-7". Actual: ' + (String(0.0000001))); +} + +// CHECK#2 +if (String(0.000000000100000000000) !== "1e-10") { + throw new Test262Error('#2: String(0.000000000100000000000) === "1e-10". Actual: ' + (String(0.000000000100000000000))); +} + +// CHECK#3 +if (String(1e-7) !== "1e-7") { + throw new Test262Error('#3: String(1e-7) === "1e-7". Actual: ' + (String(1e-7))); +} + +// CHECK#4 +if (String(1.0e-10) !== "1e-10") { + throw new Test262Error('#4: String(1.0e-10) === "1e-10". Actual: ' + (String(1.0e-10))); +} + +// CHECK#5 +if (String(1E-7) !== "1e-7") { + throw new Test262Error('#5: String(1E-7) === "1e-7". Actual: ' + (String(1E-7))); +} + +// CHECK#6 +if (String(1.0E-10) !== "1e-10") { + throw new Test262Error('#6: String(1.0E-10) === "1e-10". Actual: ' + (String(1.0E-10))); +} + +// CHECK#7 +if (String(-0.0000001) !== "-1e-7") { + throw new Test262Error('#7: String(-0.0000001) === "1e-7". Actual: ' + (String(-0.0000001))); +} + +// CHECK#8 +if (String(-0.000000000100000000000) !== "-1e-10") { + throw new Test262Error('#8: String(-0.000000000100000000000) === "1e-10". Actual: ' + (String(-0.000000000100000000000))); +} + +// CHECK#9 +if (String(-1e-7) !== "-1e-7") { + throw new Test262Error('#9: String(-1e-7) === "-1e-7". Actual: ' + (String(-1e-7))); +} + +// CHECK#10 +if (String(-1.0e-10) !== "-1e-10") { + throw new Test262Error('#10: String(-1.0e-10) === "-1e-10". Actual: ' + (String(-1.0e-10))); +} + +// CHECK#11 +if (String(-1E-7) !== "-1e-7") { + throw new Test262Error('#11: String(-1E-7) === "-1e-7". Actual: ' + (String(-1E-7))); +} + +// CHECK#12 +if (String(-1.0E-10) !== "-1e-10") { + throw new Test262Error('#12: String(-1.0E-10) === "-1e-10". Actual: ' + (String(-1.0E-10))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8_A1_T1.js b/js/src/tests/test262/built-ins/String/S9.8_A1_T1.js new file mode 100644 index 0000000000..d32cd82322 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8_A1_T1.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: Result of ToString conversion from undefined value is "undefined" +es5id: 9.8_A1_T1 +description: > + Undefined values is undefined, void 0 and eval("var x"). Use + explicit transformation +---*/ + +// CHECK#1 +if (String(undefined) !== "undefined") { + throw new Test262Error('#1: String(undefined) === "undefined". Actual: ' + (String(undefined))); +} + +// CHECK#2 +if (String(void 0) !== "undefined") { + throw new Test262Error('#2: String(void 0) === "undefined". Actual: ' + (String(void 0))); +} + +// CHECK#3 +if (String(eval("var x")) !== "undefined") { + throw new Test262Error('#3: String(eval("var x")) === "undefined" . Actual: ' + (String(eval("var x")))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8_A2_T1.js b/js/src/tests/test262/built-ins/String/S9.8_A2_T1.js new file mode 100644 index 0000000000..39a2610bb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8_A2_T1.js @@ -0,0 +1,15 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Result of ToString conversion from null value is "null" +es5id: 9.8_A2_T1 +description: null convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(null) !== "null") { + throw new Test262Error('#1: String(null) === "null". Actual: ' + (String(null))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8_A3_T1.js b/js/src/tests/test262/built-ins/String/S9.8_A3_T1.js new file mode 100644 index 0000000000..9645ae0233 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8_A3_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of ToString conversion from boolean value is "true" if + the argument is "true", else is "false" +es5id: 9.8_A3_T1 +description: True and false convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(false) !== "false") { + throw new Test262Error('#1: String(false) === "false". Actual: ' + (String(false))); +} + +// CHECK#2 +if (String(true) !== "true") { + throw new Test262Error('#2: String(true) === "true". Actual: ' + (String(true))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8_A4_T1.js b/js/src/tests/test262/built-ins/String/S9.8_A4_T1.js new file mode 100644 index 0000000000..eebe88e277 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8_A4_T1.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of String conversion from string value is the input argument (no + conversion) +es5id: 9.8_A4_T1 +description: Some strings convert to String with explicit transformation +---*/ + +// CHECK#1 +var x1 = "abc"; +if (String(x1) !== x1) { + throw new Test262Error('#1: String("abc") === "abc". Actual: ' + (String("abc"))); +} + +// CHECK#2 +var x2 = "abc"; +if (typeof String(x2) !== typeof x2) { + throw new Test262Error('#2: typeof String("abc") === "string". Actual: ' + (typeof String("abc"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/S9.8_A5_T1.js b/js/src/tests/test262/built-ins/String/S9.8_A5_T1.js new file mode 100644 index 0000000000..1c439e220d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/S9.8_A5_T1.js @@ -0,0 +1,110 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Result of String conversion from Object value is conversion + from primitive value +es5id: 9.8_A5_T1 +description: Some objects convert to String by explicit transformation +---*/ + +// CHECK#1 +if (String(new Number()) !== "0") { + throw new Test262Error('#1: String(new Number()) === "0". Actual: ' + (String(new Number()))); +} + +// CHECK#2 +if (String(new Number(0)) !== "0") { + throw new Test262Error('#2: String(new Number(0)) === "0". Actual: ' + (String(new Number(0)))); +} + +// CHECK#3 +if (String(new Number(Number.NaN)) !== "NaN") { + throw new Test262Error('#3: String(new Number(Number.NaN)) === Not-a-Number. Actual: ' + (String(new Number(Number.NaN)))); +} + +// CHECK#4 +if (String(new Number(null)) !== "0") { + throw new Test262Error('#4: String(new Number(null)) === "0". Actual: ' + (String(new Number(null)))); +} + +// CHECK#5 +if (String(new Number(void 0)) !== "NaN") { + throw new Test262Error('#5: String(new Number(void 0)) === Not-a-Number. Actual: ' + (String(new Number(void 0)))); +} + +// CHECK#6 +if (String(new Number(true)) !== "1") { + throw new Test262Error('#6: String(new Number(true)) === "1". Actual: ' + (String(new Number(true)))); +} + +// CHECK#7 +if (String(new Number(false)) !== "0") { + throw new Test262Error('#7: String(new Number(false)) === "0". Actual: ' + (String(new Number(false)))); +} + +// CHECK#8 +if (String(new Boolean(true)) !== "true") { + throw new Test262Error('#8: String(new Boolean(true)) === "true". Actual: ' + (String(new Boolean(true)))); +} + +// CHECK#9 +if (String(new Boolean(false)) !== "false") { + throw new Test262Error('#9: Number(new Boolean(false)) === "false". Actual: ' + (Number(new Boolean(false)))); +} + +// CHECK#10 +if (String(new Array(2, 4, 8, 16, 32)) !== "2,4,8,16,32") { + throw new Test262Error('#10: String(new Array(2,4,8,16,32)) === "2,4,8,16,32". Actual: ' + (String(new Array(2, 4, 8, 16, 32)))); +} + +// CHECK#11 +var myobj1 = { + toNumber: function() { + return 12345; + }, + toString: function() { + return 67890; + }, + valueOf: function() { + return "[object MyObj]"; + } +}; + +if (String(myobj1) !== "67890") { + throw new Test262Error("#11: String(myobj) calls ToPrimitive with hint String"); +} + +// CHECK#12 +var myobj2 = { + toNumber: function() { + return 12345; + }, + toString: function() { + return {} + }, + valueOf: function() { + return "[object MyObj]"; + } +}; + +if (String(myobj2) !== "[object MyObj]") { + throw new Test262Error("#12: String(myobj) calls ToPrimitive with hint String"); +} + +// CHECK#13 +var myobj3 = { + toNumber: function() { + return 12345; + }, + valueOf: function() { + return "[object MyObj]"; + } +}; + +if (String(myobj3) !== "[object Object]") { + throw new Test262Error("#13: String(myobj) calls ToPrimitive with hint String"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/browser.js b/js/src/tests/test262/built-ins/String/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/browser.js diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A1.js new file mode 100644 index 0000000000..0d34147bfa --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A1.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: The length property of the fromCharCode function is 1 +es5id: 15.5.3.2_A1 +description: Checking String.fromCharCode.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof String.fromCharCode !== "function") { + throw new Test262Error('#1: typeof String.fromCharCode === "function". Actual: typeof String.fromCharCode ===' + typeof String.fromCharCode); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (!(String.hasOwnProperty("fromCharCode"))) { + throw new Test262Error('#2: String.hasOwnProperty("fromCharCode") return true. Actual: ' + String.hasOwnProperty("fromCharCode")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (String.fromCharCode.length !== 1) { + throw new Test262Error('#3: String.fromCharCode.length === 1. Actual: String.fromCharCode.length ===' + String.fromCharCode.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A2.js new file mode 100644 index 0000000000..1584c3ad73 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode () returns empty string +es5id: 15.5.3.2_A2 +description: Call String.fromCharCode() +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.fromCharCode() !== "") { + throw new Test262Error('#1: String.fromCharCode () returns empty string. Actual: ' + String.fromCharCode()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T1.js new file mode 100644 index 0000000000..fb9e1e5e3c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] ) +es5id: 15.5.3.2_A3_T1 +description: Call String.fromCharCode(65,66,66,65) +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.fromCharCode(65, 66, 66, 65) !== "ABBA") { + throw new Test262Error('#1: String.fromCharCode(65,66,66,65) === "ABBA". Actual: String.fromCharCode(65,66,66,65) ===' + String.fromCharCode(65, 66, 66, 65)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T2.js new file mode 100644 index 0000000000..3ae78b1237 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A3_T2.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode ( [ char0 [ , char1 [ , ... ] ] ] ) +es5id: 15.5.3.2_A3_T2 +description: > + Create function variable, that equal String.fromCharCode, delete + original String.fromCharCode and use created variable +---*/ + +var __fcc__func = String.fromCharCode; + +delete String.fromCharCode; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__fcc__func(65, 66, 66, 65) !== "ABBA") { + throw new Test262Error('#1: __fcc__func = String.fromCharCode; delete String.fromCharCode; __fcc__func(65,66,66,65) === "ABBA". Actual: __fcc__func(65,66,66,65) ===' + __fcc__func(65, 66, 66, 65)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A4.js b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A4.js new file mode 100644 index 0000000000..321612c888 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S15.5.3.2_A4.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.fromCharCode has not [[construct]] method +es5id: 15.5.3.2_A4 +description: Checking if creating "new String.fromCharCode" fails +---*/ + +var __fcc__func = String.fromCharCode; + +delete String.fromCharCode; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var __obj = new __fcc__func(65, 66, 66, 65); + throw new Test262Error('#1: __fcc__func = String.fromCharCode; var __obj = new __fcc__func(65,66,66,65) 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/fromCharCode/S9.7_A1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A1.js new file mode 100644 index 0000000000..098d5c3f72 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A1.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If value is NaN, +0, -0, +Infinity, or -Infinity, return +0 +es5id: 9.7_A1 +description: > + For testing use String.fromCharCode(Number).charCodeAt(0) + construction +---*/ + +// CHECK#1 +if (String.fromCharCode(Number.NaN).charCodeAt(0) !== +0) { + throw new Test262Error('#1.1: String.fromCharCode(Number.NaN).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number.NaN).charCodeAt(0))); +} else if (1 / String.fromCharCode(Number.NaN).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#1.2: String.fromCharCode(Number.NaN).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#2 +if (String.fromCharCode(Number("abc")).charCodeAt(0) !== +0) { + throw new Test262Error('#2.1: String.fromCharCode(Number("abc")).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number("abc")).charCodeAt(0))); +} else if (1 / String.fromCharCode(0).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#2.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#3 +if (String.fromCharCode(0).charCodeAt(0) !== +0) { + throw new Test262Error('#3.1: String.fromCharCode(0).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(0).charCodeAt(0))); +} else if (1 / String.fromCharCode(0).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#3.2: String.fromCharCode(0).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#4 +if (String.fromCharCode(-0).charCodeAt(0) !== +0) { + throw new Test262Error("#4.1: String.fromCharCode(-0).charCodeAt(0) === +0"); +} else if (1 / String.fromCharCode(-0).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + throw new Test262Error("#4.2: String.fromCharCode(-0).charCodeAt(0) === +0. Actual: -0"); +} + +// CHECK#5 +if (String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) !== +0) { + throw new Test262Error('#5.1: String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0))); +} else if (1 / String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#5.2: String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) === +0. Actual: -0'); +} + +// CHECK#6 +if (String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) !== +0) { + throw new Test262Error("#6.1: String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) === +0"); +} else if (1 / String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) !== Number.POSITIVE_INFINITY) { + throw new Test262Error("#6.2: String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) === +0. Actual: -0"); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.1.js new file mode 100644 index 0000000000..8942031757 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.1.js @@ -0,0 +1,57 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: ToUint16 returns values between 0 and 2^16-1 +es5id: 9.7_A2.1 +description: > + Converting numbers, which are in\outside of Uint16 scopes, with + String.fromCharCode(Number).charCodeAt(0) construction +---*/ + +// CHECK#1 +if (String.fromCharCode(0).charCodeAt(0) !== 0) { + throw new Test262Error('#1: String.fromCharCode(0).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(0).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(1).charCodeAt(0) !== 1) { + throw new Test262Error('#2: String.fromCharCode(1).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(1).charCodeAt(0))); +} + +// CHECK#3 +if (String.fromCharCode(-1).charCodeAt(0) !== 65535) { + throw new Test262Error('#3: String.fromCharCode(-1).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(-1).charCodeAt(0))); +} + +// CHECK#4 +if (String.fromCharCode(65535).charCodeAt(0) !== 65535) { + throw new Test262Error('#4: String.fromCharCode(65535).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(65535).charCodeAt(0))); +} + +// CHECK#5 +if (String.fromCharCode(65534).charCodeAt(0) !== 65534) { + throw new Test262Error('#5: String.fromCharCode(65534).charCodeAt(0) === 65534. Actual: ' + (String.fromCharCode(65534).charCodeAt(0))); +} + +// CHECK#6 +if (String.fromCharCode(65536).charCodeAt(0) !== 0) { + throw new Test262Error('#6: String.fromCharCode(65536).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(65536).charCodeAt(0))); +} + +// CHECK#7 +if (String.fromCharCode(4294967295).charCodeAt(0) !== 65535) { + throw new Test262Error('#7: String.fromCharCode(4294967295).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(4294967295).charCodeAt(0))); +} + +// CHECK#8 +if (String.fromCharCode(4294967294).charCodeAt(0) !== 65534) { + throw new Test262Error('#8: String.fromCharCode(4294967294).charCodeAt(0) === 65534. Actual: ' + (String.fromCharCode(4294967294).charCodeAt(0))); +} + +// CHECK#9 +if (String.fromCharCode(4294967296).charCodeAt(0) !== 0) { + throw new Test262Error('#9: String.fromCharCode(4294967296).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(4294967296).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.2.js new file mode 100644 index 0000000000..8c5c28d75d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A2.2.js @@ -0,0 +1,72 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Compute result modulo 2^16 +es5id: 9.7_A2.2 +description: > + For testing use String.fromCharCode(Number).charCodeAt(0) + construction +---*/ + +// CHECK#1 +if (String.fromCharCode(-32767).charCodeAt(0) !== 32769) { + throw new Test262Error('#1: String.fromCharCode(-32767).charCodeAt(0) === 32769. Actual: ' + (String.fromCharCode(-32767).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(-32768).charCodeAt(0) !== 32768) { + throw new Test262Error('#2: String.fromCharCode(-32768).charCodeAt(0) === 32768. Actual: ' + (String.fromCharCode(-32768).charCodeAt(0))); +} + +// CHECK#3 +if (String.fromCharCode(-32769).charCodeAt(0) !== 32767) { + throw new Test262Error('#3: String.fromCharCode(-32769).charCodeAt(0) === 32767. Actual: ' + (String.fromCharCode(-32769).charCodeAt(0))); +} + +// CHECK#4 +if (String.fromCharCode(-65535).charCodeAt(0) !== 1) { + throw new Test262Error('#4: String.fromCharCode(-65535).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(-65535).charCodeAt(0))); +} + +// CHECK#5 +if (String.fromCharCode(-65536).charCodeAt(0) !== 0) { + throw new Test262Error('#5: String.fromCharCode(-65536).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(-65536).charCodeAt(0))); +} + +// CHECK#6 +if (String.fromCharCode(-65537).charCodeAt(0) !== 65535) { + throw new Test262Error('#6: String.fromCharCode(-65537).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(-65537).charCodeAt(0))); +} + +// CHECK#7 +if (String.fromCharCode(65535).charCodeAt(0) !== 65535) { + throw new Test262Error('#7: String.fromCharCode(65535).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(65535).charCodeAt(0))); +} + +// CHECK#8 +if (String.fromCharCode(65536).charCodeAt(0) !== 0) { + throw new Test262Error('#8: String.fromCharCode(65536).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(65536).charCodeAt(0))); +} + +// CHECK#9 +if (String.fromCharCode(65537).charCodeAt(0) !== 1) { + throw new Test262Error('#9: String.fromCharCode(65537).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(65537).charCodeAt(0))); +} + +// CHECK#10 +if (String.fromCharCode(131071).charCodeAt(0) !== 65535) { + throw new Test262Error('#10: String.fromCharCode(131071).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(131071).charCodeAt(0))); +} + +// CHECK#11 +if (String.fromCharCode(131072).charCodeAt(0) !== 0) { + throw new Test262Error('#11: String.fromCharCode(131072).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(131072).charCodeAt(0))); +} + +// CHECK#12 +if (String.fromCharCode(131073).charCodeAt(0) !== 1) { + throw new Test262Error('#12: String.fromCharCode(131073).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(131073).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T1.js new file mode 100644 index 0000000000..aade671307 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T1 +description: Type(x) is Boolean +---*/ + +// CHECK#1 +if (String.fromCharCode(new Boolean(true)).charCodeAt(0) !== 1) { + throw new Test262Error('#1: String.fromCharCode(new Boolean(true)).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(new Boolean(true)).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(false).charCodeAt(0) !== 0) { + throw new Test262Error('#2: String.fromCharCode(false).charCodeAt(0) === 0. Actual: ' + (String.fromCharCode(false).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T2.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T2.js new file mode 100644 index 0000000000..540608c677 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T2 +description: Type(x) is Number +---*/ + +// CHECK#1 +if (String.fromCharCode(new Number(1)).charCodeAt(0) !== 1) { + throw new Test262Error('#1: String.fromCharCode(new Number(1)).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(new Number(1)).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(-1.234).charCodeAt(0) !== 65535) { + throw new Test262Error('#2: String.fromCharCode(-1.234).charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode(-1.234).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T3.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T3.js new file mode 100644 index 0000000000..0235d4a5b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T3 +description: Type(x) is String +---*/ + +// CHECK#1 +if (String.fromCharCode(new String(1)).charCodeAt(0) !== 1) { + throw new Test262Error('#1: String.fromCharCode(new String(1)).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(new String(1)).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode("-1.234").charCodeAt(0) !== 65535) { + throw new Test262Error('#2: String.fromCharCode("-1.234").charCodeAt(0) === 65535. Actual: ' + (String.fromCharCode("-1.234").charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T4.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T4.js new file mode 100644 index 0000000000..4df691b949 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.1_T4.js @@ -0,0 +1,129 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator uses ToNumber +es5id: 9.7_A3.1_T4 +description: Type(x) is Object +---*/ + +//CHECK#1 +var object = { + valueOf: function() { + return 1 + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + throw new Test262Error('#1: var object = {valueOf: function() {return 1}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#2 +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return 0 + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + throw new Test262Error('#2: var object = {valueOf: function() {return 1}, toString: function() {return 0}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#3 +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return {} + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + throw new Test262Error('#3: var object = {valueOf: function() {return 1}, toString: function() {return {}}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#4 +try { + var object = { + valueOf: function() { + return 1 + }, + toString: function() { + throw "error" + } + }; + if (String.fromCharCode(object).charCodeAt(0) !== 1) { + throw new Test262Error('#4.1: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); + } +} +catch (e) { + if (e === "error") { + throw new Test262Error('#4.2: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; object not throw "error"'); + } else { + throw new Test262Error('#4.3: var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; object not throw Error. Actual: ' + (e)); + } +} + +//CHECK#5 +var object = { + toString: function() { + return 1 + } +}; +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + throw new Test262Error('#5: var object = {toString: function() {return 1}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#6 +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +if (String.fromCharCode(object).charCodeAt(0) !== 1) { + throw new Test262Error('#6: var object = {valueOf: function() {return {}}, toString: function() {return 1}}; String.fromCharCode(object).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(object).charCodeAt(0))); +} + +//CHECK#7 +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + object >>> 0; + throw new Test262Error('#7.1: var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; object throw "error". Actual: ' + (object >>> 0)); +} +catch (e) { + if (e !== "error") { + throw new Test262Error('#7.2: var object = {valueOf: function() {throw "error"}, toString: function() {return 1}}; object throw "error". Actual: ' + (e)); + } +} + +//CHECK#8 +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + object >>> 0; + throw new Test262Error('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; object throw TypeError. Actual: ' + (object >>> 0)); +} +catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#8.2: var object = {valueOf: function() {return {}}, toString: function() {return {}}}; object throw TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.2_T1.js b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.2_T1.js new file mode 100644 index 0000000000..3efb74756c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/S9.7_A3.2_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Operator uses floor, abs +es5id: 9.7_A3.2_T1 +description: > + For testing use String.fromCharCode(Number).charCodeAt(0) + construction +---*/ + +// CHECK#1 +if (String.fromCharCode(1.2345).charCodeAt(0) !== 1) { + throw new Test262Error('#1: String.fromCharCode(1.2345).charCodeAt(0) === 1. Actual: ' + (String.fromCharCode(1.2345).charCodeAt(0))); +} + +// CHECK#2 +if (String.fromCharCode(-5.4321).charCodeAt(0) !== 65531) { + throw new Test262Error('#2: String.fromCharCode(-5.4321).charCodeAt(0) === 65531. Actual: ' + (String.fromCharCode(-5.4321).charCodeAt(0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/browser.js b/js/src/tests/test262/built-ins/String/fromCharCode/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/browser.js diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/name.js b/js/src/tests/test262/built-ins/String/fromCharCode/name.js new file mode 100644 index 0000000000..aad7ed2c18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/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.2.1 +description: > + String.fromCharCode.name is "fromCharCode". +info: | + String.fromCharCode ( ...codeUnits ) + + 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.fromCharCode.name, "fromCharCode"); + +verifyNotEnumerable(String.fromCharCode, "name"); +verifyNotWritable(String.fromCharCode, "name"); +verifyConfigurable(String.fromCharCode, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js b/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js new file mode 100644 index 0000000000..2076c9b6ab --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/not-a-constructor.js @@ -0,0 +1,31 @@ +// 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.fromCharCode 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.fromCharCode), false, 'isConstructor(String.fromCharCode) must return false'); + +assert.throws(TypeError, () => { + new String.fromCharCode(); +}, '`new String.fromCharCode()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCharCode/shell.js b/js/src/tests/test262/built-ins/String/fromCharCode/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCharCode/shell.js diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-Symbol.js b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-Symbol.js new file mode 100644 index 0000000000..909f4909c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-Symbol.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Return abrupt from ToNumber(next). +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). +features: [Symbol, String.fromCodePoint] +---*/ + +assert.throws(TypeError, function() { + String.fromCodePoint(Symbol()); +}); + +assert.throws(TypeError, function() { + String.fromCodePoint(42, Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-not-integer.js b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-not-integer.js new file mode 100644 index 0000000000..e5410178a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-is-not-integer.js @@ -0,0 +1,49 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Throw a RangeError if an argument is not equal to its Integer representation. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). + d. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError + exception. + ... +features: [String.fromCodePoint] +---*/ + +assert.throws(RangeError, function() { + String.fromCodePoint(3.14); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(42, 3.14); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint('3.14'); +}); + +// ToNumber(undefined) returns NaN. +assert.throws(RangeError, function() { + String.fromCodePoint(undefined); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint('_1'); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint('1a'); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/argument-not-coercible.js b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-not-coercible.js new file mode 100644 index 0000000000..344690c1ca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/argument-not-coercible.js @@ -0,0 +1,44 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Return abrupt from ToNumber(next). +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). +features: [String.fromCodePoint] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'item', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + String.fromCodePoint({ + valueOf: function() { + throw new Test262Error(); + } + }); +}); + +assert.throws(Test262Error, function() { + String.fromCodePoint(42, { + valueOf: function() { + throw new Test262Error(); + } + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/arguments-is-empty.js b/js/src/tests/test262/built-ins/String/fromCodePoint/arguments-is-empty.js new file mode 100644 index 0000000000..5fa6407f27 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/arguments-is-empty.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + The the arguments list is empty, an empty string is returned. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + ... + 5. Repeat while nextIndex < length + ... + f. Append the elements of the UTF16Encoding (10.1.1) of nextCP to the end of + elements. + g. Let nextIndex be nextIndex + 1. + 6. Return the String value whose elements are, in order, the elements in the + List elements. If length is 0, the empty string is returned. + +features: [String.fromCodePoint] +---*/ + +assert.sameValue(String.fromCodePoint(), ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/browser.js b/js/src/tests/test262/built-ins/String/fromCodePoint/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/browser.js diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/fromCodePoint.js b/js/src/tests/test262/built-ins/String/fromCodePoint/fromCodePoint.js new file mode 100644 index 0000000000..6e9f8746be --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/fromCodePoint.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + String.fromCodePoint property descriptor +info: | + String.fromCodePoint ( ...codePoints ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.fromCodePoint] +---*/ + +verifyNotEnumerable(String, 'fromCodePoint'); +verifyWritable(String, 'fromCodePoint'); +verifyConfigurable(String, 'fromCodePoint'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/length.js b/js/src/tests/test262/built-ins/String/fromCodePoint/length.js new file mode 100644 index 0000000000..5708d475e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/length.js @@ -0,0 +1,20 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + The length property of the String.fromCodePoint constructor is 1. +includes: [propertyHelper.js] +features: [String.fromCodePoint] +---*/ + +assert.sameValue( + String.fromCodePoint.length, 1, + 'The value of `String.fromCodePoint.length` is `1`' +); + +verifyNotEnumerable(String.fromCodePoint, 'length'); +verifyNotWritable(String.fromCodePoint, 'length'); +verifyConfigurable(String.fromCodePoint, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/name.js b/js/src/tests/test262/built-ins/String/fromCodePoint/name.js new file mode 100644 index 0000000000..306ca1041d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + String.fromCodePoint.name +info: | + String.fromCodePoint ( ...codePoints ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.fromCodePoint] +---*/ + +assert.sameValue( + String.fromCodePoint.name, 'fromCodePoint', + 'The value of `String.fromCodePoint.name` is "fromCodePoint"' +); + +verifyNotEnumerable(String.fromCodePoint, 'name'); +verifyNotWritable(String.fromCodePoint, 'name'); +verifyConfigurable(String.fromCodePoint, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js b/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js new file mode 100644 index 0000000000..ad07f88425 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/not-a-constructor.js @@ -0,0 +1,31 @@ +// 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.fromCodePoint 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.fromCodePoint), false, 'isConstructor(String.fromCodePoint) must return false'); + +assert.throws(TypeError, () => { + new String.fromCodePoint(); +}, '`new String.fromCodePoint()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/number-is-out-of-range.js b/js/src/tests/test262/built-ins/String/fromCodePoint/number-is-out-of-range.js new file mode 100644 index 0000000000..2ea4144e2a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/number-is-out-of-range.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Throw a RangeError if an argument is < 0 or > 0x10FFFF. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + 2. Let length be the number of elements in codePoints. + 3. Let elements be a new List. + 4. Let nextIndex be 0. + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + c. ReturnIfAbrupt(nextCP). + d. If SameValue(nextCP, ToInteger(nextCP)) is false, throw a RangeError + exception. + e. If nextCP < 0 or nextCP > 0x10FFFF, throw a RangeError exception. + ... +features: [String.fromCodePoint] +---*/ + +assert.throws(RangeError, function() { + String.fromCodePoint(-1); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(1, -1); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(1114112); +}); + +assert.throws(RangeError, function() { + String.fromCodePoint(Infinity); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/return-string-value.js b/js/src/tests/test262/built-ins/String/fromCodePoint/return-string-value.js new file mode 100644 index 0000000000..d58934636a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/return-string-value.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Returns the String value whose elements are, in order, the code unit for the + numbers in the arguments list. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + ... + 5. Repeat while nextIndex < length + ... + f. Append the elements of the UTF16Encoding (10.1.1) of nextCP to the end of + elements. + g. Let nextIndex be nextIndex + 1. + 6. Return the String value whose elements are, in order, the elements in the + List elements. If length is 0, the empty string is returned. +features: [String.fromCodePoint] +---*/ + +assert.sameValue(String.fromCodePoint(0), '\x00'); +assert.sameValue(String.fromCodePoint(42), '*'); +assert.sameValue(String.fromCodePoint(65, 90), 'AZ'); +assert.sameValue(String.fromCodePoint(0x404), '\u0404'); +assert.sameValue(String.fromCodePoint(0x2F804), '\uD87E\uDC04'); +assert.sameValue(String.fromCodePoint(194564), '\uD87E\uDC04'); +assert.sameValue( + String.fromCodePoint(0x1D306, 0x61, 0x1D307), + '\uD834\uDF06a\uD834\uDF07' +); +assert.sameValue(String.fromCodePoint(1114111), '\uDBFF\uDFFF'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/shell.js b/js/src/tests/test262/built-ins/String/fromCodePoint/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/shell.js diff --git a/js/src/tests/test262/built-ins/String/fromCodePoint/to-number-conversions.js b/js/src/tests/test262/built-ins/String/fromCodePoint/to-number-conversions.js new file mode 100644 index 0000000000..452a904479 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/fromCodePoint/to-number-conversions.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.2 +description: > + Returns the String value with the code unit for the given coerced types. +info: | + String.fromCodePoint ( ...codePoints ) + + 1. Let codePoints be a List containing the arguments passed to this function. + ... + 5. Repeat while nextIndex < length + a. Let next be codePoints[nextIndex]. + b. Let nextCP be ToNumber(next). + ... + 6. Return the String value whose elements are, in order, the elements in the + List elements. If length is 0, the empty string is returned. + + Ref: 7.1.3 ToNumber ( argument ) +features: [String.fromCodePoint] +---*/ + +assert.sameValue(String.fromCodePoint(null), '\x00'); +assert.sameValue(String.fromCodePoint(false), '\x00'); +assert.sameValue(String.fromCodePoint(true), '\x01'); +assert.sameValue(String.fromCodePoint('42'), '\x2A'); +assert.sameValue(String.fromCodePoint('042'), '\x2A'); +assert.sameValue( + String.fromCodePoint({ + valueOf: function() { + return 31; + } + }), + '\x1F' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/is-a-constructor.js b/js/src/tests/test262/built-ins/String/is-a-constructor.js new file mode 100644 index 0000000000..7866cc611a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/is-a-constructor.js @@ -0,0 +1,26 @@ +// 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: > + The String constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(String), true, 'isConstructor(String) must return true'); +new String(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/length.js b/js/src/tests/test262/built-ins/String/length.js new file mode 100644 index 0000000000..62da509bdb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/length.js @@ -0,0 +1,30 @@ +// 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-properties-of-string-instances-length +description: The "length" property of String objects +info: | + [...] + 4. Return ? StringCreate(s, ? GetPrototypeFromConstructor(NewTarget, + "%StringPrototype%")). +includes: [propertyHelper.js] +---*/ + +var str = new String(''); + +verifyNotEnumerable(str, 'length'); +verifyNotWritable(str, 'length'); +verifyNotConfigurable(str, 'length'); + +assert.sameValue(str.length, 0, 'empty string'); + +str = new String(' '); +assert.sameValue(str.length, 1, 'whitespace'); + +str = new String(' \b '); +assert.sameValue(str.length, 3, 'character escape (U+008, "backspace")'); + +str = new String('\ud834\udf06'); +assert.sameValue(str.length, 2, 'Unicode escape (surrogate pair)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/numeric-properties.js b/js/src/tests/test262/built-ins/String/numeric-properties.js new file mode 100644 index 0000000000..a57bcef39d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/numeric-properties.js @@ -0,0 +1,33 @@ +// 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-exotic-objects-getownproperty-p +description: > + Property descriptor for numeric "own" properties of an exotic String object +info: | + [...] + 12. Let resultStr be a String value of length 1, containing one code unit + from str, specifically the code unit at index index. + 13. Return a PropertyDescriptor{[[Value]]: resultStr, [[Writable]]: false, + [[Enumerable]]: true, [[Configurable]]: false}. +includes: [propertyHelper.js] +---*/ + +var str = new String('abc'); + +assert.sameValue(str[0], 'a'); +verifyEnumerable(str, '0'); +verifyNotWritable(str, '0'); +verifyNotConfigurable(str, '0'); + +assert.sameValue(str[1], 'b'); +verifyEnumerable(str, '1'); +verifyNotWritable(str, '1'); +verifyNotConfigurable(str, '1'); + +assert.sameValue(str[2], 'c'); +verifyEnumerable(str, '2'); +verifyNotWritable(str, '2'); +verifyNotConfigurable(str, '2'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prop-desc.js b/js/src/tests/test262/built-ins/String/prop-desc.js new file mode 100644 index 0000000000..7f43a1fd4e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prop-desc.js @@ -0,0 +1,18 @@ +// Copyright (C) 2019 Bocoup. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-constructor-properties-of-the-global-object-string +description: Property descriptor for String +info: | + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(this, "String"); +verifyWritable(this, "String"); +verifyConfigurable(this, "String"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/proto-from-ctor-realm.js b/js/src/tests/test262/built-ins/String/proto-from-ctor-realm.js new file mode 100644 index 0000000000..986112d5cb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/proto-from-ctor-realm.js @@ -0,0 +1,30 @@ +// 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-constructor-string-value +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 4. Return ? StringCreate(s, ? GetPrototypeFromConstructor(NewTarget, + "%StringPrototype%")). + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(String, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.String.prototype); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A1.js b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A1.js new file mode 100644 index 0000000000..d74defe0d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The String has property prototype +es5id: 15.5.3.1_A1 +description: Checking String.hasOwnProperty('prototype') +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.hasOwnProperty('prototype'))) { + throw new Test262Error('#1: String.hasOwnProperty(\'prototype\') return true. Actual: ' + String.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A2.js b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A2.js new file mode 100644 index 0000000000..83ff7dfa62 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A2.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: The String.prototype property has the attribute DontEnum +es5id: 15.5.3.1_A2 +description: Checking if enumerating the String.prototype property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.hasOwnProperty('prototype'))) { + throw new Test262Error('#0: String.hasOwnProperty(\'prototype\') return true. Actual: ' + String.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.propertyIsEnumerable('prototype')) { + throw new Test262Error('#1: String.propertyIsEnumerable(\'prototype\') return false. Actual: ' + String.propertyIsEnumerable('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String) { + if (p === "prototype") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String){ if (p==="prototype") count++;}; count === 0. Actual: count ===' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A3.js b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A3.js new file mode 100644 index 0000000000..87f0a07b0c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A3.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: The String.prototype property has the attribute DontDelete +es5id: 15.5.3.1_A3 +description: Checking if deleting the String.prototype property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.hasOwnProperty('prototype'))) { + throw new Test262Error('#1: String.hasOwnProperty(\'prototype\') return true. Actual: ' + String.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + +verifyNotConfigurable(String, "prototype"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +try { + if ((delete String.prototype) !== false) { + throw new Test262Error('#2: String.prototype has the attribute DontDelete'); + } +} catch (e) { + if (e instanceof Test262Error) throw e; + assert(e instanceof TypeError); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (!(String.hasOwnProperty('prototype'))) { + throw new Test262Error('#3: delete String.prototype; String.hasOwnProperty(\'prototype\') return true. Actual: ' + String.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A4.js b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A4.js new file mode 100644 index 0000000000..a4e7014e42 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/S15.5.3.1_A4.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: The String.prototype property has the attribute ReadOnly +es5id: 15.5.3.1_A4 +description: Checking if varying the String.prototype property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.hasOwnProperty('prototype'))) { + throw new Test262Error('#1: String.hasOwnProperty(\'prototype\') return true. Actual: ' + String.hasOwnProperty('prototype')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype; + +verifyNotWritable(String, "prototype", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype !== __obj) { + throw new Test262Error('#2: __obj = String.prototype; String.prototype = function(){return "shifted";}; String.prototype === __obj. Actual: String.prototype ===' + String.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A1.js b/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A1.js new file mode 100644 index 0000000000..55437f96a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A1.js @@ -0,0 +1,24 @@ +// 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 object is itself a String object (its [[Class]] is "String") +es5id: 15.5.4_A1 +description: > + first we delete String.prototype.toString cause it overrides + Object prototype toString. Object.prototype.toString returns + [object+[[class]]+] +---*/ + +delete String.prototype.toString; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.toString() !== "[object " + "String" + "]") { + throw new Test262Error('#1: delete String.prototype.toString; String.prototype.toString() === "[object "+"String"+"]". Actual: String.prototype.toString() ===' + String.prototype.toString()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A2.js b/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A2.js new file mode 100644 index 0000000000..3369b4ecf3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A2.js @@ -0,0 +1,18 @@ +// 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 object is itself a String object whose value is an empty string +es5id: 15.5.4_A2 +description: Checking String.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype != "") { + throw new Test262Error('#1: String.prototype =="". Actual: String.prototype ==' + String.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A3.js b/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A3.js new file mode 100644 index 0000000000..33540be3a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/S15.5.4_A3.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 value of the internal [[Prototype]] property of the String prototype + object is the Object prototype object (15.2.3.1) +es5id: 15.5.4_A3 +description: Checking Object.prototype.isPrototypeOf(String.prototype) +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(Object.prototype.isPrototypeOf(String.prototype))) { + throw new Test262Error('#1: Object.prototype.isPrototypeOf(String.prototype) return true. Actual: ' + Object.prototype.isPrototypeOf(String.prototype)); +} +// +////////////////////////////////////////////////////////////////////////////// + +delete String.prototype.toString; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toString() != "[object " + "String" + "]") { + throw new Test262Error('#2: delete String.prototype.toString; String.prototype.toString() == "[object "+"String"+"]". Actual: String.prototype.toString() ==' + String.prototype.toString()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/browser.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/length.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/length.js new file mode 100644 index 0000000000..c7b43eed8a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/length.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.1.3.27 +description: Length of String.prototype[ @@iterator ] +info: | + ES6 Section 17: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +features: [Symbol.iterator] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(String.prototype[Symbol.iterator].length, 0); + +verifyNotEnumerable(String.prototype[Symbol.iterator], 'length'); +verifyNotWritable(String.prototype[Symbol.iterator], 'length'); +verifyConfigurable(String.prototype[Symbol.iterator], 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/name.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/name.js new file mode 100644 index 0000000000..29f1ffc52e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/name.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.1.3.27 +description: Descriptor for `name` property +info: | + The value of the name property of this function is "[Symbol.iterator]". + + ES6 Section 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, this value is the name that is given to + the function in this specification. + + [...] + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +features: [Symbol.iterator] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(String.prototype[Symbol.iterator].name, '[Symbol.iterator]'); + +verifyNotEnumerable(String.prototype[Symbol.iterator], 'name'); +verifyNotWritable(String.prototype[Symbol.iterator], 'name'); +verifyConfigurable(String.prototype[Symbol.iterator], 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 0000000000..33fdc254d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/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[Symbol.iterator] 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, Symbol, Symbol.iterator, arrow-function] +---*/ + +assert.sameValue( + isConstructor(String.prototype[Symbol.iterator]), + false, + 'isConstructor(String.prototype[Symbol.iterator]) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype[Symbol.iterator](); +}, '`new String.prototype[Symbol.iterator]()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/prop-desc.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/prop-desc.js new file mode 100644 index 0000000000..afea256f3e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.1.3.27 +description: Property descriptor +info: | + ES6 Section 17 + + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +features: [Symbol.iterator] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof String.prototype[Symbol.iterator], 'function'); +verifyNotEnumerable(String.prototype, Symbol.iterator); +verifyWritable(String.prototype, Symbol.iterator); +verifyConfigurable(String.prototype, Symbol.iterator); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/shell.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/this-val-non-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/this-val-non-obj-coercible.js new file mode 100644 index 0000000000..eec6d2eb74 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/this-val-non-obj-coercible.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.1.3.27 +description: The `this` value cannot be coerced into an object +info: | + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol.iterator] +---*/ + +assert.throws(TypeError, function() { + String.prototype[Symbol.iterator].call(undefined); +}); + +assert.throws(TypeError, function() { + String.prototype[Symbol.iterator].call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js new file mode 100644 index 0000000000..3a9f6c4cb8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/Symbol.iterator/this-val-to-str-err.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 25.1.3.27 +description: Error thrown coercing `this` value to a string +info: | + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol.iterator] +---*/ + +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype[Symbol.iterator].call(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/browser.js b/js/src/tests/test262/built-ins/String/prototype/at/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/at/index-argument-tointeger.js b/js/src/tests/test262/built-ins/String/prototype/at/index-argument-tointeger.js new file mode 100644 index 0000000000..1265d2412b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/index-argument-tointeger.js @@ -0,0 +1,29 @@ +// 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.at +description: > + Property type and descriptor. +info: | + String.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +let valueOfCallCount = 0; +let index = { + valueOf() { + valueOfCallCount++; + return 1; + } +}; + +let s = "01"; + +assert.sameValue(s.at(index), '1', 's.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1'); +assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger-invalid.js new file mode 100644 index 0000000000..64a31c0120 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -0,0 +1,22 @@ +// 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.at +description: > + Property type and descriptor. +info: | + String.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +let s = "01"; + +assert.throws(TypeError, () => { + s.at(Symbol()); +}, '`s.at(Symbol())` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js b/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js new file mode 100644 index 0000000000..c7e56a2a94 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js @@ -0,0 +1,28 @@ +// 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.at +description: > + Property type and descriptor. +info: | + String.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +let s = "01"; + +assert.sameValue(s.at(false), '0', 's.at(false) must return 0'); +assert.sameValue(s.at(null), '0', 's.at(null) must return 0'); +assert.sameValue(s.at(undefined), '0', 's.at(undefined) must return 0'); +assert.sameValue(s.at(""), '0', 's.at("") must return 0'); +assert.sameValue(s.at(function() {}), '0', 's.at(function() {}) must return 0'); +assert.sameValue(s.at([]), '0', 's.at([]) must return 0'); + +assert.sameValue(s.at(true), '1', 's.at(true) must return 1'); +assert.sameValue(s.at("1"), '1', 's.at("1") must return 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/length.js b/js/src/tests/test262/built-ins/String/prototype/at/length.js new file mode 100644 index 0000000000..d552c459bd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/length.js @@ -0,0 +1,26 @@ +// 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.at +description: > + String.prototype.at.length value and descriptor. +info: | + String.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +assert.sameValue( + String.prototype.at.length, 1, + 'The value of String.prototype.at.length is 1' +); + +verifyNotEnumerable(String.prototype.at, 'length'); +verifyNotWritable(String.prototype.at, 'length'); +verifyConfigurable(String.prototype.at, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/name.js b/js/src/tests/test262/built-ins/String/prototype/at/name.js new file mode 100644 index 0000000000..46b8a44410 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/name.js @@ -0,0 +1,28 @@ +// 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.at +description: > + String.prototype.at.name value and descriptor. +info: | + String.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +assert.sameValue( + String.prototype.at.name, 'at', + 'The value of String.prototype.at.name is "at"' +); + +verifyProperty(String.prototype.at, 'name', { + enumerable: false, + writable: false, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/prop-desc.js b/js/src/tests/test262/built-ins/String/prototype/at/prop-desc.js new file mode 100644 index 0000000000..2cc96c993b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/prop-desc.js @@ -0,0 +1,28 @@ +// 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.at +description: > + Property type and descriptor. +info: | + String.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +assert.sameValue( + typeof String.prototype.at, + 'function', + 'The value of `typeof String.prototype.at` is "function"' +); + +verifyProperty(String.prototype, 'at', { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/at/return-abrupt-from-this.js new file mode 100644 index 0000000000..0dc4011fce --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/return-abrupt-from-this.js @@ -0,0 +1,24 @@ +// 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.at +description: > + Return abrupt from RequireObjectCoercible(this value). +info: | + String.prototype.at( index ) + + Let O be ? RequireObjectCoercible(this value). + +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +assert.throws(TypeError, () => { + String.prototype.at.call(undefined); +}, '`String.prototype.at.call(undefined)` throws TypeError'); + +assert.throws(TypeError, () => { + String.prototype.at.call(null); +}, '`String.prototype.at.call(null)` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/returns-code-unit.js b/js/src/tests/test262/built-ins/String/prototype/at/returns-code-unit.js new file mode 100644 index 0000000000..08b1e049e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/returns-code-unit.js @@ -0,0 +1,32 @@ +// 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.at +description: > + The method should return an Iterator instance. +info: | + String.prototype.at ( ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfStringLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +let s = "12\uD80034"; + +assert.sameValue(s.at(0), "1", 's.at(0) must return "1"'); +assert.sameValue(s.at(1), "2", 's.at(1) must return "2"'); +assert.sameValue(s.at(2), "\uD800", 's.at(2) must return "\\uD800"'); +assert.sameValue(s.at(3), "3", 's.at(3) must return "3"'); +assert.sameValue(s.at(4), "4", 's.at(4) must return "4"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/returns-item-relative-index.js b/js/src/tests/test262/built-ins/String/prototype/at/returns-item-relative-index.js new file mode 100644 index 0000000000..9c3360f266 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/returns-item-relative-index.js @@ -0,0 +1,31 @@ +// 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.at +description: > + Returns the item value at the specified relative index +info: | + String.prototype.at ( ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfStringLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +let s = "12345"; + +assert.sameValue(s.at(0), "1", 's.at(0) must return "1"'); +assert.sameValue(s.at(-1), "5", 's.at(-1) must return "5"'); +assert.sameValue(s.at(-3), "3", 's.at(-3) must return "3"'); +assert.sameValue(s.at(-4), "2", 's.at(-4) must return "2"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/returns-item.js b/js/src/tests/test262/built-ins/String/prototype/at/returns-item.js new file mode 100644 index 0000000000..c71ce2d605 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/returns-item.js @@ -0,0 +1,32 @@ +// 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.at +description: > + Returns the item value at the specified index +info: | + String.prototype.at ( ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfStringLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +let s = "12345"; + +assert.sameValue(s.at(0), "1", 's.at(0) must return "1"'); +assert.sameValue(s.at(1), "2", 's.at(1) must return "2"'); +assert.sameValue(s.at(2), "3", 's.at(2) must return "3"'); +assert.sameValue(s.at(3), "4", 's.at(3) must return "4"'); +assert.sameValue(s.at(4), "5", 's.at(4) must return "5"'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/returns-undefined-for-out-of-range-index.js b/js/src/tests/test262/built-ins/String/prototype/at/returns-undefined-for-out-of-range-index.js new file mode 100644 index 0000000000..4be2a96b67 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/returns-undefined-for-out-of-range-index.js @@ -0,0 +1,22 @@ +// 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.at +description: > + Creates an iterator from a custom object. +info: | + String.prototype.at( index ) + + If k < 0 or k ≥ len, then return undefined. +features: [String.prototype.at] +---*/ +assert.sameValue(typeof String.prototype.at, 'function'); + +let s = ""; + +assert.sameValue(s.at(-2), undefined, 's.at(-2) must return undefined'); // wrap around the end +assert.sameValue(s.at(0), undefined, 's.at(0) must return undefined'); +assert.sameValue(s.at(1), undefined, 's.at(1) must return undefined'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/at/shell.js b/js/src/tests/test262/built-ins/String/prototype/at/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/at/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/browser.js b/js/src/tests/test262/built-ins/String/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1.1.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1.1.js new file mode 100644 index 0000000000..82a34b6a53 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1.1.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.charAt() can accept many arguments +es5id: 15.5.4.4_A1.1 +description: Checking by using eval +---*/ + +function __FACTORY() { + this.toString = function() { + return "wizard"; + }; +}; + +__FACTORY.prototype.charAt = String.prototype.charAt; + +var __instance = new __FACTORY; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charAt(eval("1"), true, null, {}) !== "i") { + throw new Test262Error('#1: __instance.charAt(eval("1"),true,null,{})=== "i". Actual: ' + __instance.charAt(eval("1"), true, null, {})); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A10.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A10.js new file mode 100644 index 0000000000..3c5e38db4c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A10.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: The String.prototype.charAt.length property has the attribute ReadOnly +es5id: 15.5.4.4_A10 +description: > + Checking if varying the String.prototype.charAt.length property + fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.charAt.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.charAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.charAt.length; + +verifyNotWritable(String.prototype.charAt, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charAt.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.charAt.length; String.prototype.charAt.length = function(){return "shifted";}; String.prototype.charAt.length === __obj. Actual: ' + String.prototype.charAt.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A11.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A11.js new file mode 100644 index 0000000000..6e29517e39 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A11.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 length property of the charAt method is 1 +es5id: 15.5.4.4_A11 +description: Checking String.prototype.charAt.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.charAt.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.charAt.hasOwnProperty("length") return true. Actual: ' + String.prototype.charAt.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charAt.length !== 1) { + throw new Test262Error('#2: String.prototype.charAt.length === 1. Actual: ' + String.prototype.charAt.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T1.js new file mode 100644 index 0000000000..72a0bd2238 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T1 +description: pos is false and true, and instance is object +---*/ + +var __instance = new Object(42); + +__instance.charAt = String.prototype.charAt; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charAt(false) + __instance.charAt(true) !== "42") { + throw new Test262Error('#1: __instance = new Object(42); __instance.charAt = String.prototype.charAt; __instance = new Object(42); __instance.charAt = String.prototype.charAt; __instance.charAt(false)+__instance.charAt(true) === "42". Actual: ' + __instance.charAt(false) + __instance.charAt(true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T10.js new file mode 100644 index 0000000000..ac98653b3f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T10.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T10 +description: Call charAt() function with object argument +---*/ + +var __obj = { + toString: function() { + return 1; + } +} +var __str = "lego"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.charAt(__obj) !== "e") { + throw new Test262Error('#1: var __obj = {toString:function(){return 1;}}; var __str = "lego"; __str.charAt(__obj) === "e". Actual: ' + __str.charAt(__obj)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T2.js new file mode 100644 index 0000000000..f6d675d698 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T2 +description: pos is equation with false and true, and instance is Boolean object +---*/ + +var __instance = new Boolean; + +__instance.charAt = String.prototype.charAt; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charAt(false) + __instance.charAt(true) + __instance.charAt(true + 1) !== "fal") { + throw new Test262Error('#1: __instance = new Boolean; __instance.charAt = String.prototype.charAt; __instance = new Boolean; __instance.charAt = String.prototype.charAt; __instance.charAt(false)+__instance.charAt(true)+__instance.charAt(true+1) === "fal". Actual: ' + __instance.charAt(false) + __instance.charAt(true) + __instance.charAt(true + 1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T4.js new file mode 100644 index 0000000000..6c6a051597 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T4.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T4 +description: Call charAt() function without argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger() evaluates to 0 charAt() evaluates to charAt(0) +if ("lego".charAt() !== "l") { + throw new Test262Error('#1: "lego".charAt() === "l". Actual: "lego".charAt() ===' + ("lego".charAt())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T5.js new file mode 100644 index 0000000000..138d7948f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T5 +description: Call charAt() function with null argument of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(null) evaluates to 0 charAt() evaluates to charAt(0) +if (function() { + return "lego" + }().charAt(null) !== "l") { + throw new Test262Error('#1: function(){return "lego"}().charAt(null) === "l". Actual: function(){return "lego"}().charAt(null) ===' + function() { + return "lego" + }().charAt(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T6.js new file mode 100644 index 0000000000..d207385458 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T6 +description: > + Call charAt() function with x argument of new String object, where + x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charAt() evaluates to charAt(0) +if (new String("lego").charAt(x) !== "l") { + throw new Test262Error('#1: var x; new String("lego").charAt(x) === "l". Actual: new String("lego").charAt(x) ===' + new String("lego").charAt(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T7.js new file mode 100644 index 0000000000..73c0998587 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T7 +description: Call charAt() function with undefined argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charAt() evaluates to charAt(0) +if (String("lego").charAt(undefined) !== "l") { + throw new Test262Error('#1: String("lego").charAt(undefined) === "l". Actual: String("lego").charAt(undefined) ===' + String("lego").charAt(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T8.js new file mode 100644 index 0000000000..8c4bc9dc0f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T8.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt(pos) +es5id: 15.5.4.4_A1_T8 +description: Call charAt() function with void 0 argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(void 0) evaluates to 0 charAt() evaluates to charAt(0) +if (String(42).charAt(void 0) !== "4") { + throw new Test262Error('#1: String(42).charAt(void 0) === "4". Actual: String(42).charAt(void 0) ===' + String(42).charAt(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T9.js new file mode 100644 index 0000000000..c45374025b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A1_T9.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.charAt(pos) +es5id: 15.5.4.4_A1_T9 +description: > + Call charAt() function with function(){}() argument of string + object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charAt() evaluates to charAt(0) +if (new String(42).charAt(function() {}()) !== "4") { + throw new Test262Error('#1: new String(42).charAt(function(){}()) === "4". Actual: new String(42).charAt(function(){}()) ===' + new String(42).charAt(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A2.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A2.js new file mode 100644 index 0000000000..139d75b06d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A2.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: | + When String.prototype.charAt(pos) calls if ToInteger(pos) less than 0 the + empty string returns +es5id: 15.5.4.4_A2 +description: Call charAt(pos) with negative pos +---*/ + +function __FACTORY() {}; + +__FACTORY.prototype.charAt = String.prototype.charAt; + +var __instance = new __FACTORY; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charAt(-1) !== "") { + throw new Test262Error('#1: __instance.charAt(-1) === "". Actual: __instance.charAt(-1) ===' + __instance.charAt(-1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A3.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A3.js new file mode 100644 index 0000000000..dd32dcbd8b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String.prototype.charAt(pos) calls if ToInteger(pos) not less than + ToString(this value) the empty string returns +es5id: 15.5.4.4_A3 +description: pos is bigger of string length +---*/ + +var __instance = new String("ABC"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charAt(3) !== "") { + throw new Test262Error('#1: __instance = new String("ABC"); __instance.charAt(3) === "". Actual: __instance.charAt(3) ===' + __instance.charAt(3)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T1.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T1.js new file mode 100644 index 0000000000..7bd0ab8cb4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T1.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If pos is a value of Number type that is an integer, then the result of + x.charAt(pos) is equal to the result of x.substring(pos, pos+1) +es5id: 15.5.4.4_A4_T1 +description: Compare results of x.charAt(pos) and x.substring(pos, pos+1) +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var i = 0; i < 6; i++) { + if ("ABC\u0041\u0042\u0043".charAt(i) !== "\u0041\u0042\u0043ABC".substring(i, i + 1)) { + throw new Test262Error('#' + i + ': "ABC\\u0041\\u0042\\u0043".charAt(' + i + ') === "\\u0041\\u0042\\u0043ABC".substring(' + i + ', ' + (i + 1) + '). Actual: "ABC\\u0041\\u0042\\u0043".charAt(' + i + ') ===' + ("ABC\u0041\u0042\u0043".charAt(i))); + } +} + +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T2.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T2.js new file mode 100644 index 0000000000..4624ccef9f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If pos is a value of Number type that is an integer, then the result of + x.charAt(pos) is equal to the result of x.substring(pos, pos+1) +es5id: 15.5.4.4_A4_T2 +description: > + Compare results of x.charAt(pos) and x.substring(pos, pos+1), wheb + pos is smaller of zero +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var i = -2; i < 0; i++) { + if ("ABC\u0041\u0042\u0043".charAt(i) !== "\u0041\u0042\u0043ABC".substring(i, i + 1)) { + throw new Test262Error('#' + (i + 2) + ': "ABC\\u0041\\u0042\\u0043".charAt(' + i + ') === "\\u0041\\u0042\\u0043ABC".substring(' + i + ', ' + (i + 1) + '). Actual: "ABC\\u0041\\u0042\\u0043".charAt(' + i + ') ===' + ("ABC\u0041\u0042\u0043".charAt(i))); + } +} + +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T3.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T3.js new file mode 100644 index 0000000000..da7368b170 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A4_T3.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If pos is a value of Number type that is an integer, then the result of + x.charAt(pos) is equal to the result of x.substring(pos, pos+1) +es5id: 15.5.4.4_A4_T3 +description: > + Compare results of x.charAt(pos) and x.substring(pos, pos+1), wheb + pos is bigger string length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var i = 6; i < 8; i++) { + if ("ABC\u0041\u0042\u0043".charAt(i) !== "\u0041\u0042\u0043ABC".substring(i, i + 1)) { + throw new Test262Error('#' + (i - 5) + ': "ABC\\u0041\\u0042\\u0043".charAt(' + i + ') === "\\u0041\\u0042\\u0043ABC".substring(' + i + ', ' + (i + 1) + '). Actual: "ABC\\u0041\\u0042\\u0043".charAt(' + i + ') ===' + ("ABC\u0041\u0042\u0043".charAt(i))); + } +} + +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A5.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A5.js new file mode 100644 index 0000000000..37320912bb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A5.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: | + When String.prototype.charAt(pos) calls first calls ToString, giving it + the this value as its argument +es5id: 15.5.4.4_A5 +description: Change toString function, it trow exception, and call charAt() +---*/ + +var __obj = { + valueOf: 1, + toString: function() { + throw 'intostring' + }, + charAt: String.prototype.charAt +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.charAt(); + throw new Test262Error('#1: __obj={valueOf:1,toString:function(){throw \'intostring\'},charAt:String.prototype.charAt}; "var x = __obj.charAt()" lead to throwing exception'); +} catch (e) { + if (e !== 'intostring') { + throw new Test262Error('#1.1: Exception === \'intostring\'. Actual: exception ===' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A6.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A6.js new file mode 100644 index 0000000000..6298c66ddc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charAt has not prototype property +es5id: 15.5.4.4_A6 +description: Checking String.prototype.charAt.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.charAt.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.charAt.prototype === undefined. Actual: ' + String.prototype.charAt.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A7.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A7.js new file mode 100644 index 0000000000..0d79526df8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A7.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.charAt can't be used as constructor +es5id: 15.5.4.4_A7 +description: Checking if creating the String.prototype.charAt object fails +---*/ + +var __FACTORY = String.prototype.charAt; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.charAt; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: undefined = 1 throw a TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A8.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A8.js new file mode 100644 index 0000000000..c7a23c927e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A8.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: The String.prototype.charAt.length property has the attribute DontEnum +es5id: 15.5.4.4_A8 +description: > + Checking if enumerating the String.prototype.charAt.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.charAt.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.charAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.charAt.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.charAt.propertyIsEnumerable(\'length\') return false. Actual: ' + String.prototype.charAt.propertyIsEnumerable('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.charAt) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.charAt){if (p==="length") count++;}; count === 0. Actual: count ===' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A9.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A9.js new file mode 100644 index 0000000000..b75e7537e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S15.5.4.4_A9.js @@ -0,0 +1,38 @@ +// 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.charAt.length property does not have the attribute + DontDelete +es5id: 15.5.4.4_A9 +description: > + Checking if deleting the String.prototype.charAt.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.charAt.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.charAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.charAt.length) { + throw new Test262Error('#1: delete String.prototype.charAt.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charAt.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.charAt.length; String.prototype.charAt.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.charAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S9.4_A1.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S9.4_A1.js new file mode 100644 index 0000000000..37aa8620dc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S9.4_A1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: If ToNumber(value) is NaN, ToInteger(value) returns +0 +es5id: 9.4_A1 +description: > + Check what position is defined by Number.NaN in string "abc": + "abc".charAt(Number.NaN) +---*/ + +// CHECK#1 +if ("abc".charAt(Number.NaN) !== "a") { + throw new Test262Error('#1: "abc".charAt(Number.NaN) === "a". Actual: ' + ("abc".charAt(Number.NaN))); +} + +// CHECK#2 +if ("abc".charAt("x") !== "a") { + throw new Test262Error('#2: "abc".charAt("x") === "a". Actual: ' + ("abc".charAt("x"))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/S9.4_A2.js b/js/src/tests/test262/built-ins/String/prototype/charAt/S9.4_A2.js new file mode 100644 index 0000000000..3a0fdfdf94 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/S9.4_A2.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + If ToNumber(value) is +0, -0, +Infinity, or -Infinity, + return ToNumber(value) +es5id: 9.4_A2 +description: > + Check what position is defined by Number.NaN in string "abc": + "abc".charAt(Number.NaN) +---*/ + +// CHECK#1 +if ("abc".charAt(0.0) !== "a") { + throw new Test262Error('#1: "abc".charAt(0.0) === "a". Actual: ' + ("abc".charAt(0.0))); +} + +// CHECK#2 +if ("abc".charAt(-0.0) !== "a") { + throw new Test262Error('#2: "abc".charAt(-0.0) === "a". Actual: ' + ("abc".charAt(-0.0))); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/browser.js b/js/src/tests/test262/built-ins/String/prototype/charAt/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/name.js b/js/src/tests/test262/built-ins/String/prototype/charAt/name.js new file mode 100644 index 0000000000..13a245e2fc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/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.1 +description: > + String.prototype.charAt.name is "charAt". +info: | + String.prototype.charAt ( pos ) + + 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.charAt.name, "charAt"); + +verifyNotEnumerable(String.prototype.charAt, "name"); +verifyNotWritable(String.prototype.charAt, "name"); +verifyConfigurable(String.prototype.charAt, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/charAt/not-a-constructor.js new file mode 100644 index 0000000000..6e00163a90 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/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.charAt 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.charAt), + false, + 'isConstructor(String.prototype.charAt) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.charAt(); +}, '`new String.prototype.charAt()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/pos-coerce-err.js b/js/src/tests/test262/built-ins/String/prototype/charAt/pos-coerce-err.js new file mode 100644 index 0000000000..a2ea4dac46 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/pos-coerce-err.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.charat +description: Error when attempting to coerce providec "pos" to a Number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var noCoerce = Object.create(null); + +assert.throws(TypeError, function() { + ''.charAt(noCoerce); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/pos-coerce-string.js b/js/src/tests/test262/built-ins/String/prototype/charAt/pos-coerce-string.js new file mode 100644 index 0000000000..51cdde8314 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/pos-coerce-string.js @@ -0,0 +1,18 @@ +// 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.charat +description: Coercion of "pos" string value into number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +assert.sameValue('abcd'.charAt(' +00200.0000E-0002 '), 'c'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/pos-rounding.js b/js/src/tests/test262/built-ins/String/prototype/charAt/pos-rounding.js new file mode 100644 index 0000000000..0f516f73c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/pos-rounding.js @@ -0,0 +1,27 @@ +// 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.charat +description: Rounding of the provided "pos" number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, return +0. + 3. If number is +0, -0, +∞, or -∞, return number. + 4. Return the number value that is the same sign as number and whose + magnitude is floor(abs(number)). +---*/ + +assert.sameValue('abc'.charAt(-0.99999), 'a', '-0.99999'); +assert.sameValue('abc'.charAt(-0.00001), 'a', '-0.00001'); +assert.sameValue('abc'.charAt(0.00001), 'a', '0.00001'); +assert.sameValue('abc'.charAt(0.99999), 'a', '0.99999'); +assert.sameValue('abc'.charAt(1.00001), 'b', '1.00001'); +assert.sameValue('abc'.charAt(1.99999), 'b', '1.99999'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/shell.js b/js/src/tests/test262/built-ins/String/prototype/charAt/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/charAt/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/charAt/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..3028c94073 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charAt/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.charat +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var charAt = String.prototype.charAt; + +assert.sameValue(typeof charAt, 'function'); + +assert.throws(TypeError, function() { + charAt.call(undefined, 0); +}, 'undefined'); + +assert.throws(TypeError, function() { + charAt.call(null, 0); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1.1.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1.1.js new file mode 100644 index 0000000000..9e27b9db34 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1.1.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.charCodeAt() can accept many arguments +es5id: 15.5.4.5_A1.1 +description: Checking by using eval +---*/ + +function __FACTORY() { + this.toString = function() { + return "wizard"; + }; +}; + +__FACTORY.prototype.charCodeAt = String.prototype.charCodeAt; + +var __instance = new __FACTORY; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charCodeAt(eval("1"), true, null, {}) !== 0x69) { + throw new Test262Error('#1: __instance.charCodeAt(eval("1"),true,null,{})=== 0x69. Actual: __instance.charCodeAt(eval("1"),true,null,{})===' + __instance.charCodeAt(eval("1"), true, null, {})); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A10.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A10.js new file mode 100644 index 0000000000..51d18d3db5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A10.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: The String.prototype.charCodeAt.length property has the attribute ReadOnly +es5id: 15.5.4.5_A10 +description: > + Checking if varying the String.prototype.charCodeAt.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.charCodeAt.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.charCodeAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.charCodeAt.length; + +verifyNotWritable(String.prototype.charCodeAt, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charCodeAt.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.charCodeAt.length; String.prototype.charCodeAt.length = function(){return "shifted";}; String.prototype.charCodeAt.length === __obj. Actual: ' + String.prototype.charCodeAt.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A11.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A11.js new file mode 100644 index 0000000000..104b402726 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A11.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 length property of the charCodeAt method is 1 +es5id: 15.5.4.5_A11 +description: Checking String.prototype.charCodeAt.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.charCodeAt.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.charCodeAt.hasOwnProperty("length") return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charCodeAt.length !== 1) { + throw new Test262Error('#2: String.prototype.charCodeAt.length === 1. Actual: ' + String.prototype.charCodeAt.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T1.js new file mode 100644 index 0000000000..53edc2e24b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T1 +description: pos is false and true, and instance is object +---*/ + +var __instance = new Object(42); + +__instance.charCodeAt = String.prototype.charCodeAt; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((__instance.charCodeAt(false) !== 52) || (__instance.charCodeAt(true) !== 50)) { + throw new Test262Error('#1: __instance = new Object(42); __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(false) === 52 and __instance.charCodeAt(true) === 50. Actual: __instance.charCodeAt(false) ===' + __instance.charCodeAt(false) + ' and __instance.charCodeAt(true) ===' + __instance.charCodeAt(true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T10.js new file mode 100644 index 0000000000..8548781ffe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T10.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T10 +description: Call charCodeAt() function with object argument +---*/ + +var __obj = { + toString: function() { + return 1; + } +} +var __str = "lego"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.charCodeAt(__obj) !== 0x65) { + throw new Test262Error('#1: var __obj = {toString:function(){return 1;}}; var __str = "lego"; __str.charCodeAt(__obj) === 0x65. Actual: ' + __str.charCodeAt(__obj)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T2.js new file mode 100644 index 0000000000..f93769b079 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T2.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T2 +description: pos is equation with false and true, and instance is Boolean object +---*/ + +var __instance = new Boolean; + +__instance.charCodeAt = String.prototype.charCodeAt; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.charCodeAt(false) !== 0x66) { + throw new Test262Error('#1: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(false)===0x66. Actual: ' + __instance.charCodeAt(false)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.charCodeAt(true) !== 0x61) { + throw new Test262Error('#2: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(true)===0x61. Actual: ' + __instance.charCodeAt(true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__instance.charCodeAt(true + 1) !== 0x6C) { + throw new Test262Error('#3: __instance = new Boolean; __instance.charCodeAt = String.prototype.charCodeAt; __instance.charCodeAt(true+1) === 0x6C. Actual: ' + __instance.charCodeAt(true + 1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T4.js new file mode 100644 index 0000000000..729817fd72 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T4.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T4 +description: Call charCodeAt() function without argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since Number() evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if ("smart".charCodeAt() !== 0x73) { + throw new Test262Error('#1: "smart".charCodeAt() === 0x73. Actual: "smart".charCodeAt() ===' + ("smart".charCodeAt())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T5.js new file mode 100644 index 0000000000..c975a03b3a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T5 +description: Call charCodeAt() function with null argument of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(null) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (function() { + return "lego" + }().charCodeAt(null) !== 0x6C) { + throw new Test262Error('#1: function(){return "lego"}().charCodeAt(null) === 0x6C. Actual: ' + function() { + return "lego" + }().charCodeAt(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T6.js new file mode 100644 index 0000000000..f45c701d11 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T6 +description: > + Call charCodeAt() function with x argument of new String object, + where x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (new String("lego").charCodeAt(x) !== 0x6C) { + throw new Test262Error('#1: var x; new String("lego").charCodeAt(x) === 0x6C. Actual: new String("lego").charCodeAt(x) ===' + new String("lego").charCodeAt(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T7.js new file mode 100644 index 0000000000..a7542ca12b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T7 +description: Call charCodeAt() function with undefined argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (String("lego").charCodeAt(undefined) !== 0x6C) { + throw new Test262Error('#1: String("lego").charCodeAt(undefined) === 0x6C. Actual: String("lego").charCodeAt(undefined) ===' + String("lego").charCodeAt(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T8.js new file mode 100644 index 0000000000..855cc4213f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T8.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt(pos) +es5id: 15.5.4.5_A1_T8 +description: Call charCodeAt() function with void 0 argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(void 0) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (String(42).charCodeAt(void 0) !== 0x34) { + throw new Test262Error('#1: String(42).charCodeAt(void 0) === 0x34. Actual: String(42).charCodeAt(void 0) ===' + String(42).charCodeAt(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T9.js new file mode 100644 index 0000000000..fa466e9cac --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A1_T9.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.charCodeAt(pos) +es5id: 15.5.4.5_A1_T9 +description: > + Call charCodeAt() function with function(){}() argument of string + object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToInteger(undefined) evaluates to 0 charCodeAt() evaluates to charCodeAt(0) +if (new String(42).charCodeAt(function() {}()) !== 0x34) { + throw new Test262Error('#1: new String(42).charCodeAt(function(){}()) === 0x34. Actual: new String(42).charCodeAt(function(){}()) ===' + new String(42).charCodeAt(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.js new file mode 100644 index 0000000000..e7e04ab7f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + When String.prototype.charCodeAt(pos) calls if ToInteger(pos) less than 0 + the NaN returns +es5id: 15.5.4.5_A2 +description: Call charCodeAt(pos) with negative pos +---*/ + +function __FACTORY() {}; + +__FACTORY.prototype.charCodeAt = String.prototype.charCodeAt; + +var __instance = new __FACTORY; + +assert.sameValue(__instance.charCodeAt(-1), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A3.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A3.js new file mode 100644 index 0000000000..5ac83b6a0a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A3.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: | + When String.prototype.charCodeAt(pos) calls if ToInteger(pos) not less + than ToString(this value) the NaN returns +es5id: 15.5.4.5_A3 +description: pos is bigger of string length +---*/ + +var __instance = new String("ABC"); + +assert.sameValue(__instance.charCodeAt(3), NaN); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A4.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A4.js new file mode 100644 index 0000000000..3b74114d7f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A4.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: | + When String.prototype.charCodeAt(pos) calls first calls ToString, giving + it the this value as its argument +es5id: 15.5.4.5_A4 +description: Change toString function, it trow exception, and call charCodeAt() +---*/ + +var __obj = { + valueOf: 1, + toString: function() { + throw 'intostring' + }, + charCodeAt: String.prototype.charCodeAt +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.charCodeAt(); + throw new Test262Error('#1: "var x = __obj.charCodeAt()" lead to throwing exception'); +} catch (e) { + if (e !== 'intostring') { + throw new Test262Error('#1.1: Exception === \'intostring\'. Actual: exception ===' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A6.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A6.js new file mode 100644 index 0000000000..b5b9cbef8a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt has not prototype property +es5id: 15.5.4.5_A6 +description: Checking String.prototype.charCodeAt.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.charCodeAt.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.charCodeAt.prototype === undefined. Actual: ' + String.prototype.charCodeAt.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A7.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A7.js new file mode 100644 index 0000000000..be97cc320c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.charCodeAt can't be used as constructor +es5id: 15.5.4.5_A7 +description: Checking if creating the String.prototype.charCodeAt object fails +---*/ + +var __FACTORY = String.prototype.charCodeAt; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.charCodeAt; "__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/charCodeAt/S15.5.4.5_A8.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A8.js new file mode 100644 index 0000000000..d62fdb38ba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A8.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: The String.prototype.charCodeAt.length property has the attribute DontEnum +es5id: 15.5.4.5_A8 +description: > + Checking if enumerating the String.prototype.charCodeAt.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.charCodeAt.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.charCodeAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.charCodeAt.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.charCodeAt.propertyIsEnumerable(\'length\') return false. Actual: ' + String.prototype.charCodeAt.propertyIsEnumerable('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.charCodeAt) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.charCodeAt){if (p==="length") count++;} count === 0. Actual: count ===' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A9.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A9.js new file mode 100644 index 0000000000..28876dd07a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/S15.5.4.5_A9.js @@ -0,0 +1,38 @@ +// 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.charCodeAt.length property does not have the + attribute DontDelete +es5id: 15.5.4.5_A9 +description: > + Checking if deleting the String.prototype.charCodeAt.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.charCodeAt.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.charCodeAt.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.charCodeAt.length) { + throw new Test262Error('#1: delete String.prototype.charCodeAt.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.charCodeAt.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.charCodeAt.length; String.prototype.charCodeAt.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.charCodeAt.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/browser.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/name.js new file mode 100644 index 0000000000..9916d17abf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/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.2 +description: > + String.prototype.charCodeAt.name is "charCodeAt". +info: | + String.prototype.charCodeAt ( pos ) + + 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.charCodeAt.name, "charCodeAt"); + +verifyNotEnumerable(String.prototype.charCodeAt, "name"); +verifyNotWritable(String.prototype.charCodeAt, "name"); +verifyConfigurable(String.prototype.charCodeAt, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/not-a-constructor.js new file mode 100644 index 0000000000..282fcb0b55 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/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.charCodeAt 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.charCodeAt), + false, + 'isConstructor(String.prototype.charCodeAt) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.charCodeAt(); +}, '`new String.prototype.charCodeAt()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-err.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-err.js new file mode 100644 index 0000000000..3f30646ab3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-err.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.charcodeat +description: Error when attempting to coerce providec "pos" to a Number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var noCoerce = Object.create(null); + +assert.throws(TypeError, function() { + ''.charCodeAt(noCoerce); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-string.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-string.js new file mode 100644 index 0000000000..8d41a2de81 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-coerce-string.js @@ -0,0 +1,20 @@ +// 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.charcodeat +description: Coercion of "pos" string value into number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). +---*/ + +var cCode = 99; + +assert.sameValue('abcd'.charCodeAt(' +00200.0000E-0002 '), cCode); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-rounding.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-rounding.js new file mode 100644 index 0000000000..577d1e1fc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/pos-rounding.js @@ -0,0 +1,30 @@ +// 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.charcodeat +description: Rounding of the provided "pos" number +info: | + [...] + 3. Let position be ? ToInteger(pos). + [...] + + 7.1.4 ToInteger + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, return +0. + 3. If number is +0, -0, +∞, or -∞, return number. + 4. Return the number value that is the same sign as number and whose + magnitude is floor(abs(number)). +---*/ + +var aCode = 97; +var bCode = 98; + +assert.sameValue('abc'.charCodeAt(-0.99999), aCode, '-0.99999'); +assert.sameValue('abc'.charCodeAt(-0.00001), aCode, '-0.00001'); +assert.sameValue('abc'.charCodeAt(0.00001), aCode, '0.00001'); +assert.sameValue('abc'.charCodeAt(0.99999), aCode, '0.99999'); +assert.sameValue('abc'.charCodeAt(1.00001), bCode, '1.00001'); +assert.sameValue('abc'.charCodeAt(1.99999), bCode, '1.99999'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/shell.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..0215b3ba7d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/charCodeAt/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.charcodeat +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var charCodeAt = String.prototype.charCodeAt; + +assert.sameValue(typeof charCodeAt, 'function'); + +assert.throws(TypeError, function() { + charCodeAt.call(undefined, 0); +}, 'undefined'); + +assert.throws(TypeError, function() { + charCodeAt.call(null, 0); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/browser.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/codePointAt.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/codePointAt.js new file mode 100644 index 0000000000..1838f1e274 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/codePointAt.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Property type and descriptor. +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof String.prototype.codePointAt, + 'function', + '`typeof String.prototype.codePointAt` is `function`' +); + +verifyNotEnumerable(String.prototype, 'codePointAt'); +verifyWritable(String.prototype, 'codePointAt'); +verifyConfigurable(String.prototype, 'codePointAt'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/length.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/length.js new file mode 100644 index 0000000000..99acb42698 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + String.prototype.codePointAt.length value and descriptor. +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.codePointAt.length, 1, + 'The value of `String.prototype.codePointAt.length` is `1`' +); + +verifyNotEnumerable(String.prototype.codePointAt, 'length'); +verifyNotWritable(String.prototype.codePointAt, 'length'); +verifyConfigurable(String.prototype.codePointAt, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/name.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/name.js new file mode 100644 index 0000000000..db3ce58ddc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + String.prototype.codePointAt.name value and descriptor. +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.codePointAt.name, 'codePointAt', + 'The value of `String.prototype.codePointAt.name` is `"codePointAt"`' +); + +verifyNotEnumerable(String.prototype.codePointAt, 'name'); +verifyNotWritable(String.prototype.codePointAt, 'name'); +verifyConfigurable(String.prototype.codePointAt, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/not-a-constructor.js new file mode 100644 index 0000000000..56d31f5280 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/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.codePointAt 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.codePointAt), + false, + 'isConstructor(String.prototype.codePointAt) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.codePointAt(); +}, '`new String.prototype.codePointAt()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-object-pos-to-integer.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-object-pos-to-integer.js new file mode 100644 index 0000000000..354a5d43c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-object-pos-to-integer.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Returns abrupt from ToInteger(pos) +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + 4. Let position be ToInteger(pos). + 5. ReturnIfAbrupt(position). +---*/ + +var o = { + valueOf: function() { + throw new Test262Error(); + } +} + +assert.throws(Test262Error, function() { + 'abc'.codePointAt(o); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-symbol-pos-to-integer.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-symbol-pos-to-integer.js new file mode 100644 index 0000000000..fb59c85a1f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-symbol-pos-to-integer.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Returns abrupt from ToInteger(pos) +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + 4. Let position be ToInteger(pos). + 5. ReturnIfAbrupt(position). +features: [Symbol] +---*/ + +var s = Symbol(1); + +assert.throws(TypeError, function() { + 'abc'.codePointAt(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-this-as-symbol.js new file mode 100644 index 0000000000..ff7613d472 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-this-as-symbol.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Returns abrupt from ToString(this) where this is a Symbol +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol] +---*/ + +var s = Symbol(); + +assert.throws(TypeError, function() { + String.prototype.codePointAt.call(s, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-this.js new file mode 100644 index 0000000000..c83735ca0f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Returns abrupt from ToString(this) +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.codePointAt.call(o, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-code-unit-coerced-position.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-code-unit-coerced-position.js new file mode 100644 index 0000000000..637a6d035d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-code-unit-coerced-position.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Return value on coerced values on ToInteger(position). +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + ... + 4. Let position be ToInteger(pos). + ... + +---*/ + +assert.sameValue('\uD800\uDC00'.codePointAt(''), 65536); +assert.sameValue('\uD800\uDC00'.codePointAt('0'), 65536); +assert.sameValue('\uD800\uDC00'.codePointAt(NaN), 65536); +assert.sameValue('\uD800\uDC00'.codePointAt(false), 65536); +assert.sameValue('\uD800\uDC00'.codePointAt(null), 65536); +assert.sameValue('\uD800\uDC00'.codePointAt(undefined), 65536); +assert.sameValue('\uD800\uDC00'.codePointAt([]), 65536); + +assert.sameValue('\uD800\uDC00'.codePointAt('1'), 56320); +assert.sameValue('\uD800\uDC00'.codePointAt(true), 56320); +assert.sameValue('\uD800\uDC00'.codePointAt([1]), 56320); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-first-code-unit.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-first-code-unit.js new file mode 100644 index 0000000000..dba2e3dc85 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-first-code-unit.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Returns code point of LeadSurrogate if not followed by a valid TrailSurrogate. +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + ... + 8. Let first be the code unit value of the element at index position in the + String S. + 9. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first. + 10. Let second be the code unit value of the element at index position+1 in + the String S. + 11. If second < 0xDC00 or second > 0xDFFF, return first. +---*/ + +assert.sameValue('\uD800\uDBFF'.codePointAt(0), 0xD800); +assert.sameValue('\uD800\uE000'.codePointAt(0), 0xD800); + +assert.sameValue('\uDAAA\uDBFF'.codePointAt(0), 0xDAAA); +assert.sameValue('\uDAAA\uE000'.codePointAt(0), 0xDAAA); + +assert.sameValue('\uDBFF\uDBFF'.codePointAt(0), 0xDBFF); +assert.sameValue('\uDBFF\uE000'.codePointAt(0), 0xDBFF); + +assert.sameValue('\uD800\u0000'.codePointAt(0), 0xD800); +assert.sameValue('\uD800\uFFFF'.codePointAt(0), 0xD800); + +assert.sameValue('\uDAAA\u0000'.codePointAt(0), 0xDAAA); +assert.sameValue('\uDAAA\uFFFF'.codePointAt(0), 0xDAAA); + +assert.sameValue('\uDBFF\uDBFF'.codePointAt(0), 0xDBFF); +assert.sameValue('\uDBFF\uFFFF'.codePointAt(0), 0xDBFF); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-single-code-unit.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-single-code-unit.js new file mode 100644 index 0000000000..b37fe8bab0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-single-code-unit.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Return single code unit value of the element at index position. +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + 4. Let position be ToInteger(pos). + 5. ReturnIfAbrupt(position). + 6. Let size be the number of elements in S. + 7. If position < 0 or position ≥ size, return undefined. + 8. Let first be the code unit value of the element at index position in the + String S. + 9. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first. +---*/ + +assert.sameValue('abc'.codePointAt(0), 97); +assert.sameValue('abc'.codePointAt(1), 98); +assert.sameValue('abc'.codePointAt(2), 99); + +assert.sameValue('\uAAAA\uBBBB'.codePointAt(0), 0xAAAA); +assert.sameValue('\uD7FF\uAAAA'.codePointAt(0), 0xD7FF); +assert.sameValue('\uDC00\uAAAA'.codePointAt(0), 0xDC00); +assert.sameValue('\uAAAA\uBBBB'.codePointAt(0), 0xAAAA); + +assert.sameValue('123\uD800'.codePointAt(3), 0xD800); +assert.sameValue('123\uDAAA'.codePointAt(3), 0xDAAA); +assert.sameValue('123\uDBFF'.codePointAt(3), 0xDBFF); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-utf16-decode.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-utf16-decode.js new file mode 100644 index 0000000000..42620b6277 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/return-utf16-decode.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Return UTF16 Decode value of the lead and trail elements at index position. +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + ... + 8. Let first be the code unit value of the element at index position in the + String S. + 9. If first < 0xD800 or first > 0xDBFF or position+1 = size, return first. + 10. Let second be the code unit value of the element at index position+1 in + the String S. + 11. If second < 0xDC00 or second > 0xDFFF, return first. + 12. Return UTF16Decode(first, second). + + 10.1.2 Static Semantics: UTF16Decode( lead, trail ) + + Two code units, lead and trail, that form a UTF-16 surrogate pair are + converted to a code point by performing the following steps: + + 1. Assert: 0xD800 ≤ lead ≤ 0xDBFF and 0xDC00 ≤ trail ≤ 0xDFFF. + 2. Let cp be (lead – 0xD800) × 1024 + (trail – 0xDC00) + 0x10000. + 3. Return the code point cp. +---*/ + +assert.sameValue('\uD800\uDC00'.codePointAt(0), 65536, 'U+10000'); +assert.sameValue('\uD800\uDDD0'.codePointAt(0), 66000, 'U+101D0'); +assert.sameValue('\uD800\uDFFF'.codePointAt(0), 66559, 'U+103FF'); + +assert.sameValue('\uDAAA\uDC00'.codePointAt(0), 763904, 'U+BA800'); +assert.sameValue('\uDAAA\uDDD0'.codePointAt(0), 764368, 'U+BA9D0'); +assert.sameValue('\uDAAA\uDFFF'.codePointAt(0), 764927, 'U+BABFF'); + +assert.sameValue('\uDBFF\uDC00'.codePointAt(0), 1113088, 'U+10FC00'); +assert.sameValue('\uDBFF\uDDD0'.codePointAt(0), 1113552, 'U+10FDD0'); +assert.sameValue('\uDBFF\uDFFF'.codePointAt(0), 1114111, 'U+10FFFF'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/returns-undefined-on-position-equal-or-more-than-size.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/returns-undefined-on-position-equal-or-more-than-size.js new file mode 100644 index 0000000000..57cf03d817 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/returns-undefined-on-position-equal-or-more-than-size.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + If pos >= size, return undefined +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + 4. Let position be ToInteger(pos). + 5. ReturnIfAbrupt(position). + 6. Let size be the number of elements in S. + 7. If position < 0 or position ≥ size, return undefined. +---*/ + +assert.sameValue('abc'.codePointAt(3), undefined); +assert.sameValue('abc'.codePointAt(4), undefined); +assert.sameValue('abc'.codePointAt(Infinity), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/returns-undefined-on-position-less-than-zero.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/returns-undefined-on-position-less-than-zero.js new file mode 100644 index 0000000000..087909a08e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/returns-undefined-on-position-less-than-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + If pos < size, return undefined +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + 4. Let position be ToInteger(pos). + 5. ReturnIfAbrupt(position). + 6. Let size be the number of elements in S. + 7. If position < 0 or position ≥ size, return undefined. +---*/ + +assert.sameValue('abc'.codePointAt(-1), undefined); +assert.sameValue('abc'.codePointAt(-Infinity), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/shell.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/this-is-null-throws.js new file mode 100644 index 0000000000..d6a23b7b6a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/this-is-null-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Throws TypeError when `this` is null +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.codePointAt.call(null, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/codePointAt/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/codePointAt/this-is-undefined-throws.js new file mode 100644 index 0000000000..edc798df09 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/codePointAt/this-is-undefined-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.3 +description: > + Throws TypeError when `this` is undefined +info: | + 21.1.3.3 String.prototype.codePointAt ( pos ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.codePointAt.call(undefined, 1); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A10.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A10.js new file mode 100644 index 0000000000..c51f6ecdd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A10.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: The String.prototype.concat.length property has the attribute ReadOnly +es5id: 15.5.4.6_A10 +description: > + Checking if varying the String.prototype.concat.length property + fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.concat.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.concat.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.concat.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.concat.length; + +verifyNotWritable(String.prototype.concat, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.concat.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.concat.length; String.prototype.concat.length = function(){return "shifted";}; String.prototype.concat.length === __obj. Actual: ' + String.prototype.concat.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A11.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A11.js new file mode 100644 index 0000000000..27347f1f1a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A11.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 length property of the concat method is 1 +es5id: 15.5.4.6_A11 +description: Checking String.prototype.concat.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.concat.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.concat.hasOwnProperty("length") return true. Actual: ' + String.prototype.concat.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.concat.length !== 1) { + throw new Test262Error('#2: String.prototype.concat.length === 1. Actual: ' + String.prototype.concat.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T1.js new file mode 100644 index 0000000000..b1d3528276 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat([,[...]]) +es5id: 15.5.4.6_A1_T1 +description: Arguments are false and true, and instance is object +---*/ + +var __instance = new Object(42); + +__instance.concat = String.prototype.concat; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.concat(false, true) !== "42falsetrue") { + throw new Test262Error('#1: __instance = new Object(42); __instance.concat = String.prototype.concat; __instance.concat(false,true) === "42falsetrue". Actual: ' + __instance.concat(false, true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T10.js new file mode 100644 index 0000000000..85b6805c04 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T10.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.concat([,[...]]) +es5id: 15.5.4.6_A1_T10 +description: Call concat([,[...]]) function with object arguments +---*/ + +var __obj = { + toString: function() { + return "\u0041"; + }, + valueOf: function() { + return "_\u0041_"; + } +} +var __obj2 = { + toString: function() { + return true; + } +} +var __obj3 = { + toString: function() { + return 42; + } +} +var __str = "lego"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.concat(__obj) !== "legoA") { + throw new Test262Error('#1: var x; var __obj = {toString:function(){return "\u0041";}, valueOf:function(){return "_\u0041_";}}; var __str = "lego"; __str.concat(__obj) === "legoA". Actual: ' + __str.concat(__obj)); +} +if (__str.concat(__obj, __obj2, __obj3, x) !== "legoAtrue42undefined") { + throw new Test262Error('#2: var x; var __obj = {toString:function(){return "\u0041";}, valueOf:function(){return "_\u0041_";}}; var __obj2 = {toString:function(){return true;}}; var __obj3 = {toString:function(){return 42;}}; var __str = "lego"; __str.concat(__obj, __obj2, __obj3, x) === "legoAtrue42undefined". Actual: ' + __str.concat(__obj, __obj2, __obj3, x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T2.js new file mode 100644 index 0000000000..72c9c7d2df --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T2.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat([,[...]]) +es5id: 15.5.4.6_A1_T2 +description: > + Arguments are equation with false and true, and instance is + Boolean object +---*/ + +var __instance = new Boolean; + +__instance.concat = String.prototype.concat; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.concat("\u0041", true, true + 1) !== "falseAtrue2") { + throw new Test262Error('#1: __instance = new Boolean; __instance.concat = String.prototype.concat; __instance.concat("\\u0041",true,true+1) === "falseAtrue2". Actual: ' + __instance.concat("\u0041", true, true + 1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T4.js new file mode 100644 index 0000000000..cbc64804f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T4.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat([,[...]]) +es5id: 15.5.4.6_A1_T4 +description: Call concat([,[...]]) function without argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString() evaluates to "" concat() evaluates to concat("") +if ("lego".concat() !== "lego") { + throw new Test262Error('#1: "lego".concat() === "lego". Actual: ' + ("lego".concat())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T5.js new file mode 100644 index 0000000000..492f6d8772 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T5.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat([,[...]]) +es5id: 15.5.4.6_A1_T5 +description: > + Call concat([,[...]]) function with null argument of function + object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" concat(null) evaluates to concat("null") +if (function() { + return "lego" + }().concat(null) !== "legonull") { + throw new Test262Error('#1: function(){return "lego"}().concat(null) === "legonull". Actual: ' + function() { + return "lego" + }().concat(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T6.js new file mode 100644 index 0000000000..ab6cc06c17 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat([,[...]]) +es5id: 15.5.4.6_A1_T6 +description: > + Call concat([,[...]]) function with x argument of new String + object, where x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" concat(undefined) evaluates to concat("undefined") +if (new String("lego").concat(x) !== "legoundefined") { + throw new Test262Error('#1: var x; new String("lego").concat(x) === "legoundefined". Actual: ' + new String("lego").concat(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T7.js new file mode 100644 index 0000000000..b3ba0109ad --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T7.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.concat([,[...]]) +es5id: 15.5.4.6_A1_T7 +description: > + Call concat([,[...]]) function with undefined argument of string + object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" concat(undefined) evaluates to concat("undefined") +if (String("lego").concat(undefined) !== "legoundefined") { + throw new Test262Error('#1: String("lego").concat(undefined) === "legoundefined". Actual: ' + String("lego").concat(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T8.js new file mode 100644 index 0000000000..7eae3fd440 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T8.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.concat([,[...]]) +es5id: 15.5.4.6_A1_T8 +description: > + Call concat([,[...]]) function with void 0 argument of string + object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(void 0) evaluates to "undefined" concat(void 0) evaluates to concat("undefined") +if (String(42).concat(void 0) !== "42undefined") { + throw new Test262Error('#1: String(42).concat(void 0) === "42undefined". Actual: ' + String(42).concat(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T9.js new file mode 100644 index 0000000000..7a49043e8e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A1_T9.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.concat([,[...]]) +es5id: 15.5.4.6_A1_T9 +description: > + Call concat([,[...]]) function with function(){}() argument of + string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" concat(undefined) evaluates to concat("undefined") +if (new String(42).concat(function() {}()) !== "42undefined") { + throw new Test262Error('#1: new String(42).concat(function(){}()) === "42undefined". Actual: ' + new String(42).concat(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A2.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A2.js new file mode 100644 index 0000000000..08f96a9b8c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A2.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.concat([,[...]]) can accept at least 128 +es5id: 15.5.4.6_A2 +description: Call concat([,[...]]) function with 128 arguments +---*/ + +var __instance = new Number(); + +__instance.concat = String.prototype.concat; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.concat( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF + ) !== "001234567891011121314150123456789101112131415012345678910111213141501234567891011121314150123456789101112131415012345678910111213141501234567891011121314150123456789101112131415") { + throw new Test262Error('#1: Call concat([,[...]]) function with 128 arguments does not lead to throwing any errors'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A3.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A3.js new file mode 100644 index 0000000000..91034b8756 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat([,[...]]) can't change the instance to be applied +es5id: 15.5.4.6_A3 +description: Checking if varying the instance that is applied fails +---*/ + +var __instance = new String("one"); + +__instance.concat("two"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance != "one") { + throw new Test262Error('#1: __instance = new String("one"); __instance.concat("two"); __instance = new String("one"); __instance.concat("two"); __instance == "one". Actual: ' + __instance); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A4_T1.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A4_T1.js new file mode 100644 index 0000000000..1cbb6fbcb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A4_T1.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: | + when String.prototype.concat([,[...]]) is called first Call ToString, + giving it the this value as its argument +es5id: 15.5.4.6_A4_T1 +description: Override toString function +---*/ + +var __instance = { + toString: function() { + return "one" + } +}; + +__instance.concat = String.prototype.concat; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.concat("two", x) !== "onetwoundefined") { + throw new Test262Error('#1: var x; __instance = {toString:function(){return "one"}}; __instance.concat = String.prototype.concat; __instance.concat("two",x) === "onetwoundefined". Actual: ' + __instance.concat("two", x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A4_T2.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A4_T2.js new file mode 100644 index 0000000000..3a965d4e5a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A4_T2.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.concat([,[...]]) is called first Call ToString, + giving it the this value as its argument +es5id: 15.5.4.6_A4_T2 +description: Override toString function onto function, that throw exception +---*/ + +var __instance = { + toString: function() { + throw "intostring"; + } +}; +var __obj = { + toString: function() { + throw "infirstarg"; + } +}; + +__instance.concat = String.prototype.concat; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + String.prototype.concat.call(__instance, __obj, notexist); + throw new Test262Error('#1: "String.prototype.concat.call(__instance,__obj, notexist)" lead to throwing exception'); +} catch (e) { + if (e !== "intostring") { + throw new Test262Error('#1: e === "intostring". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +var notexist; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A6.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A6.js new file mode 100644 index 0000000000..65fa01265f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat has not prototype property +es5id: 15.5.4.6_A6 +description: Checking String.prototype.concat.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.concat.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.concat.prototype === undefined. Actual: ' + String.prototype.concat.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A7.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A7.js new file mode 100644 index 0000000000..05838ed864 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.concat can't be used as constructor +es5id: 15.5.4.6_A7 +description: Checking if creating the String.prototype.concat object fails +---*/ + +var __FACTORY = String.prototype.concat; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.concat; "__instance = new __FACTORY" lead throwing exception'); +} catch (e) { + if (e instanceof Test262Error) throw e; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A8.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A8.js new file mode 100644 index 0000000000..dee8d4c810 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A8.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: The String.prototype.concat.length property has the attribute DontEnum +es5id: 15.5.4.6_A8 +description: > + Checking if enumerating the String.prototype.concat.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.concat.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.concat.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.concat.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.concat.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.concat.propertyIsEnumerable(\'length\') return false. Actual: ' + String.prototype.concat.propertyIsEnumerable('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.concat) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count = 0; for (p in String.prototype.concat){ if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A9.js b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A9.js new file mode 100644 index 0000000000..16a29b87ae --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/S15.5.4.6_A9.js @@ -0,0 +1,38 @@ +// 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.concat.length property does not have the attribute + DontDelete +es5id: 15.5.4.6_A9 +description: > + Checking if deleting the String.prototype.concat.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.concat.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.concat.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.concat.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.concat.length) { + throw new Test262Error('#1: delete String.prototype.concat.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.concat.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.concat.length; String.prototype.concat.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.concat.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/browser.js b/js/src/tests/test262/built-ins/String/prototype/concat/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/name.js b/js/src/tests/test262/built-ins/String/prototype/concat/name.js new file mode 100644 index 0000000000..6a4181b098 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/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.4 +description: > + String.prototype.concat.name is "concat". +info: | + String.prototype.concat ( ...args ) + + 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.concat.name, "concat"); + +verifyNotEnumerable(String.prototype.concat, "name"); +verifyNotWritable(String.prototype.concat, "name"); +verifyConfigurable(String.prototype.concat, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/concat/not-a-constructor.js new file mode 100644 index 0000000000..e0287c912b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/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.concat 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.concat), + false, + 'isConstructor(String.prototype.concat) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.concat(); +}, '`new String.prototype.concat()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/shell.js b/js/src/tests/test262/built-ins/String/prototype/concat/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/concat/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/concat/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..eeb652c710 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/concat/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.concat +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var concat = String.prototype.concat; + +assert.sameValue(typeof concat, 'function'); + +assert.throws(TypeError, function() { + concat.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + concat.call(null, ''); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/constructor/S15.5.4.1_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/constructor/S15.5.4.1_A1_T1.js new file mode 100644 index 0000000000..44d4457ee7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/constructor/S15.5.4.1_A1_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The initial value of String.prototype.constructor is the built-in String + constructor +es5id: 15.5.4.1_A1_T1 +description: Checking String.prototype.constructor +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.constructor !== String) { + throw new Test262Error('#1: String.prototype.constructor === String. Actual: String.prototype.constructor ===' + String.prototype.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/constructor/S15.5.4.1_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/constructor/S15.5.4.1_A1_T2.js new file mode 100644 index 0000000000..9db613da7f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/constructor/S15.5.4.1_A1_T2.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The initial value of String.prototype.constructor is the built-in String + constructor +es5id: 15.5.4.1_A1_T2 +description: Create new String.prototype.constructor object and check it +---*/ + +var __constr = String.prototype.constructor; + +var __instance = new __constr("choosing one"); + +////////////////////////////////////////////////////////////////////////////// +// CHECK#0 +if (__instance != "choosing one") { + throw new Test262Error('#0: __constr = String.prototype.constructor; __instance = new __constr("choosing one"); __instance =="choosing one". Actual: __instance ==' + __instance); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (__instance.constructor !== String) { + throw new Test262Error('#1: __constr = String.prototype.constructor; __instance = new __constr("choosing one"); __instance.constructor === String. Actual: __instance.constructor ===' + __instance.constructor); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +if (!(String.prototype.isPrototypeOf(__instance))) { + throw new Test262Error('#2: __constr = String.prototype.constructor; __instance = new __constr("choosing one"); String.prototype.isPrototypeOf(__instance) return true. Actual: ' + String.prototype.isPrototypeOf(__instance)); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#3 +var __to_string_result = '[object ' + 'String' + ']'; + +delete String.prototype.toString; + +if (__instance.toString() !== __to_string_result) { + throw new Test262Error('#3: __constr = String.prototype.constructor; __instance = new __constr("choosing one"); delete String.prototype.toString; __instance.toString() === __to_string_result. Actual: __instance.toString() ===' + __instance.toString() + ' __to_string_result ===' + __to_string_result); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/constructor/browser.js b/js/src/tests/test262/built-ins/String/prototype/constructor/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/constructor/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/constructor/shell.js b/js/src/tests/test262/built-ins/String/prototype/constructor/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/constructor/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Fail.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Fail.js new file mode 100644 index 0000000000..6c130e2297 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Fail.js @@ -0,0 +1,12 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: endsWith should return false when called on 'word' and passed 'r'. +features: [String.prototype.endsWith] +---*/ + +assert.sameValue('word'.endsWith('r'), false, '"word".endsWith("r")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Fail_2.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Fail_2.js new file mode 100644 index 0000000000..18e2ddd4e6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Fail_2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + endsWith should return false when called on 'word' and passed 'd', + with an endPosition of 3. +features: [String.prototype.endsWith] +---*/ + +assert.sameValue('word'.endsWith('d', 3), false, '"word".endsWith("d", 3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success.js new file mode 100644 index 0000000000..1d58e3a9fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + endsWith should return true when called on 'word' and passed 'd' + and with no endPosition (defaults to 4). +features: [String.prototype.endsWith] +---*/ + +assert.sameValue('word'.endsWith('d'), true, '"word".endsWith("d")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_2.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_2.js new file mode 100644 index 0000000000..03b97f024e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + endsWith should return true when called on 'word' and passed 'd' + and with an endPosition of 4. +features: [String.prototype.endsWith] +---*/ + +assert.sameValue('word'.endsWith('d', 4), true, '"word".endsWith("d", 4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_3.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_3.js new file mode 100644 index 0000000000..9d2a03a672 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + endsWith should return true when called on 'word' and passed 'd' + and with an endPosition of 25. +features: [String.prototype.endsWith] +---*/ + +assert.sameValue('word'.endsWith('d', 25), true, '"word".endsWith("d", 25)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_4.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_4.js new file mode 100644 index 0000000000..19956fc76d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/String.prototype.endsWith_Success_4.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + endsWith should return true when called on 'word' and passed 'r', + with an endPosition of 3. +features: [String.prototype.endsWith] +---*/ + +assert.sameValue('word'.endsWith('r', 3), true, '"word".endsWith("r", 3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/browser.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/coerced-values-of-position.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/coerced-values-of-position.js new file mode 100644 index 0000000000..5b8ce9acd7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/coerced-values-of-position.js @@ -0,0 +1,39 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns based on coerced values of endPosition. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + 12. Let end be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. Let start be end - searchLength. + 15. If start is less than 0, return false. + 16. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + 17. Otherwise, return false. + ... +features: [String.prototype.endsWith] +---*/ + +var str = 'The future is cool!'; + +assert(str.endsWith('', NaN), 'NaN coerced to 0'); +assert(str.endsWith('', null), 'null coerced to 0'); +assert(str.endsWith('', false), 'false coerced to 0'); +assert(str.endsWith('', ''), '"" coerced to 0'); +assert(str.endsWith('', '0'), '"0" coerced to 0'); +assert(str.endsWith('', undefined), 'undefined coerced to 0'); + +assert(str.endsWith('The future', 10.4), '10.4 coerced to 10'); +assert(str.endsWith('T', true), 'true coerced to 1'); + +assert(str.endsWith('The future', '10'), '"10" coerced to 10'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/endsWith.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/endsWith.js new file mode 100644 index 0000000000..e33b121a23 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/endsWith.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Property type and descriptor. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.endsWith] +---*/ + +assert.sameValue( + typeof String.prototype.endsWith, + 'function', + '`typeof String.prototype.endsWith` is `function`' +); + +verifyNotEnumerable(String.prototype, 'endsWith'); +verifyWritable(String.prototype, 'endsWith'); +verifyConfigurable(String.prototype, 'endsWith'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/length.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/length.js new file mode 100644 index 0000000000..d5040bab96 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/length.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + String.prototype.endsWith.length value and descriptor. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + The length property of the endsWith method is 1. + +includes: [propertyHelper.js] +features: [String.prototype.endsWith] +---*/ + +assert.sameValue( + String.prototype.endsWith.length, 1, + 'The value of `String.prototype.endsWith.length` is `1`' +); + +verifyNotEnumerable(String.prototype.endsWith, 'length'); +verifyNotWritable(String.prototype.endsWith, 'length'); +verifyConfigurable(String.prototype.endsWith, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/name.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/name.js new file mode 100644 index 0000000000..d4aa6ee5f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/name.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + String.prototype.endsWith.name value and descriptor. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.endsWith] +---*/ + +assert.sameValue( + String.prototype.endsWith.name, 'endsWith', + 'The value of `String.prototype.endsWith.name` is `"endsWith"`' +); + +verifyNotEnumerable(String.prototype.endsWith, 'name'); +verifyNotWritable(String.prototype.endsWith, 'name'); +verifyConfigurable(String.prototype.endsWith, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/not-a-constructor.js new file mode 100644 index 0000000000..2112ea842d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/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.endsWith 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, String.prototype.endsWith, arrow-function] +---*/ + +assert.sameValue( + isConstructor(String.prototype.endsWith), + false, + 'isConstructor(String.prototype.endsWith) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.endsWith(); +}, '`new String.prototype.endsWith()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-position-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-position-as-symbol.js new file mode 100644 index 0000000000..6c035f420e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-position-as-symbol.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns abrupt from ToInteger(endPosition) as a Symbol. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + ... +features: [Symbol, String.prototype.endsWith] +---*/ + +var position = Symbol(); + +assert.throws(TypeError, function() { + ''.endsWith('', position); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-position.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-position.js new file mode 100644 index 0000000000..86c26233a1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-position.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns abrupt from ToInteger(endPosition). +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + ... +features: [String.prototype.endsWith] +---*/ + +var position = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.endsWith('', position); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-as-symbol.js new file mode 100644 index 0000000000..33e6cf455a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-as-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns abrupt from ToString(searchString) as a Symbol +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 7. Let searchStr be ToString(searchString). + 8. ReturnIfAbrupt(searchStr). + ... +features: [Symbol, String.prototype.endsWith] +---*/ + +var s = Symbol(); + +assert.throws(TypeError, function() { + ''.endsWith(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js new file mode 100644 index 0000000000..165b14f6f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring-regexp-test.js @@ -0,0 +1,44 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns abrupt from IsRegExp(searchString). +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 4. Let isRegExp be IsRegExp(searchString). + 5. ReturnIfAbrupt(isRegExp). + ... + + 7.2.8 IsRegExp ( argument ) + + 2. Let isRegExp be Get(argument, @@match). + 3. ReturnIfAbrupt(isRegExp). +features: [Symbol.match, String.prototype.endsWith] +---*/ + +var obj = {}; +Object.defineProperty(obj, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.endsWith(obj); +}); + +var regexp = /./; +Object.defineProperty(regexp, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.endsWith(regexp); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring.js new file mode 100644 index 0000000000..915803e6b6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-searchstring.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns abrupt from ToString(searchString) +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 7. Let searchStr be ToString(searchString). + 8. ReturnIfAbrupt(searchStr). + ... +features: [String.prototype.endsWith] +---*/ + +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.endsWith(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-this-as-symbol.js new file mode 100644 index 0000000000..8930406092 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-this-as-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns abrupt from ToString(this) where this is a Symbol +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). + ... +features: [Symbol, String.prototype.endsWith] +---*/ + +var s = Symbol(''); + +assert.throws(TypeError, function() { + String.prototype.endsWith.call(s, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-this.js new file mode 100644 index 0000000000..5ad458c006 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-abrupt-from-this.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. +/*--- +es6id: 21.1.3.6 +description: > + Returns abrupt from ToString(this) +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [String.prototype.endsWith] +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.endsWith.call(o, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-false-if-search-start-is-less-than-zero.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-false-if-search-start-is-less-than-zero.js new file mode 100644 index 0000000000..37ec778399 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-false-if-search-start-is-less-than-zero.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns false if search start is less than 0. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 9. Let len be the number of elements in S. + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + 12. Let end be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. Let start be end - searchLength. + 15. If start is less than 0, return false. + ... + + Note: (min(max(pos, 0), len) - searchString.length) < 0; +features: [String.prototype.endsWith] +---*/ + +assert.sameValue( + 'web'.endsWith('w', 0), false, + '"web".endsWith("w", 0) returns false' +); + +assert.sameValue( + 'Bob'.endsWith(' Bob'), false, + '"Bob".endsWith(" Bob") returns false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/return-true-if-searchstring-is-empty.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-true-if-searchstring-is-empty.js new file mode 100644 index 0000000000..1871492039 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/return-true-if-searchstring-is-empty.js @@ -0,0 +1,51 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns true if searchString.length == 0. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + 12. Let end be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. Let start be end - searchLength. + 15. If start is less than 0, return false. + 16. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + ... +features: [String.prototype.endsWith] +---*/ + +var str = 'The future is cool!'; + +assert( + str.endsWith(''), + 'str.endsWith("") returns true' +); + +assert( + str.endsWith('', str.length), + 'str.endsWith("", str.length) returns true' +); + +assert( + str.endsWith('', Infinity), + 'str.endsWith("", Infinity) returns true' +); + +assert( + str.endsWith('', -1), + 'str.endsWith("", -1) returns true' +); + +assert( + str.endsWith('', -Infinity), + 'str.endsWith("", -Infinity) returns true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-found-with-position.js new file mode 100644 index 0000000000..0c0445e1fe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-found-with-position.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns true if searchString appears as a substring of the given string with a + given position. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + 12. Let end be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. Let start be end - searchLength. + 15. If start is less than 0, return false. + 16. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + ... +features: [String.prototype.endsWith] +---*/ + +var str = 'The future is cool!'; + +assert( + str.endsWith('The future', 10), + 'str.endsWith("The future", 10) === true' +); +assert( + str.endsWith('future', 10), + 'str.endsWith("future", 10) === true' +); +assert( + str.endsWith(' is cool!', str.length), + 'str.endsWith(" is cool!", str.length) === true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-found-without-position.js new file mode 100644 index 0000000000..3eabfafb4d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-found-without-position.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns true if searchString appears as a substring of the given string. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + 12. Let end be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. Let start be end - searchLength. + 15. If start is less than 0, return false. + 16. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + ... +features: [String.prototype.endsWith] +---*/ + +var str = 'The future is cool!'; + +assert(str.endsWith('cool!'), 'str.endsWith("cool!") === true'); +assert(str.endsWith('!'), 'str.endsWith("!") === true'); +assert(str.endsWith(str), 'str.endsWith(str) === true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-is-regexp-throws.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-is-regexp-throws.js new file mode 100644 index 0000000000..8cdf821300 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-is-regexp-throws.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Throws a TypeError if searchString is a RegExp. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 4. Let isRegExp be IsRegExp(searchString). + 5. ReturnIfAbrupt(isRegExp). + 6. If isRegExp is true, throw a TypeError exception. + ... +features: [String.prototype.endsWith] +---*/ + +var searchString = /./; + +assert.throws(TypeError, function() { + ''.endsWith(searchString); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-not-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-not-found-with-position.js new file mode 100644 index 0000000000..cf7bb58854 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-not-found-with-position.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns false if searchString is not found with a given position. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + 12. Let end be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. Let start be end - searchLength. + 15. If start is less than 0, return false. + 16. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + 17. Otherwise, return false. + ... +features: [String.prototype.endsWith] +---*/ + +var str = 'The future is cool!'; + +assert.sameValue( + str.endsWith('is cool!', str.length - 1), false, + 'str.endsWith("is cool!", str.length - 1) === false' +); + +assert.sameValue( + str.endsWith('!', 1), false, + 'str.endsWith("!", 1) === false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-not-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-not-found-without-position.js new file mode 100644 index 0000000000..58e6f1f63a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/searchstring-not-found-without-position.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Returns false if searchString is not found. +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + ... + 10. If endPosition is undefined, let pos be len, else let pos be + ToInteger(endPosition). + 11. ReturnIfAbrupt(pos). + 12. Let end be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. Let start be end - searchLength. + 15. If start is less than 0, return false. + 16. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + 17. Otherwise, return false. + ... +features: [String.prototype.endsWith] +---*/ + +var str = 'The future is cool!'; + +assert.sameValue( + str.endsWith('is Flash!'), false, + 'str.endsWith("is Flash!") === false' +); +assert.sameValue( + str.endsWith('IS COOL!'), false, + 'endsWith is case sensitive' +); +assert.sameValue( + str.endsWith('The future'), false, + 'str.endsWith("The future") === false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/shell.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/this-is-null-throws.js new file mode 100644 index 0000000000..7828dd9e71 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/this-is-null-throws.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Throws TypeError when `this` is null +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +features: [String.prototype.endsWith] +---*/ + +assert.throws(TypeError, function() { + String.prototype.endsWith.call(null, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/endsWith/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/endsWith/this-is-undefined-throws.js new file mode 100644 index 0000000000..f0b95cd90a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/endsWith/this-is-undefined-throws.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.6 +description: > + Throws TypeError when `this` is undefined +info: | + 21.1.3.6 String.prototype.endsWith ( searchString [ , endPosition] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +features: [String.prototype.endsWith] +---*/ + +assert.throws(TypeError, function() { + String.prototype.endsWith.call(undefined, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailBadLocation.js b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailBadLocation.js new file mode 100644 index 0000000000..73876d5392 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailBadLocation.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + String should return false if a location is passed that is + greather than the length of the string. +features: [String.prototype.includes] +---*/ + +assert.sameValue('word'.includes('w', 5), false, '"word".includes("w", 5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailLocation.js b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailLocation.js new file mode 100644 index 0000000000..e8415f3e1e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailLocation.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + String should return false if a letter is not found in the word + starting from the passed location. +features: [String.prototype.includes] +---*/ + +assert.sameValue('word'.includes('o', 3), false, '"word".includes("o", 3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailMissingLetter.js b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailMissingLetter.js new file mode 100644 index 0000000000..c9eb1245a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_FailMissingLetter.js @@ -0,0 +1,12 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: String should return false if a letter is not found in the word. +features: [String.prototype.includes] +---*/ + +assert.sameValue('word'.includes('a', 0), false, '"word".includes("a", 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_Success.js b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_Success.js new file mode 100644 index 0000000000..1651d00988 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_Success.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + String should return true when called on 'word' and passed 'w' and + the location 0. +features: [String.prototype.includes] +---*/ + +assert.sameValue('word'.includes('w', 0), true, '"word".includes("w", 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_SuccessNoLocation.js b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_SuccessNoLocation.js new file mode 100644 index 0000000000..49551f6ab7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_SuccessNoLocation.js @@ -0,0 +1,14 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: > + String should return true when called on 'word' and passed 'w' and + with no location (defaults to 0). +features: [String.prototype.includes] +---*/ + +assert.sameValue('word'.includes('w'), true, '"word".includes("w")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_lengthProp.js b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_lengthProp.js new file mode 100644 index 0000000000..b268186511 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/String.prototype.includes_lengthProp.js @@ -0,0 +1,11 @@ +// Copyright (c) 2014 Ryan Lewis. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ryan Lewis +description: String should have the property length with size of 1. +features: [String.prototype.includes] +---*/ +assert.sameValue('word'.includes.length, 1, '"word".includes.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/browser.js b/js/src/tests/test262/built-ins/String/prototype/includes/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/coerced-values-of-position.js b/js/src/tests/test262/built-ins/String/prototype/includes/coerced-values-of-position.js new file mode 100644 index 0000000000..5976cde337 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/coerced-values-of-position.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns based on coerced values of position. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 9. Let pos be ToInteger(position). (If position is undefined, this step + produces the value 0). + 10. ReturnIfAbrupt(pos). + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLen be the number of elements in searchStr. + 14. If there exists any integer k not smaller than start such that k + + searchLen is not greater than len, and for all nonnegative integers j less + than searchLen, the code unit at index k+j of S is the same as the code unit + at index j of searchStr, return true; but if there is no such integer k, + return false. + ... +features: [String.prototype.includes] +---*/ + +var str = 'The future is cool!'; + +assert(str.includes('The future', NaN), 'NaN coerced to 0'); +assert(str.includes('The future', null), 'null coerced to 0'); +assert(str.includes('The future', false), 'false coerced to 0'); +assert(str.includes('The future', ''), '"" coerced to 0'); +assert(str.includes('The future', '0'), '"0" coerced to 0'); +assert(str.includes('The future', undefined), 'undefined coerced to 0'); +assert(str.includes('The future', 0.4), '0.4 coerced to 0'); + +assert(str.includes('The future', -1)); + +assert.sameValue(str.includes('The future', true), false, 'true coerced to 1'); +assert.sameValue(str.includes('The future', '1'), false, '"1" coerced to 1'); +assert.sameValue(str.includes('The future', 1.4), false, '1.4 coerced to 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/includes.js b/js/src/tests/test262/built-ins/String/prototype/includes/includes.js new file mode 100644 index 0000000000..e155f7effa --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/includes.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Property type and descriptor. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.includes] +---*/ + +assert.sameValue( + typeof String.prototype.includes, + 'function', + '`typeof String.prototype.includes` is `function`' +); + +verifyNotEnumerable(String.prototype, 'includes'); +verifyWritable(String.prototype, 'includes'); +verifyConfigurable(String.prototype, 'includes'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/length.js b/js/src/tests/test262/built-ins/String/prototype/includes/length.js new file mode 100644 index 0000000000..c74ad3f706 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/length.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + String.prototype.includes.length value and descriptor. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.includes] +---*/ + +assert.sameValue( + String.prototype.includes.length, 1, + 'The value of `String.prototype.includes.length` is `1`' +); + +verifyNotEnumerable(String.prototype.includes, 'length'); +verifyNotWritable(String.prototype.includes, 'length'); +verifyConfigurable(String.prototype.includes, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/name.js b/js/src/tests/test262/built-ins/String/prototype/includes/name.js new file mode 100644 index 0000000000..24bf088db4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/name.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + String.prototype.includes.name value and descriptor. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.includes] +---*/ + +assert.sameValue( + String.prototype.includes.name, 'includes', + 'The value of `String.prototype.includes.name` is `"includes"`' +); + +verifyNotEnumerable(String.prototype.includes, 'name'); +verifyNotWritable(String.prototype.includes, 'name'); +verifyConfigurable(String.prototype.includes, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/includes/not-a-constructor.js new file mode 100644 index 0000000000..f276a53f92 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/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.includes 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.includes), + false, + 'isConstructor(String.prototype.includes) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.includes(1); +}, '`new String.prototype.includes(1)` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-position-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-position-as-symbol.js new file mode 100644 index 0000000000..9b54287580 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-position-as-symbol.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns abrupt from ToInteger(position) as a Symbol. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 9. Let pos be ToInteger(position). (If position is undefined, this step + produces the value 0). + 10. ReturnIfAbrupt(pos). + ... +features: [Symbol, String.prototype.includes] +---*/ + +var position = Symbol(); + +assert.throws(TypeError, function() { + ''.includes('', position); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-position.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-position.js new file mode 100644 index 0000000000..440bcec201 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-position.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns abrupt from ToInteger(position). +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 9. Let pos be ToInteger(position). (If position is undefined, this step + produces the value 0). + 10. ReturnIfAbrupt(pos). + ... +features: [String.prototype.includes] +---*/ + +var position = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.includes('', position); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring-as-symbol.js new file mode 100644 index 0000000000..6aa47b08ba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring-as-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns abrupt from ToString(searchString) as a Symbol +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 7. Let searchStr be ToString(searchString). + 8. ReturnIfAbrupt(searchStr). + ... +features: [Symbol, String.prototype.includes] +---*/ + +var s = Symbol(); + +assert.throws(TypeError, function() { + ''.includes(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring-regexp-test.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring-regexp-test.js new file mode 100644 index 0000000000..3b6f379e93 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring-regexp-test.js @@ -0,0 +1,44 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns abrupt from IsRegExp(searchString). +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 4. Let isRegExp be IsRegExp(searchString). + 5. ReturnIfAbrupt(isRegExp). + ... + + 7.2.8 IsRegExp ( argument ) + + 2. Let isRegExp be Get(argument, @@match). + 3. ReturnIfAbrupt(isRegExp). +features: [Symbol.match, String.prototype.includes] +---*/ + +var obj = {}; +Object.defineProperty(obj, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.includes(obj); +}); + +var regexp = /./; +Object.defineProperty(regexp, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.includes(regexp); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring.js new file mode 100644 index 0000000000..dbab997afc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-searchstring.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns abrupt from ToString(searchString) +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 7. Let searchStr be ToString(searchString). + 8. ReturnIfAbrupt(searchStr). + ... +features: [String.prototype.includes] +---*/ + +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.includes(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-this-as-symbol.js new file mode 100644 index 0000000000..af8905d962 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-this-as-symbol.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns abrupt from ToString(this) where this is a Symbol +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol, String.prototype.includes] +---*/ + +var s = Symbol(''); + +assert.throws(TypeError, function() { + String.prototype.includes.call(s, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-this.js new file mode 100644 index 0000000000..d811e7e12e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns abrupt from ToString(this) +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [String.prototype.includes] +---*/ +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.includes.call(o, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-false-with-out-of-bounds-position.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-false-with-out-of-bounds-position.js new file mode 100644 index 0000000000..fda6edafc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-false-with-out-of-bounds-position.js @@ -0,0 +1,45 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns false if position is >= this.length and searchString.length > 0. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLen be the number of elements in searchStr. + 14. If there exists any integer k not smaller than start such that k + + searchLen is not greater than len, and for all nonnegative integers j less + than searchLen, the code unit at index k+j of S is the same as the code unit + at index j of searchStr, return true; but if there is no such integer k, + return false. + ... +features: [String.prototype.includes] +---*/ + +var str = 'The future is cool!'; + +assert.sameValue( + str.includes('!', str.length + 1), false, + 'str.includes("!", str.length + 1) returns false' +); + +assert.sameValue( + str.includes('!', 100), false, + 'str.includes("!", 100) returns false' +); + +assert.sameValue( + str.includes('!', Infinity), false, + 'str.includes("!", Infinity) returns false' +); + +assert.sameValue( + str.includes('!', str.length), false, + 'str.includes("!", str.length) returns false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/return-true-if-searchstring-is-empty.js b/js/src/tests/test262/built-ins/String/prototype/includes/return-true-if-searchstring-is-empty.js new file mode 100644 index 0000000000..dfeaa58403 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/return-true-if-searchstring-is-empty.js @@ -0,0 +1,40 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns true if searchString.length == 0. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLen be the number of elements in searchStr. + 14. If there exists any integer k not smaller than start such that k + + searchLen is not greater than len, and for all nonnegative integers j less + than searchLen, the code unit at index k+j of S is the same as the code unit + at index j of searchStr, return true; but if there is no such integer k, + return false. + ... +features: [String.prototype.includes] +---*/ + +var str = 'The future is cool!'; + +assert( + str.includes('', str.length), + 'str.includes("", str.length) returns true' +); + +assert( + str.includes(''), + 'str.includes("") returns true' +); + +assert( + str.includes('', Infinity), + 'str.includes("", Infinity) returns true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-found-with-position.js new file mode 100644 index 0000000000..26907b4bd4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-found-with-position.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns true if searchString appears as a substring of the given string with a + given position. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLen be the number of elements in searchStr. + 14. If there exists any integer k not smaller than start such that k + + searchLen is not greater than len, and for all nonnegative integers j less + than searchLen, the code unit at index k+j of S is the same as the code unit + at index j of searchStr, return true; but if there is no such integer k, + return false. + ... +features: [String.prototype.includes] +---*/ + +var str = 'The future is cool!'; + +assert( + str.includes('The future', 0), + 'Returns true for str.includes("The future", 0)' +); +assert(str.includes(' is ', 1), 'Returns true for str.includes(" is ", 1)'); +assert(str.includes('cool!', 10), 'Returns true for str.includes("cool!", 10)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-found-without-position.js new file mode 100644 index 0000000000..11d9d92d8b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-found-without-position.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns true if searchString appears as a substring of the given string. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLen be the number of elements in searchStr. + 14. If there exists any integer k not smaller than start such that k + + searchLen is not greater than len, and for all nonnegative integers j less + than searchLen, the code unit at index k+j of S is the same as the code unit + at index j of searchStr, return true; but if there is no such integer k, + return false. + ... +features: [String.prototype.includes] +---*/ + +var str = 'The future is cool!'; + +assert( + str.includes('The future'), + 'Returns true for str.includes("The future")' +); +assert(str.includes('is cool!'), 'Returns true for str.includes("is cool!")'); +assert(str.includes(str), 'Returns true for str.includes(str)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-is-regexp-throws.js b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-is-regexp-throws.js new file mode 100644 index 0000000000..3006a4956a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-is-regexp-throws.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Throws a TypeError if searchString is a RegExp. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 4. Let isRegExp be IsRegExp(searchString). + 5. ReturnIfAbrupt(isRegExp). + 6. If isRegExp is true, throw a TypeError exception. + ... +features: [String.prototype.includes] +---*/ +var searchString = /./; + +assert.throws(TypeError, function() { + ''.includes(searchString); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-not-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-not-found-with-position.js new file mode 100644 index 0000000000..cf126204eb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-not-found-with-position.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns false if searchString is not found with a given position. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLen be the number of elements in searchStr. + 14. If there exists any integer k not smaller than start such that k + + searchLen is not greater than len, and for all nonnegative integers j less + than searchLen, the code unit at index k+j of S is the same as the code unit + at index j of searchStr, return true; but if there is no such integer k, + return false. + ... +features: [String.prototype.includes] +---*/ +var str = 'The future is cool!'; + +assert.sameValue( + str.includes('The future', 1), false, + 'Returns false on str.includes("The future", 1)' +); + +assert.sameValue( + str.includes(str, 1), false, + 'Returns false on str.includes(str, 1)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-not-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-not-found-without-position.js new file mode 100644 index 0000000000..3888d0eb96 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/searchstring-not-found-without-position.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Returns false if searchString is not found. +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLen be the number of elements in searchStr. + 14. If there exists any integer k not smaller than start such that k + + searchLen is not greater than len, and for all nonnegative integers j less + than searchLen, the code unit at index k+j of S is the same as the code unit + at index j of searchStr, return true; but if there is no such integer k, + return false. + ... +features: [String.prototype.includes] +---*/ +var str = 'The future is cool!'; + +assert.sameValue( + str.includes('Flash'), false, + 'Flash if not included' +); +assert.sameValue(str.includes('FUTURE'), false, 'includes is case sensitive'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/shell.js b/js/src/tests/test262/built-ins/String/prototype/includes/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/includes/this-is-null-throws.js new file mode 100644 index 0000000000..4bdee98384 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/this-is-null-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Throws TypeError when `this` is null +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +features: [String.prototype.includes] +---*/ +assert.throws(TypeError, function() { + String.prototype.includes.call(null, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/includes/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/includes/this-is-undefined-throws.js new file mode 100644 index 0000000000..230cb1cdb5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/includes/this-is-undefined-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.7 +description: > + Throws TypeError when `this` is undefined +info: | + 21.1.3.7 String.prototype.includes ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +features: [String.prototype.includes] +---*/ +assert.throws(TypeError, function() { + String.prototype.includes.call(undefined, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A10.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A10.js new file mode 100644 index 0000000000..e8470aa105 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A10.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: The String.prototype.indexOf.length property has the attribute ReadOnly +es5id: 15.5.4.7_A10 +description: > + Checking if varying the String.prototype.indexOf.length property + fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.indexOf.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.indexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.indexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.indexOf.length; + +verifyNotWritable(String.prototype.indexOf, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.indexOf.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.indexOf.length; String.prototype.indexOf.length = function(){return "shifted";}; String.prototype.indexOf.length === __obj. Actual: ' + String.prototype.indexOf.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A11.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A11.js new file mode 100644 index 0000000000..9154c4ee74 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A11.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 length property of the indexOf method is 1 +es5id: 15.5.4.7_A11 +description: Checking String.prototype.indexOf.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.indexOf.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.indexOf.hasOwnProperty("length") return true. Actual: ' + String.prototype.indexOf.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.indexOf.length !== 1) { + throw new Test262Error('#2: String.prototype.indexOf.length === 1. Actual: ' + String.prototype.indexOf.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T1.js new file mode 100644 index 0000000000..5e5f2b4e77 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T1 +description: Arguments are false and true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.indexOf = String.prototype.indexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.indexOf(true, false) !== 0) { + throw new Test262Error('#1: __instance = new Object(true); __instance.indexOf = String.prototype.indexOf; __instance.indexOf(true, false) === 0. Actual: ' + __instance.indexOf(true, false)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T10.js new file mode 100644 index 0000000000..7a4a6940ad --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T10.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.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T10 +description: Call indexOf(searchString, position) function with object arguments +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return true; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.indexOf(__obj, __obj2) !== 3) { + throw new Test262Error('#1: var x; var __obj = {toString:function(){return "\u0041B";}}; var __obj2 = {valueOf:function(){return true;}}; var __str = "ABB\u0041BABAB"; __str.indexOf(__obj, __obj2) === 3. Actual: ' + __str.indexOf(__obj, __obj2)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T12.js new file mode 100644 index 0000000000..ae01758ac0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T12.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.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T12 +description: Argument is string, and instance is array of strings +---*/ + +var __instance = new Array('new', 'zoo', 'revue'); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.indexOf('new') !== 0) { + throw new Test262Error('#1: __instance = new Array(\'new\',\'zoo\',\'revue\'); __instance.indexOf(\'new\') === 0. Actual: ' + __instance.indexOf('new')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.indexOf('zoo') !== 1) { + throw new Test262Error('#2: __instance = new Array(\'new\',\'zoo\',\'revue\'); __instance.indexOf(\'zoo\') === 1. Actual: ' + __instance.indexOf('zoo')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T2.js new file mode 100644 index 0000000000..84559cf6bf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T2.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.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T2 +description: > + Arguments are boolean equation, function and null, and instance is + Boolean object +---*/ + +var __instance = new Boolean; + +__instance.indexOf = String.prototype.indexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.indexOf("A" !== "\u0041", function() { + return 0; + }(), null) !== 0) { + throw new Test262Error('#1: __instance = new Boolean; __instance.indexOf = String.prototype.indexOf; __instance.indexOf("A"!=="\\u0041", function(){return 0;}(),null) === 0. Actual: ' + __instance.indexOf("A" !== "\u0041", function() { + return 0; + }(), null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T4.js new file mode 100644 index 0000000000..f569552206 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T4.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.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T4 +description: > + Call indexOf(searchString, position) function without arguments of + string +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString() evaluates to "" indexOf() evaluates to indexOf("",0) +if ("".indexOf() !== -1) { + throw new Test262Error('#1: "".indexOf() === -1. Actual: ' + ("".indexOf())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T5.js new file mode 100644 index 0000000000..062eb4a5bf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T5.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T5 +description: > + Call indexOf(searchString, position) function with null argument + of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" indexOf(null) evaluates to indexOf("",0) +if (function() { + return "gnulluna" + }().indexOf(null) !== 1) { + throw new Test262Error('#1: function(){return "gnulluna"}().indexOf(null) === 1. Actual: ' + function() { + return "gnulluna" + }().indexOf(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T6.js new file mode 100644 index 0000000000..220003e0b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T6 +description: > + Call indexOf(searchString, position) function with x argument of + new String object, where x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "" indexOf(undefined) evaluates to indexOf("",0) +if (new String("undefined").indexOf(x) !== 0) { + throw new Test262Error('#1: var x; new String("undefined").indexOf(x) === 0. Actual: ' + new String("undefined").indexOf(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T7.js new file mode 100644 index 0000000000..7a617eff3a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T7.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.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T7 +description: > + Call indexOf(searchString, position) function with undefined + argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" indexOf(undefined) evaluates to indexOf("undefined",0) +if (String("undefined").indexOf(undefined) !== 0) { + throw new Test262Error('#1: String("undefined").indexOf(undefined) === 0. Actual: ' + String("undefined").indexOf(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T8.js new file mode 100644 index 0000000000..ecc0cfb088 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T8.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T8 +description: > + Call indexOf(searchString, position) function with void 0 argument + of string object +---*/ + +var __obj = { + toString: function() {} +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(void 0) evaluates to "undefined" indexOf(void 0) evaluates to indexOf("undefined") +if (String(__obj).indexOf(void 0) !== 0) { + throw new Test262Error('#1: __obj = {toString:function(){}}; String(__obj).indexOf(void 0) === 0. Actual: ' + String(__obj).indexOf(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T9.js new file mode 100644 index 0000000000..e21a055b41 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A1_T9.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.indexOf(searchString, position) +es5id: 15.5.4.7_A1_T9 +description: > + Call indexOf(searchString, position) function with function(){}() + argument of string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" indexOf(undefined) evaluates to indexOf("undefined") +if (new String(__obj).indexOf(function() {}()) !== 0) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; new String(__obj).indexOf(function(){}()) === 0. Actual: ' + new String(__obj).indexOf(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T1.js new file mode 100644 index 0000000000..e338160a18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: When length of searchString less than length of ToString(this) -1 returns +es5id: 15.5.4.7_A2_T1 +description: Call "abcd".indexOf("abcdab") and check result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("abcd".indexOf("abcdab") !== -1) { + throw new Test262Error('#1: "abcd".indexOf("abcdab")===-1. Actual: ' + ("abcd".indexOf("abcdab"))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T2.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T2.js new file mode 100644 index 0000000000..ad29d78703 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T2.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: When length of searchString less than length of ToString(this) -1 returns +es5id: 15.5.4.7_A2_T2 +description: Call "abcd".indexOf("abcdab",0) and check result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("abcd".indexOf("abcdab", 0) !== -1) { + throw new Test262Error('#1: "abcd".indexOf("abcdab",0)===-1. Actual: ' + ("abcd".indexOf("abcdab", 0))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T3.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T3.js new file mode 100644 index 0000000000..0c21d307ce --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T3.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: When length of searchString less than length of ToString(this) -1 returns +es5id: 15.5.4.7_A2_T3 +description: Call "abcd".indexOf("abcdab",99) and check result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("abcd".indexOf("abcdab", 99) !== -1) { + throw new Test262Error('#1: "abcd".indexOf("abcdab",99)===-1. Actual: ' + ("abcd".indexOf("abcdab", 99))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T4.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T4.js new file mode 100644 index 0000000000..8f9b2be63a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A2_T4.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: When length of searchString less than length of ToString(this) -1 returns +es5id: 15.5.4.7_A2_T4 +description: Call "abcd".indexOf("abcdab",NaN) and check result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("abcd".indexOf("abcdab", NaN) !== -1) { + throw new Test262Error('#1: "abcd".indexOf("abcdab",NaN)===-1. Actual: ' + ("abcd".indexOf("abcdab", NaN))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T1.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T1.js new file mode 100644 index 0000000000..47941f97e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Since we deal with max(ToInteger(pos), 0) if ToInteger(pos) less than 0 + indexOf(searchString,0) returns +es5id: 15.5.4.7_A3_T1 +description: Call "$$abcdabcd".indexOf("ab",NaN) and check result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("$$abcdabcd".indexOf("ab", NaN) !== 2) { + throw new Test262Error('#1: "$$abcdabcd".indexOf("ab",NaN)===2. Actual: ' + ("$$abcdabcd".indexOf("ab", NaN))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T2.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T2.js new file mode 100644 index 0000000000..79264306b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + Since we deal with max(ToInteger(pos), 0) if ToInteger(pos) less than 0 + indexOf(searchString,0) returns +es5id: 15.5.4.7_A3_T2 +description: Call "$$abcdabcd".indexOf("ab",eval("\"-99\"")) and check result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("$$abcdabcd".indexOf("ab", eval("\"-99\"")) !== 2) { + throw new Test262Error('#1: "$$abcdabcd".indexOf("ab",eval("\\"-99\\""))===2. Actual: ' + ("$$abcdabcd".indexOf("ab", eval("\"-99\"")))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T3.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T3.js new file mode 100644 index 0000000000..efcfdd118e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A3_T3.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: | + Since we deal with max(ToInteger(pos), 0) if ToInteger(pos) less than 0 + indexOf(searchString,0) returns +es5id: 15.5.4.7_A3_T3 +description: > + Call "$$abcdabcd".indexOf("ab",function(){return -Infinity;}()) + and check result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("$$abcdabcd".indexOf("ab", function() { + return -Infinity; + }()) !== 2) { + throw new Test262Error('#1: "$$abcdabcd".indexOf("ab", function(){return -Infinity;}())===2. Actual: ' + ("$$abcdabcd".indexOf("ab", function() { + return -Infinity; + }()))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T1.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T1.js new file mode 100644 index 0000000000..28b1e8b909 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T1.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: | + when String.prototype.indexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.7_A4_T1 +description: Override toString and valueOf functions, valueOf throw exception +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + throw "intointeger"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.indexOf(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.indexOf(__obj, __obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "intointeger") { + throw new Test262Error('#1.1: Exception === "intointeger". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T2.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T2.js new file mode 100644 index 0000000000..45cc620488 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T2.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: | + when String.prototype.indexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.7_A4_T2 +description: > + Override toString and valueOf functions, second toString 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.indexOf(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.indexOf(__obj, __obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "intointeger") { + throw new Test262Error('#1.1: Exception === "intointeger". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T3.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T3.js new file mode 100644 index 0000000000..fc96919f8b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T3.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: | + when String.prototype.indexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.7_A4_T3 +description: Override toString and valueOf functions +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return {}; + }, + toString: function() { + return "1"; + } +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041BABAB".indexOf(__obj, __obj2) !== 3) { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041B";}}; var __obj2 = {valueOf:function(){return {};},toString:function(){return "1";}}; "ABB\\u0041BABAB".indexOf(__obj, __obj2)===3. Actual: ' + ("ABB\u0041BABAB".indexOf(__obj, __obj2))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T4.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T4.js new file mode 100644 index 0000000000..1701373f5a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T4.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.indexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.7_A4_T4 +description: Override toString and valueOf functions, and they throw exceptions +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +}; +var __obj2 = { + valueOf: function() { + throw "intoint"; + } +}; +var __instance = new Number(10001.10001); +Number.prototype.indexOf = String.prototype.indexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.indexOf(__obj, __obj2); + throw new Test262Error('#1: "var x = __instance.indexOf(__obj, __obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T5.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T5.js new file mode 100644 index 0000000000..59bd7c409c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A4_T5.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.indexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.7_A4_T5 +description: > + Override toString and valueOf functions, first and second valueOf + throw exception +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +}; + +var __obj2 = { + valueOf: function() { + throw "intointeger"; + } +}; + +__FACTORY.prototype.indexOf = String.prototype.indexOf; + +var __instance = new __FACTORY(void 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.indexOf(__obj, __obj2); + throw new Test262Error('#1: "var x = __instance.indexOf(__obj, __obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(value) { + this.value = value; + this.toString = function() { + return new Number; + }; + this.valueOf = function() { + return this.value + "" + }; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T1.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T1.js new file mode 100644 index 0000000000..dfb17a474d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf works properly +es5id: 15.5.4.7_A5_T1 +description: Search one symbol from begin of string +---*/ + +var TEST_STRING = new String(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var k = 0, i = 0x0020; i < 0x007e; i++, k++) { + if (TEST_STRING.indexOf(String.fromCharCode(i), 0) !== k) { + throw new Test262Error('#' + (i - 0x0020) + ': TEST_STRING.indexOf( String.fromCharCode(' + i + '), 0 )===' + k + '. Actual: ' + TEST_STRING.indexOf(String.fromCharCode(i), 0)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T2.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T2.js new file mode 100644 index 0000000000..017a91506c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf works properly +es5id: 15.5.4.7_A5_T2 +description: Search one symbol from its position in the string +---*/ + +var TEST_STRING = new String(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var k = 0, i = 0x0020; i < 0x007e; i++, k++) { + if (TEST_STRING.indexOf(String.fromCharCode(i), k) !== k) { + throw new Test262Error('#' + (i - 0x0020) + ': TEST_STRING.indexOf( String.fromCharCode(' + i + '), ' + k + ' )===' + k + '. Actual: ' + TEST_STRING.indexOf(String.fromCharCode(i), k)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T3.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T3.js new file mode 100644 index 0000000000..22f9b8328c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T3.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf works properly +es5id: 15.5.4.7_A5_T3 +description: Search one symbol from its position+1 in the string +---*/ + +var TEST_STRING = new String(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var k = 0, i = 0x0020; i < 0x007e; i++, k++) { + if (TEST_STRING.indexOf(String.fromCharCode(i), k + 1) !== -1) { + throw new Test262Error('#' + (i - 0x0020) + ': TEST_STRING.indexOf( String.fromCharCode(' + i + '), ' + (k + 1) + ' )===-1. Actual: ' + TEST_STRING.indexOf(String.fromCharCode(i), k + 1)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T4.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T4.js new file mode 100644 index 0000000000..b257a00bb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T4.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf works properly +es5id: 15.5.4.7_A5_T4 +description: Search substring from begin of string +---*/ + +var TEST_STRING = new String(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var k = 0, i = 0x0020; i < 0x007d; i++, k++) { + if (TEST_STRING.indexOf((String.fromCharCode(i) + String.fromCharCode(i + 1) + String.fromCharCode(i + 2)), 0) !== k) { + throw new Test262Error('#' + (i - 0x0020) + ': TEST_STRING.indexOf( (String.fromCharCode(' + i + ')+ String.fromCharCode(' + (i + 1) + ') + String.fromCharCode(' + (i + 2) + ')), 0 )===' + k + '. Actual: ' + TEST_STRING.indexOf((String.fromCharCode(i) + String.fromCharCode(i + 1) + String.fromCharCode(i + 2)), 0)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T5.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T5.js new file mode 100644 index 0000000000..2b96e84170 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T5.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf works properly +es5id: 15.5.4.7_A5_T5 +description: Search substring from its position in the string +---*/ + +var TEST_STRING = new String(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var k = 0, i = 0x0020; i < 0x007d; i++, k++) { + if (TEST_STRING.indexOf((String.fromCharCode(i) + String.fromCharCode(i + 1) + String.fromCharCode(i + 2)), k) !== k) { + throw new Test262Error('#' + (i - 0x0020) + ': TEST_STRING.indexOf( (String.fromCharCode(' + i + ')+ String.fromCharCode(' + (i + 1) + ') + String.fromCharCode(' + (i + 2) + ')), ' + k + ' )===' + k + '. Actual: ' + TEST_STRING.indexOf((String.fromCharCode(i) + String.fromCharCode(i + 1) + String.fromCharCode(i + 2)), k)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T6.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T6.js new file mode 100644 index 0000000000..2120268f71 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A5_T6.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf works properly +es5id: 15.5.4.7_A5_T6 +description: Search substring from its position+1 in the string +---*/ + +var TEST_STRING = new String(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +for (var k = 0, i = 0x0020; i < 0x007d; i++, k++) { + if (TEST_STRING.indexOf((String.fromCharCode(i) + String.fromCharCode(i + 1) + String.fromCharCode(i + 2)), k + 1) !== -1) { + throw new Test262Error('#' + (i - 0x0020) + ': TEST_STRING.indexOf( (String.fromCharCode(' + i + ')+ String.fromCharCode(' + (i + 1) + ') + String.fromCharCode(' + (i + 2) + ')), ' + (k + 1) + ' )=== -1. Actual: ' + TEST_STRING.indexOf((String.fromCharCode(i) + String.fromCharCode(i + 1) + String.fromCharCode(i + 2)), k + 1)); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A6.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A6.js new file mode 100644 index 0000000000..2989c9b54c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.indexOf has not prototype property +es5id: 15.5.4.7_A6 +description: Checking String.prototype.indexOf.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.indexOf.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.indexOf.prototype === undefined. Actual: ' + String.prototype.indexOf.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A7.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A7.js new file mode 100644 index 0000000000..aca8033023 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A7.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.indexOf can't be used as constructor +es5id: 15.5.4.7_A7 +description: Checking if creating the String.prototype.indexOf object fails +---*/ + +var __FACTORY = String.prototype.indexOf; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: var __FACTORY = String.prototype.indexOf; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: var __FACTORY = String.prototype.indexOf; "__instance = new __FACTORY" throw a TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A8.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A8.js new file mode 100644 index 0000000000..7b64601072 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A8.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: The String.prototype.indexOf.length property has the attribute DontEnum +es5id: 15.5.4.7_A8 +description: > + Checking if enumerating the String.prototype.indexOf.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.indexOf.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.indexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.indexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.indexOf.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.indexOf.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.indexOf) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.indexOf){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A9.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A9.js new file mode 100644 index 0000000000..310d9116fc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/S15.5.4.7_A9.js @@ -0,0 +1,38 @@ +// 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.indexOf.length property does not have the attribute + DontDelete +es5id: 15.5.4.7_A9 +description: > + Checking if deleting the String.prototype.indexOf.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.indexOf.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.indexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.indexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.indexOf.length) { + throw new Test262Error('#1: delete String.prototype.indexOf.length raturn true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.indexOf.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.indexOf.length; String.prototype.indexOf.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.indexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/browser.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/name.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/name.js new file mode 100644 index 0000000000..ff0064a42f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/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.8 +description: > + String.prototype.indexOf.name is "indexOf". +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 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.indexOf.name, "indexOf"); + +verifyNotEnumerable(String.prototype.indexOf, "name"); +verifyNotWritable(String.prototype.indexOf, "name"); +verifyConfigurable(String.prototype.indexOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/not-a-constructor.js new file mode 100644 index 0000000000..6cc8bc2efb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/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.indexOf 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.indexOf), + false, + 'isConstructor(String.prototype.indexOf) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.indexOf(); +}, '`new String.prototype.indexOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-bigint.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-bigint.js new file mode 100644 index 0000000000..a7be5890ff --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-bigint.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for position parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 4. Let pos be ? ToInteger(position). +features: [BigInt, Symbol.toPrimitive, computed-property-names] +---*/ + +assert.throws(TypeError, function() { + "".indexOf("", 0n); +}, "ToInteger: BigInt => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", Object(0n)); +}, "ToInteger: unbox object with internal slot => BigInt => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", { + [Symbol.toPrimitive]: function() { + return 0n; + } + }); +}, "ToInteger: @@toPrimitive => BigInt => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", { + valueOf: function() { + return 0n; + } + }); +}, "ToInteger: valueOf => BigInt => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", { + toString: function() { + return 0n; + } + }); +}, "ToInteger: toString => BigInt => TypeError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-errors.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-errors.js new file mode 100644 index 0000000000..f21a3d0144 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-errors.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for position parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 4. Let pos be ? ToInteger(position). +features: [Symbol, Symbol.toPrimitive, computed-property-names] +---*/ + +assert.throws(TypeError, function() { + "".indexOf("", Symbol("1")); +}, "ToInteger: Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", Object(Symbol("1"))); +}, "ToInteger: unbox object with internal slot => Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", { + [Symbol.toPrimitive]: function() { + return Symbol("1"); + } + }); +}, "ToInteger: @@toPrimitive => Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", { + valueOf: function() { + return Symbol("1"); + } + }); +}, "ToInteger: valueOf => Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf("", { + toString: function() { + return Symbol("1"); + } + }); +}, "ToInteger: toString => Symbol => TypeError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-toprimitive.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-toprimitive.js new file mode 100644 index 0000000000..68a89ae176 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-toprimitive.js @@ -0,0 +1,167 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for position parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 4. Let pos be ? ToInteger(position). +features: [Symbol.toPrimitive, computed-property-names] +---*/ + +function err() { + throw new Test262Error(); +} + +function MyError() {} + +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: function() { + return 1; + }, + valueOf: err, + toString: err +}), 1, "ToPrimitive: @@toPrimitive takes precedence"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return 1; + }, + toString: err +}), 1, "ToPrimitive: valueOf takes precedence over toString"); +assert.sameValue("aaaa".indexOf("aa", { + toString: function() { + return 1; + } +}), 1, "ToPrimitive: toString with no valueOf"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: undefined, + valueOf: function() { + return 1; + } +}), 1, "ToPrimitive: skip @@toPrimitive when it's undefined"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: null, + valueOf: function() { + return 1; + } +}), 1, "ToPrimitive: skip @@toPrimitive when it's null"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: null, + toString: function() { + return 1; + } +}), 1, "ToPrimitive: skip valueOf when it's not callable"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: 1, + toString: function() { + return 1; + } +}), 1, "ToPrimitive: skip valueOf when it's not callable"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: {}, + toString: function() { + return 1; + } +}), 1, "ToPrimitive: skip valueOf when it's not callable"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return {}; + }, + toString: function() { + return 1; + } +}), 1, "ToPrimitive: skip valueOf when it returns an object"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return Object(12345); + }, + toString: function() { + return 1; + } +}), 1, "ToPrimitive: skip valueOf when it returns an object"); +assert.throws(TypeError, function() { + "".indexOf("", { + [Symbol.toPrimitive]: 1 + }); +}, "ToPrimitive: throw when @@toPrimitive is not callable"); +assert.throws(TypeError, function() { + "".indexOf("", { + [Symbol.toPrimitive]: {} + }); +}, "ToPrimitive: throw when @@toPrimitive is not callable"); +assert.throws(TypeError, function() { + "".indexOf("", { + [Symbol.toPrimitive]: function() { + return Object(1); + } + }); +}, "ToPrimitive: throw when @@toPrimitive returns an object"); +assert.throws(TypeError, function() { + "".indexOf("", { + [Symbol.toPrimitive]: function() { + return {}; + } + }); +}, "ToPrimitive: throw when @@toPrimitive returns an object"); +assert.throws(MyError, function() { + "".indexOf("", { + [Symbol.toPrimitive]: function() { + throw new MyError(); + } + }); +}, "ToPrimitive: propagate errors from @@toPrimitive"); +assert.throws(MyError, function() { + "".indexOf("", { + valueOf: function() { + throw new MyError(); + } + }); +}, "ToPrimitive: propagate errors from valueOf"); +assert.throws(MyError, function() { + "".indexOf("", { + toString: function() { + throw new MyError(); + } + }); +}, "ToPrimitive: propagate errors from toString"); +assert.throws(TypeError, function() { + "".indexOf("", { + valueOf: null, + toString: null + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf("", { + valueOf: 1, + toString: 1 + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf("", { + valueOf: {}, + toString: {} + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf("", { + valueOf: function() { + return Object(1); + }, + toString: function() { + return Object(1); + } + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf("", { + valueOf: function() { + return {}; + }, + toString: function() { + return {}; + } + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-wrapped-values.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-wrapped-values.js new file mode 100644 index 0000000000..ea8e721eaa --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger-wrapped-values.js @@ -0,0 +1,111 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for position parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 4. Let pos be ? ToInteger(position). +features: [Symbol.toPrimitive, computed-property-names] +---*/ + +assert.sameValue("aaaa".indexOf("aa", Object(0)), 0, "ToPrimitive: unbox object with internal slot"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: function() { + return 0; + } +}), 0, "ToPrimitive: @@toPrimitive"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return 0; + } +}), 0, "ToPrimitive: valueOf"); +assert.sameValue("aaaa".indexOf("aa", { + toString: function() { + return 0; + } +}), 0, "ToPrimitive: toString"); +assert.sameValue("aaaa".indexOf("aa", Object(NaN)), 0, + "ToInteger: unbox object with internal slot => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: function() { + return NaN; + } +}), 0, "ToInteger: @@toPrimitive => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return NaN; + } +}), 0, "ToInteger: valueOf => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", { + toString: function() { + return NaN; + } +}), 0, "ToInteger: toString => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: function() { + return undefined; + } +}), 0, "ToInteger: @@toPrimitive => undefined => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return undefined; + } +}), 0, "ToInteger: valueOf => undefined => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", { + toString: function() { + return undefined; + } +}), 0, "ToInteger: toString => undefined => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: function() { + return null; + } +}), 0, "ToInteger: @@toPrimitive => null => 0"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return null; + } +}), 0, "ToInteger: valueOf => null => 0"); +assert.sameValue("aaaa".indexOf("aa", { + toString: function() { + return null; + } +}), 0, "ToInteger: toString => null => 0"); +assert.sameValue("aaaa".indexOf("aa", Object(true)), 1, + "ToInteger: unbox object with internal slot => true => 1"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: function() { + return true; + } +}), 1, "ToInteger: @@toPrimitive => true => 1"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return true; + } +}), 1, "ToInteger: valueOf => true => 1"); +assert.sameValue("aaaa".indexOf("aa", { + toString: function() { + return true; + } +}), 1, "ToInteger: toString => true => 1"); +assert.sameValue("aaaa".indexOf("aa", Object("1.9")), 1, + "ToInteger: unbox object with internal slot => parse Number => 1.9 => 1"); +assert.sameValue("aaaa".indexOf("aa", { + [Symbol.toPrimitive]: function() { + return "1.9"; + } +}), 1, "ToInteger: @@toPrimitive => parse Number => 1.9 => 1"); +assert.sameValue("aaaa".indexOf("aa", { + valueOf: function() { + return "1.9"; + } +}), 1, "ToInteger: valueOf => parse Number => 1.9 => 1"); +assert.sameValue("aaaa".indexOf("aa", { + toString: function() { + return "1.9"; + } +}), 1, "ToInteger: toString => parse Number => 1.9 => 1"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger.js new file mode 100644 index 0000000000..46f49616c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/position-tointeger.js @@ -0,0 +1,39 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for position parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 4. Let pos be ? ToInteger(position). +---*/ + +assert.sameValue("aaaa".indexOf("aa", 0), 0); +assert.sameValue("aaaa".indexOf("aa", 1), 1); +assert.sameValue("aaaa".indexOf("aa", -0.9), 0, "ToInteger: truncate towards 0"); +assert.sameValue("aaaa".indexOf("aa", 0.9), 0, "ToInteger: truncate towards 0"); +assert.sameValue("aaaa".indexOf("aa", 1.9), 1, "ToInteger: truncate towards 0"); +assert.sameValue("aaaa".indexOf("aa", NaN), 0, "ToInteger: NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", Infinity), -1); +assert.sameValue("aaaa".indexOf("aa", undefined), 0, "ToInteger: undefined => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", null), 0, "ToInteger: null => 0"); +assert.sameValue("aaaa".indexOf("aa", false), 0, "ToInteger: false => 0"); +assert.sameValue("aaaa".indexOf("aa", true), 1, "ToInteger: true => 1"); +assert.sameValue("aaaa".indexOf("aa", "0"), 0, "ToInteger: parse Number"); +assert.sameValue("aaaa".indexOf("aa", "1.9"), 1, "ToInteger: parse Number => 1.9 => 1"); +assert.sameValue("aaaa".indexOf("aa", "Infinity"), -1, "ToInteger: parse Number"); +assert.sameValue("aaaa".indexOf("aa", ""), 0, "ToInteger: unparseable string => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", "foo"), 0, "ToInteger: unparseable string => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", "true"), 0, "ToInteger: unparseable string => NaN => 0"); +assert.sameValue("aaaa".indexOf("aa", 2), 2); +assert.sameValue("aaaa".indexOf("aa", "2"), 2, "ToInteger: parse Number"); +assert.sameValue("aaaa".indexOf("aa", 2.9), 2, "ToInteger: truncate towards 0"); +assert.sameValue("aaaa".indexOf("aa", "2.9"), 2, "ToInteger: parse Number => truncate towards 0"); +assert.sameValue("aaaa".indexOf("aa", [0]), 0, 'ToInteger: [0].toString() => "0" => 0'); +assert.sameValue("aaaa".indexOf("aa", ["1"]), 1, 'ToInteger: ["1"].toString() => "1" => 1'); +assert.sameValue("aaaa".indexOf("aa", {}), 0, + 'ToInteger: ({}).toString() => "[object Object]" => NaN => 0'); +assert.sameValue("aaaa".indexOf("aa", []), 0, 'ToInteger: [].toString() => "" => NaN => 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-bigint.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-bigint.js new file mode 100644 index 0000000000..42b59ffef2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-bigint.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for searchString parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 3. Let searchStr be ? ToString(searchString). +features: [BigInt, Symbol.toPrimitive, computed-property-names] +---*/ + +assert.sameValue("__0__".indexOf(0n), 2, "ToString: BigInt to String"); +assert.sameValue("__0__".indexOf(Object(0n)), 2, + "ToString: unbox object with internal slot => BigInt to String"); +assert.sameValue("__0__".indexOf({ + [Symbol.toPrimitive]: function() { + return 0n; + } +}), 2, "ToString: @@toPrimitive => BigInt to String"); +assert.sameValue("__0__".indexOf({ + valueOf: function() { + return 0n; + }, + toString: null +}), 2, "ToString: valueOf => BigInt to String"); +assert.sameValue("__0__".indexOf({ + toString: function() { + return 0n; + } +}), 2, "ToString: toString => BigInt to String"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-errors.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-errors.js new file mode 100644 index 0000000000..9f2802c291 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-errors.js @@ -0,0 +1,42 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for searchString parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 3. Let searchStr be ? ToString(searchString). +features: [Symbol, Symbol.toPrimitive, computed-property-names] +---*/ + +assert.throws(TypeError, function() { + "".indexOf(Symbol("1")); +}, "ToString: Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf(Object(Symbol("1"))); +}, "ToString: unbox object with internal slot => Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf({ + [Symbol.toPrimitive]: function() { + return Symbol("1"); + } + }); +}, "ToString: @@toPrimitive => Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf({ + valueOf: function() { + return Symbol("1"); + }, + toString: null + }); +}, "ToString: valueOf => Symbol => TypeError"); +assert.throws(TypeError, function() { + "".indexOf({ + toString: function() { + return Symbol("1"); + } + }); +}, "ToString: toString => Symbol => TypeError"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-toprimitive.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-toprimitive.js new file mode 100644 index 0000000000..6c45bd6965 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-toprimitive.js @@ -0,0 +1,163 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for searchString parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 3. Let searchStr be ? ToString(searchString). +features: [Symbol.toPrimitive, computed-property-names] +---*/ + +function err() { + throw new Test262Error(); +} + +function MyError() {} + +assert.sameValue("__foo__".indexOf({ + [Symbol.toPrimitive]: function() { + return "foo"; + }, + toString: err, + valueOf: err +}), 2, "ToPrimitive: @@toPrimitive takes precedence"); +assert.sameValue("__foo__".indexOf({ + toString: function() { + return "foo"; + }, + valueOf: err +}), 2, "ToPrimitive: toString takes precedence over valueOf"); +assert.sameValue("__foo__".indexOf({ + [Symbol.toPrimitive]: undefined, + toString: function() { + return "foo"; + } +}), 2, "ToPrimitive: skip @@toPrimitive when it's undefined"); +assert.sameValue("__foo__".indexOf({ + [Symbol.toPrimitive]: null, + toString: function() { + return "foo"; + } +}), 2, "ToPrimitive: skip @@toPrimitive when it's null"); +assert.sameValue("__foo__".indexOf({ + toString: null, + valueOf: function() { + return "foo"; + } +}), 2, "ToPrimitive: skip toString when it's not callable"); +assert.sameValue("__foo__".indexOf({ + toString: 1, + valueOf: function() { + return "foo"; + } +}), 2, "ToPrimitive: skip toString when it's not callable"); +assert.sameValue("__foo__".indexOf({ + toString: {}, + valueOf: function() { + return "foo"; + } +}), 2, "ToPrimitive: skip toString when it's not callable"); +assert.sameValue("__foo__".indexOf({ + toString: function() { + return {}; + }, + valueOf: function() { + return "foo"; + } +}), 2, "ToPrimitive: skip toString when it returns an object"); +assert.sameValue("__foo__".indexOf({ + toString: function() { + return Object(12345); + }, + valueOf: function() { + return "foo"; + } +}), 2, "ToPrimitive: skip toString when it returns an object"); +assert.throws(TypeError, function() { + "".indexOf({ + [Symbol.toPrimitive]: 1 + }); +}, "ToPrimitive: throw when @@toPrimitive is not callable"); +assert.throws(TypeError, function() { + "".indexOf({ + [Symbol.toPrimitive]: {} + }); +}, "ToPrimitive: throw when @@toPrimitive is not callable"); +assert.throws(TypeError, function() { + "".indexOf({ + [Symbol.toPrimitive]: function() { + return Object(1); + } + }); +}, "ToPrimitive: throw when @@toPrimitive returns an object"); +assert.throws(TypeError, function() { + "".indexOf({ + [Symbol.toPrimitive]: function() { + return {}; + } + }); +}, "ToPrimitive: throw when @@toPrimitive returns an object"); +assert.throws(MyError, function() { + "".indexOf({ + [Symbol.toPrimitive]: function() { + throw new MyError(); + } + }); +}, "ToPrimitive: propagate errors from @@toPrimitive"); +assert.throws(MyError, function() { + "".indexOf({ + valueOf: function() { + throw new MyError(); + }, + toString: null + }); +}, "ToPrimitive: propagate errors from valueOf"); +assert.throws(MyError, function() { + "".indexOf({ + toString: function() { + throw new MyError(); + } + }); +}, "ToPrimitive: propagate errors from toString"); +assert.throws(TypeError, function() { + "".indexOf({ + valueOf: null, + toString: null + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf({ + valueOf: 1, + toString: 1 + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf({ + valueOf: {}, + toString: {} + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf({ + valueOf: function() { + return Object(1); + }, + toString: function() { + return Object(1); + } + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); +assert.throws(TypeError, function() { + "".indexOf({ + valueOf: function() { + return {}; + }, + toString: function() { + return {}; + } + }); +}, "ToPrimitive: throw when skipping both valueOf and toString"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-wrapped-values.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-wrapped-values.js new file mode 100644 index 0000000000..af0c8a76c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring-wrapped-values.js @@ -0,0 +1,100 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for searchString parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 3. Let searchStr be ? ToString(searchString). +features: [Symbol.toPrimitive, computed-property-names] +---*/ + +assert.sameValue("__foo__".indexOf(Object("foo")), 2, + "ToPrimitive: unbox object with internal slot"); +assert.sameValue("__foo__".indexOf({ + [Symbol.toPrimitive]: function() { + return "foo"; + } +}), 2, "ToPrimitive: @@toPrimitive"); +assert.sameValue("__foo__".indexOf({ + valueOf: function() { + return "foo"; + }, + toString: null +}), 2, "ToPrimitive: valueOf"); +assert.sameValue("__foo__".indexOf({ + toString: function() { + return "foo"; + } +}), 2, "ToPrimitive: toString"); +assert.sameValue("__undefined__".indexOf({ + [Symbol.toPrimitive]: function() { + return undefined; + } +}), 2, 'ToString: @@toPrimitive => undefined => "undefined"'); +assert.sameValue("__undefined__".indexOf({ + valueOf: function() { + return undefined; + }, + toString: null +}), 2, 'ToString: valueOf => undefined => "undefined"'); +assert.sameValue("__undefined__".indexOf({ + toString: function() { + return undefined; + } +}), 2, 'ToString: toString => undefined => "undefined"'); +assert.sameValue("__null__".indexOf({ + [Symbol.toPrimitive]: function() { + return null; + } +}), 2, 'ToString: @@toPrimitive => null => "null"'); +assert.sameValue("__null__".indexOf({ + valueOf: function() { + return null; + }, + toString: null +}), 2, 'ToString: valueOf => null => "null"'); +assert.sameValue("__null__".indexOf({ + toString: function() { + return null; + } +}), 2, 'ToString: toString => null => "null"'); +assert.sameValue("__false__".indexOf(Object(false)), 2, + 'ToString: unbox object with internal slot => false => "false"'); +assert.sameValue("__false__".indexOf({ + [Symbol.toPrimitive]: function() { + return false; + } +}), 2, 'ToString: @@toPrimitive => false => "false"'); +assert.sameValue("__false__".indexOf({ + valueOf: function() { + return false; + }, + toString: null +}), 2, 'ToString: valueOf => false => "false"'); +assert.sameValue("__false__".indexOf({ + toString: function() { + return false; + } +}), 2, 'ToString: toString => false => "false"'); +assert.sameValue("__0__".indexOf(Object(0)), 2, + "ToString: unbox object with internal slot => Number to String"); +assert.sameValue("__0__".indexOf({ + [Symbol.toPrimitive]: function() { + return 0; + } +}), 2, "ToString: @@toPrimitive => Number to String"); +assert.sameValue("__0__".indexOf({ + valueOf: function() { + return 0; + }, + toString: null +}), 2, "ToString: valueOf => Number to String"); +assert.sameValue("__0__".indexOf({ + toString: function() { + return 0; + } +}), 2, "ToString: toString => Number to String"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring.js new file mode 100644 index 0000000000..fb49889399 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/searchstring-tostring.js @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Josh Wolfe. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: String.prototype.indexOf type coercion for searchString parameter +esid: sec-string.prototype.indexof +info: | + String.prototype.indexOf ( searchString [ , position ] ) + + 3. Let searchStr be ? ToString(searchString). +---*/ + +assert.sameValue("foo".indexOf(""), 0); +assert.sameValue("__foo__".indexOf("foo"), 2); +assert.sameValue("__undefined__".indexOf(undefined), 2, 'ToString: undefined => "undefined"'); +assert.sameValue("__null__".indexOf(null), 2, 'ToString: null => "null"'); +assert.sameValue("__true__".indexOf(true), 2, 'ToString: true => "true"'); +assert.sameValue("__false__".indexOf(false), 2, 'ToString: false => "false"'); +assert.sameValue("__0__".indexOf(0), 2, "ToString: Number to String"); +assert.sameValue("__0__".indexOf(-0), 2, 'ToString: -0 => "0"'); +assert.sameValue("__Infinity__".indexOf(Infinity), 2, 'ToString: Infinity => "Infinity"'); +assert.sameValue("__-Infinity__".indexOf(-Infinity), 2, 'ToString: -Infinity => "-Infinity"'); +assert.sameValue("__NaN__".indexOf(NaN), 2, 'ToString: NaN => "NaN"'); +assert.sameValue("__123.456__".indexOf(123.456), 2, "ToString: Number to String"); +assert.sameValue("__-123.456__".indexOf(-123.456), 2, "ToString: Number to String"); +assert.sameValue("foo".indexOf([]), 0, "ToString: .toString()"); +assert.sameValue("__foo,bar__".indexOf(["foo", "bar"]), 2, "ToString: .toString()"); +assert.sameValue("__[object Object]__".indexOf({}), 2, "ToString: .toString()"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/shell.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/indexOf/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/indexOf/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..46ab36f345 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/indexOf/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.indexof +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var indexOf = String.prototype.indexOf; + +assert.sameValue(typeof indexOf, 'function'); + +assert.throws(TypeError, function() { + indexOf.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + indexOf.call(null, ''); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/browser.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/length.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/length.js new file mode 100644 index 0000000000..25dacc03cf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/length.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.iswellformed +description: > + String.prototype.isWellFormed.length value and descriptor. +info: | + String.prototype.isWellFormed( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.isWellFormed] +---*/ + +verifyProperty(String.prototype.isWellFormed, 'length', { + configurable: true, + enumerable: false, + writable: false, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/name.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/name.js new file mode 100644 index 0000000000..273e21c0df --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/name.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.iswellformed +description: > + String.prototype.isWellFormed.name value and descriptor. +info: | + String.prototype.isWellFormed( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.isWellFormed] +---*/ + +verifyProperty(String.prototype.isWellFormed, 'name', { + enumerable: false, + writable: false, + configurable: true, + value: 'isWellFormed' +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/not-a-constructor.js new file mode 100644 index 0000000000..edadd4ba0a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/not-a-constructor.js @@ -0,0 +1,35 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. 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.includes 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: [String.prototype.isWellFormed, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(String.prototype.isWellFormed), + false, + 'isConstructor(String.prototype.isWellFormed) must return false' +); + +assert.throws(TypeError, function () { + new String.prototype.isWellFormed(); +}, '`new String.prototype.isWellFormed()` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/prop-desc.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/prop-desc.js new file mode 100644 index 0000000000..e32cba4f00 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/prop-desc.js @@ -0,0 +1,28 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.iswellformed +description: > + Property type and descriptor. +info: | + String.prototype.isWellFormed( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.isWellFormed] +---*/ + +assert.sameValue( + typeof String.prototype.isWellFormed, + 'function', + 'The value of `typeof String.prototype.isWellFormed` is "function"' +); + +verifyProperty(String.prototype, 'isWellFormed', { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js new file mode 100644 index 0000000000..5796e786f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.iswellformed +description: > + Return abrupt from RequireObjectCoercible(this value). +info: | + String.prototype.isWellFormed( ) + + 1. Let O be ? RequireObjectCoercible(this value). + +features: [String.prototype.isWellFormed] +---*/ +assert.sameValue(typeof String.prototype.isWellFormed, 'function'); + +assert.throws(TypeError, function () { + String.prototype.isWellFormed.call(undefined); +}, '`String.prototype.isWellFormed.call(undefined)` throws TypeError'); + +assert.throws(TypeError, function () { + String.prototype.isWellFormed.call(null); +}, '`String.prototype.isWellFormed.call(null)` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/returns-boolean.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/returns-boolean.js new file mode 100644 index 0000000000..1109670e53 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/returns-boolean.js @@ -0,0 +1,47 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.iswellformed +description: > + The method should return a boolean. +info: | + String.prototype.isWellFormed ( ) + + 1. Let O be ? RequireObjectCoercible(this value). + 2. Let S be ? ToString(O). + 3. Return IsStringWellFormedUnicode(S). + +features: [String.prototype.isWellFormed] +---*/ +assert.sameValue(typeof String.prototype.isWellFormed, 'function'); + +var leadingPoo = '\uD83D'; +var trailingPoo = '\uDCA9'; +var wholePoo = leadingPoo + trailingPoo; + +assert.sameValue( + ('a' + leadingPoo + 'c' + leadingPoo + 'e').isWellFormed(), + false, + 'lone leading surrogates are not well-formed' +); +assert.sameValue( + ('a' + trailingPoo + 'c' + trailingPoo + 'e').isWellFormed(), + false, + 'lone trailing surrogates are not well-formed' +); +assert.sameValue( + ('a' + trailingPoo + leadingPoo + 'd').isWellFormed(), + false, + 'a wrong-ordered surrogate pair is not well-formed' +) + +assert.sameValue('a💩c'.isWellFormed(), true, 'a surrogate pair using a literal code point is well-formed'); +assert.sameValue('a\uD83D\uDCA9c'.isWellFormed(), true, 'a surrogate pair formed by escape sequences is well-formed'); +assert.sameValue(('a' + leadingPoo + trailingPoo + 'd').isWellFormed(), true, 'a surrogate pair formed by concatenation is well-formed'); +assert.sameValue(wholePoo.slice(0, 1).isWellFormed(), false, 'a surrogate pair sliced to the leading surrogate is not well-formed'); +assert.sameValue(wholePoo.slice(1).isWellFormed(), false, 'a surrogate pair sliced to the trailing surrogate is not well-formed'); +assert.sameValue('abc'.isWellFormed(), true, 'a latin-1 string is well-formed'); +assert.sameValue('a\u25A8c'.isWellFormed(), true, 'a non-ASCII character is well-formed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/shell.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/to-string-primitive.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/to-string-primitive.js new file mode 100644 index 0000000000..5ef95cf21a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/to-string-primitive.js @@ -0,0 +1,35 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.iswellformed +description: > + The method should coerce the receiver to a string. +info: | + String.prototype.isWellFormed ( ) + + 2. Let S be ? ToString(O). + … + +features: [String.prototype.isWellFormed] +---*/ + +const tests = [ + [true, Boolean.prototype], + [1, Number.prototype], + [1n, BigInt.prototype], +]; + +for (const [v, proto] of tests) { + proto.toString = function() { + throw new Test262Error(`should not call toString on the prototype for ${typeof v}`); + } + let result = String.prototype.isWellFormed.call(v); + delete proto.toString; + assert.sameValue(result, true, `isWellFormed for ${typeof v}`); +} + +Symbol.prototype.toString = function() { throw new TypeError("should not call toString on the prototype for Symbol"); } +assert.throws(TypeError, () => String.prototype.isWellFormed.call(Symbol()), `Built-in result for Symbol`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/isWellFormed/to-string.js b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/to-string.js new file mode 100644 index 0000000000..1d5035d9b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/isWellFormed/to-string.js @@ -0,0 +1,30 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.isWellFormed||!xulRuntime.shell) -- String.prototype.isWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.iswellformed +description: > + The method should coerce the receiver to a string. +info: | + String.prototype.isWellFormed ( ) + + 1. Let O be ? RequireObjectCoercible(this value). + 2. Let S be ? ToString(O). + 3. Return IsStringWellFormedUnicode(S). + +features: [String.prototype.isWellFormed] +---*/ + +var obj = { + toString: function () { + throw new Test262Error('calls ToString'); + } +}; + +assert.throws( + Test262Error, + function () { String.prototype.isWellFormed.call(obj); }, + 'coerces the receiver to a string' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A10.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A10.js new file mode 100644 index 0000000000..b3d53f4bc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A10.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.lastIndexOf.length property has the attribute + ReadOnly +es5id: 15.5.4.8_A10 +description: > + Checking if varying the String.prototype.lastIndexOf.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.lastIndexOf.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.lastIndexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.lastIndexOf.length; + +verifyNotWritable(String.prototype.lastIndexOf, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.lastIndexOf.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length = function(){return "shifted";}; String.prototype.lastIndexOf.length === __obj. Actual: ' + String.prototype.lastIndexOf.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A11.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A11.js new file mode 100644 index 0000000000..c1805c8009 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A11.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 length property of the lastIndexOf method is 1 +es5id: 15.5.4.8_A11 +description: Checking String.prototype.lastIndexOf.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.lastIndexOf.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.lastIndexOf.hasOwnProperty("length") return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.lastIndexOf.length !== 1) { + throw new Test262Error('#2: String.prototype.lastIndexOf.length === 1. Actual: ' + String.prototype.lastIndexOf.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T1.js new file mode 100644 index 0000000000..4251d7d213 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T1 +description: Arguments are false and true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.lastIndexOf = String.prototype.lastIndexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.lastIndexOf(true, false) !== 0) { + throw new Test262Error('#1: __instance = new Object(true); __instance.lastIndexOf = String.prototype.lastIndexOf; __instance.lastIndexOf(true, false) === 0. Actual: ' + __instance.lastIndexOf(true, false)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T10.js new file mode 100644 index 0000000000..fcf2b12f24 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T10.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.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T10 +description: > + Call lastIndexOf(searchString, position) function with object + arguments +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return NaN; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.lastIndexOf(__obj, __obj2) !== 7) { + throw new Test262Error('#1: var x; var __obj = {toString:function(){return "\u0041B";}}; var __obj2 = {valueOf:function(){return NaN;}}; var __str = "ABB\u0041BABAB";lastIndexOf(__obj, __obj2) === 7. Actual: ' + __str.lastIndexOf(__obj, __obj2)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T12.js new file mode 100644 index 0000000000..eff60d1894 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T12.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.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T12 +description: Argument is string, and instance is array of strings +---*/ + +var __instance = new Array('new', 'zoo', 'revue'); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.lastIndexOf('new') !== 0) { + throw new Test262Error('#1: __instance = new Array(\'new\',\'zoo\',\'revue\'); __instance.lastIndexOf(\'new\') === 0. Actual: ' + __instance.lastIndexOf('new')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.lastIndexOf('zoo') !== 1) { + throw new Test262Error('#2: __instance = new Array(\'new\',\'zoo\',\'revue\'); __instance.lastIndexOf(\'zoo\') === 1. Actual: ' + __instance.lastIndexOf('zoo')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T2.js new file mode 100644 index 0000000000..714bbaaa3c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T2.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.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T2 +description: > + Arguments are boolean equation, function and null, and instance is + Boolean object +---*/ + +var __instance = new Boolean; + +__instance.lastIndexOf = String.prototype.lastIndexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.lastIndexOf("A" !== "\u0041", function() { + return 0; + }(), null) !== 0) { + throw new Test262Error('#1: __instance = new Boolean; __instance.lastIndexOf = String.prototype.lastIndexOf; __instance.lastIndexOf("A"!=="\\u0041", function(){return 0;}(),null) === 0. Actual: ' + __instance.lastIndexOf("A" !== "\u0041", function() { + return 0; + }(), null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T4.js new file mode 100644 index 0000000000..e89a5a0902 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T4.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.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T4 +description: > + Call lastIndexOf(searchString, position) function without + arguments of string +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString() evaluates to "" lastIndexOf() evaluates to lastIndexOf("",0) +if ("".lastIndexOf() !== -1) { + throw new Test262Error('#1: "".lastIndexOf() === -1. Actual: ' + ("".lastIndexOf())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T5.js new file mode 100644 index 0000000000..6e2f0811c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T5.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T5 +description: > + Call lastIndexOf(searchString, position) function with null + argument of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" lastIndexOf(null) evaluates to lastIndexOf("",0) +if (function() { + return "gnullunazzgnull" + }().lastIndexOf(null) !== 11) { + throw new Test262Error('#1: function(){return "gnullunazzgnull"}().lastIndexOf(null) === 11. Actual: ' + function() { + return "gnullunazzgnull" + }().lastIndexOf(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T6.js new file mode 100644 index 0000000000..90b28bc8b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T6 +description: > + Call lastIndexOf(searchString, position) function with x argument + of new String object, where x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "" lastIndexOf(undefined) evaluates to lastIndexOf("",0) +if (new String("undefined").lastIndexOf(x) !== 0) { + throw new Test262Error('#1: var x; new String("undefined").lastIndexOf(x) === 0. Actual: ' + new String("undefined").lastIndexOf(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T7.js new file mode 100644 index 0000000000..c8f5af9551 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T7.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.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T7 +description: > + Call lastIndexOf(searchString, position) function with undefined + argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" lastIndexOf(undefined) evaluates to lastIndexOf("undefined",0) +if (String("undefined").lastIndexOf(undefined) !== 0) { + throw new Test262Error('#1: String("undefined").lastIndexOf(undefined) === 0. Actual: ' + String("undefined").lastIndexOf(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T8.js new file mode 100644 index 0000000000..e048c8fc7d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T8.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T8 +description: > + Call lastIndexOf(searchString, position) function with void 0 + argument of string object +---*/ + +var __obj = { + toString: function() {} +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(void 0) evaluates to "undefined" lastIndexOf(void 0) evaluates to lastIndexOf("undefined",0) +if (String(__obj).lastIndexOf(void 0) !== 0) { + throw new Test262Error('#1: __obj = {toString:function(){}}; String(__obj).lastIndexOf(void 0) === 0. Actual: ' + String(__obj).lastIndexOf(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T9.js new file mode 100644 index 0000000000..942f54a2a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T9.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.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T9 +description: > + Call lastIndexOf(searchString, position) function with + function(){}() argument of string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" indexOf(undefined) evaluates to indexOf("undefined") +if (new String(__obj).lastIndexOf(function() {}()) !== 0) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; new String(__obj).lastIndexOf(function(){}()) === 0. Actual: ' + new String(__obj).lastIndexOf(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T1.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T1.js new file mode 100644 index 0000000000..da1ba6bd97 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T1.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: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T1 +description: Override toString and valueOf functions, valueOf throw exception +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + throw "intointeger"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __str.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intointeger") { + throw new Test262Error('#1.1: Exception === "intointeger". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T2.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T2.js new file mode 100644 index 0000000000..a75fbedea6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T2.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: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T2 +description: > + Override toString and valueOf functions, second toString 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.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __str.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intointeger") { + throw new Test262Error('#1.1: Exception === "intointeger". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T3.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T3.js new file mode 100644 index 0000000000..944857f3f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T3.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: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T3 +description: Override toString and valueOf functions +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return {}; + }, + toString: function() {} +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041BABAB".lastIndexOf(__obj, __obj2) !== 7) { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041B";}}; var __obj2 = {valueOf:function(){return {};},toString:function(){}}; "ABB\\u0041BABAB".lastIndexOf(__obj, __obj2)===7. Actual: ' + ("ABB\u0041BABAB".lastIndexOf(__obj, __obj2))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T4.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T4.js new file mode 100644 index 0000000000..7994195012 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T4.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T4 +description: Override toString and valueOf functions, and they throw exceptions +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +}; +var __obj2 = { + valueOf: function() { + throw "intoint"; + } +}; +var __instance = new Number(10001.10001); +Number.prototype.lastIndexOf = String.prototype.lastIndexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __instance.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T5.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T5.js new file mode 100644 index 0000000000..4921647303 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T5.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T5 +description: > + Override toString and valueOf functions, first and second valueOf + throw exception +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +}; + +var __obj2 = { + valueOf: function() { + throw "intointeger"; + } +}; + +__FACTORY.prototype.lastIndexOf = String.prototype.lastIndexOf; + +var __instance = new __FACTORY(void 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __instance.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(value) { + this.value = value; + this.toString = function() { + return new Number; + }; + this.valueOf = function() { + return this.value + "" + }; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A6.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A6.js new file mode 100644 index 0000000000..8bd0287c74 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf has not prototype property +es5id: 15.5.4.8_A6 +description: Checking String.prototype.lastIndexOf.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.lastIndexOf.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.lastIndexOf.prototype === undefined. Actual: ' + String.prototype.lastIndexOf.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A7.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A7.js new file mode 100644 index 0000000000..0838bbcd81 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A7.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.lastIndexOf can't be used as constructor +es5id: 15.5.4.8_A7 +description: Checking if creating the String.prototype.lastIndexOf object fails +---*/ + +var FACTORY = String.prototype.lastIndexOf; + +assert.throws(TypeError, function() { + new FACTORY; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A8.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A8.js new file mode 100644 index 0000000000..ab788685bc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A8.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: | + The String.prototype.lastIndexOf.length property has the attribute + DontEnum +es5id: 15.5.4.8_A8 +description: > + Checking if enumerating the String.prototype.lastIndexOf.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.lastIndexOf.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.lastIndexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.lastIndexOf.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.lastIndexOf.propertyIsEnumerable(\'length\') return false. Actual: ' + String.prototype.lastIndexOf.propertyIsEnumerable('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.lastIndexOf) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.lastIndexOf){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A9.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A9.js new file mode 100644 index 0000000000..d592c5357d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A9.js @@ -0,0 +1,38 @@ +// 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.lastIndexOf.length property does not have the + attribute DontDelete +es5id: 15.5.4.8_A9 +description: > + Checking if deleting the String.prototype.lastIndexOf.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.lastIndexOf.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.lastIndexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.lastIndexOf.length) { + throw new Test262Error('#1: delete String.prototype.lastIndexOf.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.lastIndexOf.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/browser.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js new file mode 100644 index 0000000000..62353147a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/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.9 +description: > + String.prototype.lastIndexOf.name is "lastIndexOf". +info: | + String.prototype.lastIndexOf ( searchString [ , position ] ) + + 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.lastIndexOf.name, "lastIndexOf"); + +verifyNotEnumerable(String.prototype.lastIndexOf, "name"); +verifyNotWritable(String.prototype.lastIndexOf, "name"); +verifyConfigurable(String.prototype.lastIndexOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js new file mode 100644 index 0000000000..14485de716 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/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.lastIndexOf 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.lastIndexOf), + false, + 'isConstructor(String.prototype.lastIndexOf) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.lastIndexOf(); +}, '`new String.prototype.lastIndexOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/shell.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..e8ceaa298d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/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.lastindexof +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var lastIndexOf = String.prototype.lastIndexOf; + +assert.sameValue(typeof lastIndexOf, 'function'); + +assert.throws(TypeError, function() { + lastIndexOf.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + lastIndexOf.call(null, ''); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/15.5.4.9_3.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/15.5.4.9_3.js new file mode 100644 index 0000000000..35f29b09bf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/15.5.4.9_3.js @@ -0,0 +1,25 @@ +// Copyright 2013 Mozilla Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +es5id: 15.5.4.9_3 +description: > + Tests that String.prototype.localeCompare treats a missing "that" + argument, undefined, and "undefined" as equivalent. +author: Norbert Lindenberg +---*/ + +var thisValues = ["a", "t", "u", "undefined", "UNDEFINED", "nicht definiert", "xyz", "未定义"]; + +var i; +for (i = 0; i < thisValues.length; i++) { + var thisValue = thisValues[i]; + if (thisValue.localeCompare() !== thisValue.localeCompare(undefined)) { + throw new Test262Error("String.prototype.localeCompare does not treat missing 'that' argument as undefined."); + } + if (thisValue.localeCompare(undefined) !== thisValue.localeCompare("undefined")) { + throw new Test262Error("String.prototype.localeCompare does not treat undefined 'that' argument as \"undefined\"."); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js new file mode 100644 index 0000000000..65f9289ccb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/15.5.4.9_CE.js @@ -0,0 +1,78 @@ +// Copyright 2012 Norbert Lindenberg. All rights reserved. +// Copyright 2012 Mozilla Corporation. All rights reserved. +// Copyright 2013 Microsoft Corporation. All rights reserved. +// Copyright (C) 2022 Richard Gibson. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: > + String.prototype.localeCompare must return 0 when + comparing Strings that are considered canonically equivalent by + the Unicode Standard. +esid: sec-string.prototype.localecompare +info: | + String.prototype.localeCompare ( _that_ [ , _reserved1_ [ , _reserved2_ ] ] ) + + This function must treat Strings that are canonically equivalent + according to the Unicode standard as identical and must return `0` + when comparing Strings that are considered canonically equivalent. +---*/ + +// pairs with characters not in Unicode 3.0 are commented out +var pairs = [ + // example from Unicode 5.0, section 3.7, definition D70 + ["o\u0308", "ö"], + // examples from Unicode 5.0, chapter 3.11 + ["ä\u0323", "a\u0323\u0308"], + ["a\u0308\u0323", "a\u0323\u0308"], + ["ạ\u0308", "a\u0323\u0308"], + ["ä\u0306", "a\u0308\u0306"], + ["ă\u0308", "a\u0306\u0308"], + // example from Unicode 5.0, chapter 3.12 + ["\u1111\u1171\u11B6", "퓛"], + // examples from UTS 10, Unicode Collation Algorithm + ["Å", "Å"], + ["Å", "A\u030A"], + ["x\u031B\u0323", "x\u0323\u031B"], + ["ự", "ụ\u031B"], + ["ự", "u\u031B\u0323"], + ["ự", "ư\u0323"], + ["ự", "u\u0323\u031B"], + // examples from UAX 15, Unicode Normalization Forms + ["Ç", "C\u0327"], + ["q\u0307\u0323", "q\u0323\u0307"], + ["가", "\u1100\u1161"], + ["Å", "A\u030A"], + ["Ω", "Ω"], + ["Å", "A\u030A"], + ["ô", "o\u0302"], + ["ṩ", "s\u0323\u0307"], + ["ḋ\u0323", "d\u0323\u0307"], + ["ḋ\u0323", "ḍ\u0307"], + ["q\u0307\u0323", "q\u0323\u0307"], + // examples involving supplementary characters from UCD NormalizationTest.txt + // ["\uD834\uDD5E", "\uD834\uDD57\uD834\uDD65"], + // ["\uD87E\uDC2B", "北"] +]; + +var i; +for (i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + if (pair[0].localeCompare(pair[1]) !== 0) { + throw new Test262Error("String.prototype.localeCompare considers " + pair[0] + " (" + toU(pair[0]) + + ") ≠ " + pair[1] + " (" + toU(pair[1]) + ")."); + } +} + +function toU(s) { + var result = ""; + var escape = "\\u0000"; + var i; + for (i = 0; i < s.length; i++) { + var hex = s.charCodeAt(i).toString(16); + result += escape.substring(0, escape.length - hex.length) + hex; + } + return result; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A10.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A10.js new file mode 100644 index 0000000000..54f9d6a752 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A10.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.localeCompare.length property has the attribute + ReadOnly +es5id: 15.5.4.9_A10 +description: > + Checking if varying the String.prototype.localeCompare.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.localeCompare.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.localeCompare.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.localeCompare.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.localeCompare.length; + +verifyNotWritable(String.prototype.localeCompare, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.localeCompare.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.localeCompare.length; String.prototype.localeCompare.length = function(){return "shifted";}; String.prototype.localeCompare.length === __obj. Actual: ' + String.prototype.localeCompare.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A11.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A11.js new file mode 100644 index 0000000000..c918779e18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A11.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 length property of the localeCompare method is 1 +es5id: 15.5.4.9_A11 +description: Checking String.prototype.localeCompare.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.localeCompare.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.localeCompare.hasOwnProperty("length") return true. Actual: ' + String.prototype.localeCompare.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.localeCompare.length !== 1) { + throw new Test262Error('#2: String.prototype.localeCompare.length === 1. Actual: ' + String.prototype.localeCompare.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A1_T1.js new file mode 100644 index 0000000000..1ee5c6feed --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A1_T1.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.localeCompare(that) +es5id: 15.5.4.9_A1_T1 +description: This string is symbol and arguments are symbols +---*/ + +var str1 = new String("h"); +//CHECK#1 +var str2 = new String("\x68"); +if (str1.localeCompare(str2) !== 0) { + throw new Test262Error('#1: var str1 = new String("h"); var str2 = new String ("\\x68"); str1.localeCompare(str2)===0. Actual: ' + str1.localeCompare(str2)); +} + +//CHECK#2 +var str2 = new String("\u0068"); +if (str1.localeCompare(str2) !== 0) { + throw new Test262Error('#2: var str1 = new String("h"); var str2 = new String ("\\u0068"); str1.localeCompare(str2)===0. Actual: ' + str1.localeCompare(str2)); +} + +//CHECK#3 +var str2 = new String("h"); +if (str1.localeCompare(str2) !== 0) { + throw new Test262Error('#3: var str1 = new String("h"); var str2 = new String ("h"); str1.localeCompare(str2)===0. Actual: ' + str1.localeCompare(str2)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A1_T2.js new file mode 100644 index 0000000000..c1e239905a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A1_T2.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.localeCompare(that) +es5id: 15.5.4.9_A1_T2 +description: > + Call string_1.localeCompare(string_2) is equal + -string_2.localeCompare(string_1) +---*/ + +//CHECK#1 +var str1 = "h"; +var str2 = "H"; +if (str1.localeCompare(str2) !== -str2.localeCompare(str1)) { + throw new Test262Error('#1.1: var str1 = "h"; var str2 = "H"; str1.localeCompare(str2)===-str2.localeCompare(str1). Actual: ' + str1.localeCompare(str2)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A6.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A6.js new file mode 100644 index 0000000000..0123826201 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.localeCompare has not prototype property +es5id: 15.5.4.9_A6 +description: Checking String.prototype.localeCompare.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.localeCompare.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.localeCompare.prototype === undefined. Actual: ' + String.prototype.localeCompare.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A7.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A7.js new file mode 100644 index 0000000000..70b08ba27f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A7.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.localeCompare can't be used as constructor +es5id: 15.5.4.9_A7 +description: > + Checking if creating the String.prototype.localeCompare object + fails +---*/ + +var __FACTORY = String.prototype.localeCompare; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.localeCompare; __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/localeCompare/S15.5.4.9_A8.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A8.js new file mode 100644 index 0000000000..09b84b3a31 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A8.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: | + The String.prototype.localeCompare.length property has the attribute + DontEnum +es5id: 15.5.4.9_A8 +description: > + Checking if enumerating the String.prototype.localeCompare.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.localeCompare.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.localeCompare.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.localeCompare.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.localeCompare.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.localeCompare.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.localeCompare) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.localeCompare){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A9.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A9.js new file mode 100644 index 0000000000..fe5f58266e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/S15.5.4.9_A9.js @@ -0,0 +1,38 @@ +// 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.localeCompare.length property does not have the + attribute DontDelete +es5id: 15.5.4.9_A9 +description: > + Checking if deleting the String.prototype.localeCompare.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.localeCompare.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.localeCompare.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.localeCompare.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.localeCompare.length) { + throw new Test262Error('#1: delete String.prototype.localeCompare.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.localeCompare.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.localeCompare.length; String.prototype.localeCompare.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.localeCompare.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/browser.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/name.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/name.js new file mode 100644 index 0000000000..81a2062386 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/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.10 +description: > + String.prototype.localeCompare.name is "localeCompare". +info: | + String.prototype.localeCompare ( that [, reserved1 [ , reserved2 ] ] ) + + 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.localeCompare.name, "localeCompare"); + +verifyNotEnumerable(String.prototype.localeCompare, "name"); +verifyNotWritable(String.prototype.localeCompare, "name"); +verifyConfigurable(String.prototype.localeCompare, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/not-a-constructor.js new file mode 100644 index 0000000000..c335172ddc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/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.localeCompare 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.localeCompare), + false, + 'isConstructor(String.prototype.localeCompare) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.localeCompare(); +}, '`new String.prototype.localeCompare()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/shell.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/localeCompare/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/localeCompare/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..c76b2750f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/localeCompare/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.localecompare +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var localeCompare = String.prototype.localeCompare; + +assert.sameValue(typeof localeCompare, 'function'); + +assert.throws(TypeError, function() { + localeCompare.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + localeCompare.call(null, ''); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T10.js new file mode 100644 index 0000000000..0c34ca8972 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T10.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.match (regexp) +es5id: 15.5.4.10_A1_T10 +description: Call match (regexp) function with object argument +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.match(__obj)[0] !== "AB") { + throw new Test262Error('#1: var x; var __obj = {toString:function(){return "\u0041B";}}; var __str = "ABB\u0041BABAB"; __str.match(__obj)[0] ==="AB". Actual: ' + __str.match(__obj)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T11.js new file mode 100644 index 0000000000..7ed0b42606 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T11.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.match (regexp) +es5id: 15.5.4.10_A1_T11 +description: > + Override toString function, toString throw exception, then call + match (regexp) function with this object as argument +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.match(__obj); + throw new Test262Error('#1: "var x = __str.match(__obj)" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T12.js new file mode 100644 index 0000000000..d90588e14f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T12.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.match (regexp) +es5id: 15.5.4.10_A1_T12 +description: > + Override toString and valueOf functions, valueOf throw exception, + then call match (regexp) function with this object as argument +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +} +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.match(__obj); + throw new Test262Error('#1: "var x = __str.match(__obj)" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T13.js new file mode 100644 index 0000000000..3461822606 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T13.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: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T13 +description: > + Override toString and valueOf functions, then call match (regexp) + function with this object as argument +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj)[0] !== "1") { + throw new Test262Error('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; "ABB\\u0041B\\u0031ABAB\\u0031BBAA".match(__obj)[0] ==="1". Actual: ' + ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj)[0])); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj).length !== 1) { + throw new Test262Error('#3: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; "ABB\\u0041B\\u0031ABAB\\u0031BBAA".match(__obj).length === 1. Actual: ' + ("ABB\u0041B\u0031ABAB\u0031BBAA".match(__obj).length)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T14.js new file mode 100644 index 0000000000..cec34fd63a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T14.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T14 +description: > + Call match (regexp) function with RegExp object as argument from + string +---*/ + +var __reg = new RegExp("77"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041BABAB\u0037\u0037BBAA".match(__reg)[0] !== "77") { + throw new Test262Error('#1: var __reg = new RegExp("77"); "ABB\\u0041BABAB\\u0037\\u0037BBAA".match(__reg)[0] === "77". Actual: ' + ("ABB\u0041BABAB\u0037\u0037BBAA".match(__reg)[0])); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T3.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T3.js new file mode 100644 index 0000000000..e8d7c8b47a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T3.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.match (regexp) +es5id: 15.5.4.10_A1_T3 +description: Checking by using eval +---*/ + +var match = String.prototype.match.bind(this); + +try { + this.toString = Object.prototype.toString; +} catch (e) {; +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((this.toString === Object.prototype.toString) && //Ensure we could overwrite global obj's toString + (match(eval("\"bj\""))[0] !== "bj")) { + throw new Test262Error('#1: match = String.prototype.match.bind(this); match(eval("\\"bj\\""))[0] === "bj". Actual: ' + match(eval("\"bj\""))[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T4.js new file mode 100644 index 0000000000..928aae387d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T4.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.match (regexp) +es5id: 15.5.4.10_A1_T4 +description: Call match (regexp) function without arguments of string +---*/ + +var __matched = "".match(); + +var __expected = RegExp().exec(""); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __matched = "".match(); __expected = RegExp().exec(""); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __matched = "".match(); __expected = RegExp().exec(""); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __matched = "".match(); __expected = RegExp().exec(""); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __matched = "".match(); __expected = RegExp().exec(""); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T5.js new file mode 100644 index 0000000000..7fd4c470ef --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T5 +description: Call match (regexp) function with null argument of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" match(null) evaluates to match("null") +if (function() { + return "gnulluna" + }().match(null)[0] !== "null") { + throw new Test262Error('#1: function(){return "gnulluna"}().match(null)[0] === "null". Actual: ' + function() { + return "gnulluna" + }().match(null)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T6.js new file mode 100644 index 0000000000..164c22a560 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T6.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T6 +description: > + Call match (regexp) function with x argument of new String object, + where x is undefined variable +---*/ + +var __matched = new String("undefined").match(x); + +var __expected = RegExp(x).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __matched = new String("undefined").match(x); __expected = RegExp(x).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T7.js new file mode 100644 index 0000000000..3af4c9c7d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T7.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.match (regexp) +es5id: 15.5.4.10_A1_T7 +description: > + Call match (regexp) function with undefined argument of string + object +---*/ + +var __matched = String("undefined").match(undefined); + +var __expected = RegExp(undefined).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __matched = String("undefined").match(undefined); __expected = RegExp(undefined).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T8.js new file mode 100644 index 0000000000..e5c5b25a87 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T8.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T8 +description: Call match (regexp) function with void 0 argument of string object; +---*/ + +var __obj = { + toString: function() {} +}; + +var __matched = String(__obj).match(void 0); + +var __expected = RegExp(void 0).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {toString:function(){}}; __matched = String(__obj).match(void 0); __expected = RegExp(void 0).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T9.js new file mode 100644 index 0000000000..5e6a56d28b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A1_T9.js @@ -0,0 +1,55 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T9 +description: > + Call match (regexp) function with function(){}() argument of + string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +var __matched = new String(__obj).match(function() {}()); + +var __expected = RegExp(undefined).exec("undefined"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__matched.length !== __expected.length) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched.length === __expected.length. Actual: ' + __matched.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__matched.index !== __expected.index) { + throw new Test262Error('#2: __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched.index === __expected.index. Actual: ' + __matched.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__matched.input !== __expected.input) { + throw new Test262Error('#3: __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched.input === __expected.input. Actual: ' + __matched.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__matched[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {valueOf:function(){}, toString:void 0}; __matched = new String(__obj).match(function(){}()); __expected = RegExp(undefined).exec("undefined"); __matched[' + index + ']===__expected[' + index + ']. Actual: ' + __matched[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T1.js new file mode 100644 index 0000000000..2d3d430675 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T1.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T1 +description: Regular expression is 3 +---*/ + +var __string = "1234567890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(3)[0] !== "3") { + throw new Test262Error('#1: __string = "1234567890"; __string.match(3)[0]=== "3". Actual: ' + __string.match(3)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(3).length !== 1) { + throw new Test262Error('#2: __string = "1234567890"; __string.match(3).length ===1. Actual: ' + __string.match(3).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(3).index !== 2) { + throw new Test262Error('#3: __string = "1234567890"; __string.match(3).index ===2. Actual: ' + __string.match(3).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__string.match(3).input !== __string) { + throw new Test262Error('#4: __string = "1234567890"; __string.match(3).input ===__string. Actual: ' + __string.match(3).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T10.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T10.js new file mode 100644 index 0000000000..a39d448e24 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T10.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T10 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = tested_string.lastIndexOf("0") +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; + +__re.lastIndex = __string.lastIndexOf("0"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T11.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T11.js new file mode 100644 index 0000000000..12d441ea85 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T11.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T11 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = tested_string.lastIndexOf("0")+1 +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; + +__re.lastIndex = __string.lastIndexOf("0") + 1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T12.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T12.js new file mode 100644 index 0000000000..8211a34394 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T12.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T12 +description: > + Regular expression is variable that have value /([\d]{5})([-\ + ]?[\d]{4})?$/g +---*/ + +var __matches = ["02134"]; + +var __string = "Boston, MA 02134"; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#2: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T13.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T13.js new file mode 100644 index 0000000000..b7f7053dd3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T13.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T13 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/g. And regular + expression object have property lastIndex = 0 +---*/ + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; +__re.lastIndex = 0; + +var __string = "Boston, MA 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T14.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T14.js new file mode 100644 index 0000000000..6f25e2a095 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T14.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T14 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/g. And regular + expression object have property lastIndex = tested_string.length +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +__re.lastIndex = __string.length; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T15.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T15.js new file mode 100644 index 0000000000..8d4b698a0d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T15.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T15 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. And regular + expression object have property lastIndex = + tested_string.lastIndexOf("0") +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +__re.lastIndex = __string.lastIndexOf("0"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T16.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T16.js new file mode 100644 index 0000000000..6f681db068 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T16.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T16 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. And regular + expression object have property lastIndex = + tested_string.lastIndexOf("0")+1 +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134"]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + +__re.lastIndex = __string.lastIndexOf("0") + 1; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== __matches.length) { + throw new Test262Error('#1: __string.match(__re).length=== __matches.length. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(__re)[0] !== __matches[0]) { + throw new Test262Error('#3: __string.match(__re)[0]===__matches[0]. Actual: ' + __string.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T17.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T17.js new file mode 100644 index 0000000000..d7b517ee21 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T17.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T17 +description: Regular expression is /0./ +---*/ + +var __re = /0./; + +var __num = 10203040506070809000; + +Number.prototype.match = String.prototype.match; + +//__matches = ["02"]; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__num.match(__re)[0] !== "02") { + throw new Test262Error('#1: __num.match(__re)[0]=== "02". Actual: ' + __num.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__num.match(__re).length !== 1) { + throw new Test262Error('#2: __num.match(__re).length ===1. Actual: ' + __num.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__num.match(__re).index !== 1) { + throw new Test262Error('#3: __num.match(__re).index ===1. Actual: ' + __num.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__num.match(__re).input !== String(__num)) { + throw new Test262Error('#4: __num.match(__re).input ===String(__num). Actual: ' + __num.match(__re).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T18.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T18.js new file mode 100644 index 0000000000..72c25da54e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T18.js @@ -0,0 +1,52 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T18 +description: > + Regular expression is /0./. And regular expression object have + property lastIndex = 0 +---*/ + +var __re = /0./; + +__re.lastIndex = 0; + +var __num = 10203040506070809000; + +Number.prototype.match = String.prototype.match; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__num.match(__re)[0] !== "02") { + throw new Test262Error('#1: __num.match(__re)[0]=== "02". Actual: ' + __num.match(__re)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__num.match(__re).length !== 1) { + throw new Test262Error('#2: __num.match(__re).length ===1. Actual: ' + __num.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__num.match(__re).index !== 1) { + throw new Test262Error('#3: __num.match(__re).index ===1. Actual: ' + __num.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__num.match(__re).input !== String(__num)) { + throw new Test262Error('#4: __num.match(__re).input ===String(__num). Actual: ' + __num.match(__re).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T2.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T2.js new file mode 100644 index 0000000000..d9b7f16203 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T2.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T2 +description: Regular expression is /34/g +---*/ + +var __matches = ["34", "34", "34"]; + +var __string = "343443444"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/34/g).length !== 3) { + throw new Test262Error('#1: __string = "343443444"; __string.match(/34/g).length=== 3. Actual: ' + __string.match(/34/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/34/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["34","34","34"]; __string = "343443444"; __string.match(/34/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/34/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T3.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T3.js new file mode 100644 index 0000000000..9401095f72 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T3.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T3 +description: Regular expression is /\d{1}/g +---*/ + +var __matches = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]; + +var __string = "123456abcde7890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/\d{1}/g).length !== 10) { + throw new Test262Error('#1: __string = "123456abcde7890"; __string.match(/\\d{1}/g).length=== 10. Actual: ' + __string.match(/\d{1}/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/\d{1}/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]; __string = "123456abcde7890"; __string.match(/\\d{1}/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/\d{1}/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T4.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T4.js new file mode 100644 index 0000000000..d13b2e87c5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T4.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T4 +description: Regular expression is /\d{2}/g +---*/ + +var __matches = ["12", "34", "56", "78", "90"]; + +var __string = "123456abcde7890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/\d{2}/g).length !== 5) { + throw new Test262Error('#1: __string = "123456abcde7890"; __string.match(/\\d{2}/g).length=== 5. Actual: ' + __string.match(/\d{2}/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/\d{2}/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["12", "34", "56", "78", "90"]; __string = "123456abcde7890"; __string.match(/\\d{2}/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/\d{2}/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T5.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T5.js new file mode 100644 index 0000000000..50285dd9b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T5.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T5 +description: Regular expression is /\D{2}/g +---*/ + +var __matches = ["ab", "cd"]; + +var __string = "123456abcde7890"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/\D{2}/g).length !== 2) { + throw new Test262Error('#1: __string = "123456abcde7890"; __string.match(/\\D{2}/g).length=== 2. Actual: ' + __string.match(/\D{2}/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(/\D{2}/g)[mi] !== __matches[mi]) { + throw new Test262Error('#2.' + mi + ': __matches=["ab", "cd"]; __string = "123456abcde7890"; __string.match(/\\D{2}/g)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(/\D{2}/g)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T6.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T6.js new file mode 100644 index 0000000000..697488c357 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T6.js @@ -0,0 +1,62 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T6 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + void 0 +---*/ + +var __string = "Boston, Mass. 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[0] !== "02134") { + throw new Test262Error('#1: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/)[0]=== "02134". Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[1] !== "02134") { + throw new Test262Error('#2: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/)[1]=== "02134". Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[1]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[2] !== void 0) { + throw new Test262Error('#3: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/)[2]=== void 0. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/)[2]); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).length !== 3) { + throw new Test262Error('#4: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/).length ===3. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#5 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).index !== 14) { + throw new Test262Error('#5: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/).index ===14. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#6 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).input !== __string) { + throw new Test262Error('#6: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/).input ===__string. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/).input); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T7.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T7.js new file mode 100644 index 0000000000..8798673c31 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T7.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T7 +description: Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/g +---*/ + +var __matches = ["02134"]; + +var __string = "Boston, Mass. 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g).length !== 1) { + throw new Test262Error('#1: __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/g).length=== 1. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g)[0] !== __matches[0]) { + throw new Test262Error('#2: __matches=["02134"]; __string = "Boston, Mass. 02134"; __string.match(/([\\d]{5})([-\\ ]?[\\d]{4})?$/g)[0]===__matches[0]. Actual: ' + __string.match(/([\d]{5})([-\ ]?[\d]{4})?$/g)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T8.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T8.js new file mode 100644 index 0000000000..c86d92b66f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T8.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T8 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = 0 +---*/ + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; +__re.lastIndex = 0; + +var __string = "Boston, MA 02134"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __re.lastIndex = 0; __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __matches=["02134", "02134", undefined]; __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T9.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T9.js new file mode 100644 index 0000000000..c8060a22c8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A2_T9.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: match returns array as specified in 15.10.6.2 +es5id: 15.5.4.10_A2_T9 +description: > + Regular expression is /([\d]{5})([-\ ]?[\d]{4})?$/. Last match is + undefined. And regular expression object have property lastIndex + = tested_string.length +---*/ + +var __string = "Boston, MA 02134"; + +var __matches = ["02134", "02134", undefined]; + +var __re = /([\d]{5})([-\ ]?[\d]{4})?$/; + +__re.lastIndex = __string.length; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.match(__re).length !== 3) { + throw new Test262Error('#1: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __string.match(__re).length=== 3. Actual: ' + __string.match(__re).length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__string.match(__re).index !== __string.lastIndexOf("0")) { + throw new Test262Error('#2: __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __re.lastIndex = __string.length; __string.match(__re).index ===__string.lastIndexOf("0"). Actual: ' + __string.match(__re).index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +for (var mi = 0; mi < __matches.length; mi++) { + if (__string.match(__re)[mi] !== __matches[mi]) { + throw new Test262Error('#3.' + mi + ': __string = "Boston, MA 02134"; __re = /([\d]{5})([-\ ]?[\d]{4})?$/; __matches=["02134", "02134", undefined]; __string.match(__re)[' + mi + ']===__matches[' + mi + ']. Actual: ' + __string.match(__re)[mi]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A6.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A6.js new file mode 100644 index 0000000000..aadafa396e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match has not prototype property +es5id: 15.5.4.10_A6 +description: Checking String.prototype.match.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.match.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.match.prototype === undefined. Actual: ' + String.prototype.match.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A7.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A7.js new file mode 100644 index 0000000000..7380da230d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match can't be used as constructor +es5id: 15.5.4.10_A7 +description: Checking if creating "String.prototype.match object" fails +---*/ + +var __FACTORY = String.prototype.match; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.match; __FACTORY = String.prototype.match; __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/match/S15.5.4.10_A8.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A8.js new file mode 100644 index 0000000000..d632dfd429 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A8.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: The String.prototype.match.length property has the attribute DontEnum +es5id: 15.5.4.10_A8 +description: > + Checking if enumerating the String.prototype.match.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.match.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.match.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.match.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.match.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.match.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.match) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.match){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A9.js b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A9.js new file mode 100644 index 0000000000..12c86a3a1f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/S15.5.4.10_A9.js @@ -0,0 +1,38 @@ +// 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.match.length property does not have the attribute + DontDelete +es5id: 15.5.4.10_A9 +description: > + Checking if deleting the String.prototype.match.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.match.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.match.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.match.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.match.length) { + throw new Test262Error('#1: delete String.prototype.match.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.match.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.match.length; String.prototype.match.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.match.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/browser.js b/js/src/tests/test262/built-ins/String/prototype/match/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-get-err.js b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-get-err.js new file mode 100644 index 0000000000..e750a05018 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-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 @@match property +es6id: 21.1.3.11 +info: | + [...] + 3. If regexp is neither undefined nor null, then + a. Let matcher be GetMethod(regexp, @@match). + b. ReturnIfAbrupt(matcher). +features: [Symbol.match] +---*/ + +var obj = {}; +Object.defineProperty(obj, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.match(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-invocation.js b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-invocation.js new file mode 100644 index 0000000000..3e18b8f9eb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-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 @@match property of user-supplied objects +es6id: 21.1.3.11 +info: | + [...] + 3. If regexp is neither undefined nor null, then + a. Let matcher be GetMethod(regexp, @@match). + b. ReturnIfAbrupt(matcher). + c. If matcher is not undefined, then + i. Return Call(matcher, regexp, «O»). +features: [Symbol.match] +---*/ + +var obj = {}; +var returnVal = {}; +var callCount = 0; +var thisVal, args; + +obj[Symbol.match] = function() { + callCount += 1; + thisVal = this; + args = arguments; + return returnVal; +}; + +assert.sameValue(''.match(obj), returnVal); +assert.sameValue(callCount, 1, 'Invokes the method exactly once'); +assert.sameValue(thisVal, obj); +assert.notSameValue(args, undefined); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-is-null.js b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-is-null.js new file mode 100644 index 0000000000..96a2f9b3d6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/cstm-matcher-is-null.js @@ -0,0 +1,35 @@ +// 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.match +description: > + If regexp's Symbol.match property is null, no error is thrown. +info: | + String.prototype.match ( regexp ) + + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@match). + b. If matcher is not undefined, then + [...] + [...] + 5. Return ? Invoke(rx, @@match, « S »). + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. +features: [Symbol.match] +---*/ + +var regexp = {}; +regexp[Symbol.match] = null; +regexp.toString = function() { return "\\d"; }; +regexp.valueOf = function() { throw new Test262Error("should not be called"); }; + +assert.sameValue("abc".match(regexp), null); +assert.sameValue("ab3c".match(regexp)[0], "3"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-groups-properties.js b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-groups-properties.js new file mode 100644 index 0000000000..5cf6bb7691 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-groups-properties.js @@ -0,0 +1,39 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Properties on groups object with duplicate named capture groups +esid: prod-GroupSpecifier +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +const matcher = /(?:(?<x>a)|(?<y>a)(?<x>b))(?:(?<z>c)|(?<z>d))/; + +const threeMatchResult = "abc".match(matcher); +assert.sameValue(threeMatchResult.groups.x, "b", "group x matches b"); +assert.sameValue(threeMatchResult.groups.y, "a", "group y matches a"); +assert.sameValue(threeMatchResult.groups.z, "c", "group z matches c"); +assert.compareArray( + Object.keys(threeMatchResult.groups), + ["x", "y", "z"], + "Properties of groups are ordered in RegExp source order despite y matching before x in this alternative" +); + +const twoMatchResult = "ad".match(matcher); +assert.sameValue(twoMatchResult.groups.x, "a", "group x matches a"); +assert.sameValue(twoMatchResult.groups.y, undefined, "group y does not match"); +assert.sameValue(twoMatchResult.groups.z, "d", "group z matches d"); +assert.compareArray( + Object.keys(twoMatchResult.groups), + ["x", "y", "z"], + "y is still present on groups object, in the right order, despite not matching" +); + +const iteratedMatcher = /(?:(?:(?<x>a)|(?<x>b)|c)\k<x>){2}/; + +const matchedInPrevIterationResult = "aac".match(iteratedMatcher); +assert.sameValue(matchedInPrevIterationResult.groups.x, undefined, "group x does not match in the last iteration"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-indices-groups-properties.js b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-indices-groups-properties.js new file mode 100644 index 0000000000..2548e693a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/duplicate-named-indices-groups-properties.js @@ -0,0 +1,39 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Properties on indices.groups object with duplicate named capture groups +esid: prod-GroupSpecifier +features: [regexp-duplicate-named-groups, regexp-match-indices] +includes: [compareArray.js] +---*/ + +const matcher = /(?:(?<x>a)|(?<y>a)(?<x>b))(?:(?<z>c)|(?<z>d))/d; + +const threeMatchResult = "abc".match(matcher); +assert.compareArray(threeMatchResult.indices.groups.x, [1, 2], "group x matches b"); +assert.compareArray(threeMatchResult.indices.groups.y, [0, 1], "group y matches a"); +assert.compareArray(threeMatchResult.indices.groups.z, [2, 3], "group z matches c"); +assert.compareArray( + Object.keys(threeMatchResult.indices.groups), + ["x", "y", "z"], + "Properties of groups are ordered in RegExp source order despite y matching before x in this alternative" +); + +const twoMatchResult = "ad".match(matcher); +assert.compareArray(twoMatchResult.indices.groups.x, [0, 1], "group x matches a"); +assert.sameValue(twoMatchResult.indices.groups.y, undefined, "group y does not match"); +assert.compareArray(twoMatchResult.indices.groups.z, [1, 2], "group z matches d"); +assert.compareArray( + Object.keys(twoMatchResult.indices.groups), + ["x", "y", "z"], + "y is still present on groups object, in the right order, despite not matching" +); + +const iteratedMatcher = /(?:(?:(?<x>a)|(?<x>b)|c)\k<x>){2}/d; + +const matchedInPrevIterationResult = "aac".match(iteratedMatcher); +assert.sameValue(matchedInPrevIterationResult.indices.groups.x, undefined, "group x does not match in the last iteration"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/invoke-builtin-match.js b/js/src/tests/test262/built-ins/String/prototype/match/invoke-builtin-match.js new file mode 100644 index 0000000000..f33db66deb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/invoke-builtin-match.js @@ -0,0 +1,39 @@ +// 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 @@match property of internally-created RegExps +es6id: 21.1.3.11 +info: | + [...] + 6. Let rx be RegExpCreate(regexp, undefined) (see 21.2.3.2.3). + 7. ReturnIfAbrupt(rx). + 8. Return Invoke(rx, @@match, «S»). +features: [Symbol.match] +---*/ + +var originalMatch = RegExp.prototype[Symbol.match]; +var returnVal = {}; +var result, thisVal, args; + +RegExp.prototype[Symbol.match] = function() { + thisVal = this; + args = arguments; + return returnVal; +}; + +try { + result = 'target'.match('string source'); + + assert(thisVal instanceof RegExp); + assert.sameValue(thisVal.source, 'string source'); + assert.sameValue(thisVal.flags, ''); + assert.sameValue(thisVal.lastIndex, 0); + assert.sameValue(args.length, 1); + assert.sameValue(args[0], 'target'); + assert.sameValue(result, returnVal); +} finally { + RegExp.prototype[Symbol.match] = originalMatch; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/length.js b/js/src/tests/test262/built-ins/String/prototype/match/length.js new file mode 100644 index 0000000000..d3ab6c5320 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/length.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. + +/*--- +es5id: 15.5.4.10_A11 +es6id: 21.1.3.11 +description: Checking String.prototype.match.length +info: | + The length property of the match method is 1. + + ES6 Section 17: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.match.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.match.hasOwnProperty("length") return true. Actual: ' + String.prototype.match.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.match.length !== 1) { + throw new Test262Error('#2: String.prototype.match.length === 1. Actual: ' + String.prototype.match.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +verifyNotEnumerable(String.prototype.match, 'length'); +verifyNotWritable(String.prototype.match, 'length'); +verifyConfigurable(String.prototype.match, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/name.js b/js/src/tests/test262/built-ins/String/prototype/match/name.js new file mode 100644 index 0000000000..09c3133348 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/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.11 +description: > + String.prototype.match.name is "match". +info: | + String.prototype.match ( regexp ) + + 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.match.name, "match"); + +verifyNotEnumerable(String.prototype.match, "name"); +verifyNotWritable(String.prototype.match, "name"); +verifyConfigurable(String.prototype.match, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/match/not-a-constructor.js new file mode 100644 index 0000000000..91f5ec5a8e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/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.match 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.match), + false, + 'isConstructor(String.prototype.match) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.match(); +}, '`new String.prototype.match()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/shell.js b/js/src/tests/test262/built-ins/String/prototype/match/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/match/this-val-bool.js b/js/src/tests/test262/built-ins/String/prototype/match/this-val-bool.js new file mode 100644 index 0000000000..251d574705 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/this-val-bool.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.match (regexp) +es5id: 15.5.4.10_A1_T2 +description: > + Argument is function that return boolean, and instance is Boolean + object +---*/ + +var __instance = new Boolean; + +__instance.match = String.prototype.match; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.match(function() { + return false; + }())[0] !== "false") { + throw new Test262Error('#1: __instance = new Boolean; __instance.match = String.prototype.match; __instance.match(function(){return false;}())[0] === "false". Actual: ' + __instance.match(function() { + return false; + }())[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/this-val-obj.js b/js/src/tests/test262/built-ins/String/prototype/match/this-val-obj.js new file mode 100644 index 0000000000..aa217a541f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/this-val-obj.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.match (regexp) +es5id: 15.5.4.10_A1_T1 +description: Arguments is true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.match = String.prototype.match; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.match(true)[0] !== "true") { + throw new Test262Error('#1: __instance = new Object(true); __instance.match = String.prototype.match; __instance.match(true)[0] === "true". Actual: ' + __instance.match(true)[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/match/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/match/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..7e7d0d64ca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/match/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.match +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var match = String.prototype.match; + +assert.sameValue(typeof match, 'function'); + +assert.throws(TypeError, function() { + match.call(undefined, /./); +}, 'undefined'); + +assert.throws(TypeError, function() { + match.call(null, /./); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/browser.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/flags-nonglobal-throws.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/flags-nonglobal-throws.js new file mode 100644 index 0000000000..c134e85870 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/flags-nonglobal-throws.js @@ -0,0 +1,44 @@ +// Copyright (C) 2019 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Re-throws errors when calling @@matchAll +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If _regexp_ is neither *undefined* nor *null*, then + 1. Let _isRegExp_ be ? IsRegExp(_regexp_). + 1. If _isRegExp_ is true, then + 1. Let _flags_ be ? Get(_regexp_, *"flags"*). + 1. Perform ? RequireObjectCoercible(_flags_). + 1. If ? ToString(_flags_) does not contain *"g"*, throw a *TypeError* exception. +features: [Symbol.matchAll] +---*/ + + +assert.throws(TypeError, function () { + ''.matchAll(/a/); +}); +assert.throws(TypeError, function () { + ''.matchAll(/a/i); +}); +assert.throws(TypeError, function () { + ''.matchAll(/a/m); +}); +assert.throws(TypeError, function () { + ''.matchAll(/a/u); +}); +assert.throws(TypeError, function () { + ''.matchAll(/a/y); +}); + +var regex = /a/; +Object.defineProperty(regex, 'flags', { + value: 'muyi' +}); + +assert.throws(TypeError, function () { + ''.matchAll(regex); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/flags-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/flags-undefined-throws.js new file mode 100644 index 0000000000..9c6928c719 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/flags-undefined-throws.js @@ -0,0 +1,35 @@ +// Copyright (C) 2019 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Re-throws errors when calling @@matchAll +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If _regexp_ is neither *undefined* nor *null*, then + 1. Let _isRegExp_ be ? IsRegExp(_regexp_). + 1. If _isRegExp_ is true, then + 1. Let _flags_ be ? Get(_regexp_, *"flags"*). + 1. Perform ? RequireObjectCoercible(_flags_). + 1. If ? ToString(_flags_) does not contain *"g"*, throw a *TypeError* exception. +features: [Symbol.matchAll] +---*/ + +var regex = /a/g; +Object.defineProperty(regex, 'flags', { value: undefined }); + +assert.throws(TypeError, function () { + ''.matchAll(regex); +}); + +Object.defineProperty(RegExp.prototype, 'flags', { + get: function () { + return undefined; + } +}); + +assert.throws(TypeError, function () { + ''.matchAll(/a/g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/length.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/length.js new file mode 100644 index 0000000000..49fc24912e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: String.prototype.matchAll `length` property +info: | + 17 ECMAScript Standard Built-in Objects: + + [...] + + Every built-in function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are shown using the form «...name») are not included in the default + argument count. + + Unless otherwise specified, the length property of a built-in function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [String.prototype.matchAll] +---*/ + +assert.sameValue(String.prototype.matchAll.length, 1); + +verifyNotEnumerable(String.prototype.matchAll, 'length'); +verifyNotWritable(String.prototype.matchAll, 'length'); +verifyConfigurable(String.prototype.matchAll, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/name.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/name.js new file mode 100644 index 0000000000..efab01207f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: String.prototype.matchAll `name` property +info: | + 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] +features: [String.prototype.matchAll] +---*/ + +assert.sameValue(String.prototype.matchAll.name, 'matchAll'); + +verifyNotEnumerable(String.prototype.matchAll, 'name'); +verifyNotWritable(String.prototype.matchAll, 'name'); +verifyConfigurable(String.prototype.matchAll, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/not-a-constructor.js new file mode 100644 index 0000000000..e4a6ba973c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/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.matchAll 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, String.prototype.matchAll, arrow-function] +---*/ + +assert.sameValue( + isConstructor(String.prototype.matchAll), + false, + 'isConstructor(String.prototype.matchAll) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.matchAll(); +}, '`new String.prototype.matchAll()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/prop-desc.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/prop-desc.js new file mode 100644 index 0000000000..4354fc6ae6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: String.prototype.matchAll property descriptor +info: | + 17 ECMAScript Standard Built-in Objects: + + [...] + + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [String.prototype.matchAll] +---*/ + +assert.sameValue(typeof String.prototype.matchAll, 'function'); + +verifyNotEnumerable(String.prototype, 'matchAll'); +verifyWritable(String.prototype, 'matchAll'); +verifyConfigurable(String.prototype, 'matchAll'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-get-matchAll-throws.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-get-matchAll-throws.js new file mode 100644 index 0000000000..ebab7328b5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-get-matchAll-throws.js @@ -0,0 +1,27 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Re-throws errors when calling @@matchAll +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). + b. If matcher is not undefined, then + i. Return ? Call(matcher, regexp, « O »). +features: [Symbol.matchAll, String.prototype.matchAll] +---*/ + +var regexp = /./g; +Object.defineProperty(regexp, Symbol.matchAll, { + get() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.matchAll(regexp); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-null.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-null.js new file mode 100644 index 0000000000..0244014e4c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-null.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Behavior when regexp is null +info: | + String.prototype.matchAll ( regexp ) + 1. Let O be ? RequireObjectCoercible(this value). + 2. If regexp is neither undefined nor null, then + [...] + 3. Let S be ? ToString(O). + 4. Let rx be ? RegExpCreate(R, "g"). + 5. Return ? Invoke(rx, @@matchAll, « S »). +features: [String.prototype.matchAll] +includes: [compareArray.js, compareIterator.js, regExpUtils.js] +---*/ + +var str = '-null-'; + +assert.compareIterator(str.matchAll(null), [ + matchValidator(['null'], 1, str) +]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-undefined-or-null-invokes-matchAll.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-undefined-or-null-invokes-matchAll.js new file mode 100644 index 0000000000..17a08e3282 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-undefined-or-null-invokes-matchAll.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Behavior when regexp is null or undefined +info: | + String.prototype.matchAll ( regexp ) + 1. Let O be ? RequireObjectCoercible(this value). + 2. If regexp is neither undefined nor null, then + [...] + 3. Let S be ? ToString(O). + 4. Let rx be ? RegExpCreate(R, "g"). + 5. Return ? Invoke(rx, @@matchAll, « S »). +features: [String.prototype.matchAll] +---*/ + +var callCount = 0; +var obj = {}; +RegExp.prototype[Symbol.matchAll] = function() { + callCount++; + return obj; +}; + +assert.sameValue('a'.matchAll(null), obj); +assert.sameValue(callCount, 1); + +assert.sameValue(''.matchAll(undefined), obj); +assert.sameValue(callCount, 2); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-undefined.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-undefined.js new file mode 100644 index 0000000000..255c0d5a09 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-is-undefined.js @@ -0,0 +1,30 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Behavior when regexp is null +info: | + String.prototype.matchAll ( regexp ) + 1. Let O be ? RequireObjectCoercible(this value). + 2. If regexp is neither undefined nor null, then + [...] + 3. Return ? MatchAllIterator(regexp, O). + + MatchAllIterator( regexp, O ) + [...] + 2. If ? IsRegExp(regexp) is true, then + [...] + 3. Else, + a. Let R be RegExpCreate(regexp, "g"). +features: [String.prototype.matchAll] +includes: [compareArray.js, compareIterator.js, regExpUtils.js] +---*/ + +var str = 'a'; + +assert.compareIterator(str.matchAll(undefined), [ + matchValidator([''], 0, str), + matchValidator([''], 1, str) +]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-invocation.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-invocation.js new file mode 100644 index 0000000000..0246337834 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-invocation.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Invocation of @@matchAll property of user-supplied RegExp objects +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). + b. If matcher is not undefined, then + i. Return ? Call(matcher, regexp, « O »). +features: [Symbol.matchAll, String.prototype.matchAll] +---*/ + +var obj = {}; +var returnVal = {}; +var callCount = 0; +var thisVal, args; + +obj[Symbol.matchAll] = function () { + callCount++; + thisVal = this; + args = arguments; + return returnVal; +}; + +var str = ''; + +assert.sameValue(str.matchAll(obj), returnVal); +assert.sameValue(callCount, 1, 'Invokes the method exactly once'); +assert.sameValue(thisVal, obj); +assert.notSameValue(args, undefined); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], str); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-is-undefined-or-null.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-is-undefined-or-null.js new file mode 100644 index 0000000000..ae29ed7feb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-is-undefined-or-null.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Behavior when regexp[@@matchAll] is undefined or null +info: | + String.prototype.matchAll ( regexp ) + 1. Let O be ? RequireObjectCoercible(this value). + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). + b. If matcher is not undefined, then + [...] + 3. Let S be ? ToString(O). + 4. Let rx be ? RegExpCreate(R, "g"). + 5. Return ? Invoke(rx, @@matchAll, « S »). +features: [Symbol.matchAll, String.prototype.matchAll] +---*/ + +var regexp = /./g; +var callCount = 0; +var arg; +var obj = {}; +var str = 'abc'; +RegExp.prototype[Symbol.matchAll] = function(string) { + arg = string; + callCount++; + return obj; +}; + +regexp[Symbol.matchAll] = undefined; +assert.sameValue(str.matchAll(regexp), obj); +assert.sameValue(arg, str); +assert.sameValue(callCount, 1); + +regexp[Symbol.matchAll] = null; +assert.sameValue(str.matchAll(regexp), obj); +assert.sameValue(arg, str); +assert.sameValue(callCount, 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-not-callable.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-not-callable.js new file mode 100644 index 0000000000..647b38fb66 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-not-callable.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Behavior when regexp[@@matchAll] is not callable +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). +features: [Symbol.matchAll, String.prototype.matchAll] +---*/ + +assert.sameValue(typeof String.prototype.matchAll, "function"); + +var regexp = /./; + +regexp[Symbol.matchAll] = true; +assert.throws(TypeError, function() { + ''.matchAll(regexp); +}); + +regexp[Symbol.matchAll] = 5; +assert.throws(TypeError, function() { + ''.matchAll(regexp); +}); + +regexp[Symbol.matchAll] = ''; +assert.throws(TypeError, function() { + ''.matchAll(regexp); +}); + +regexp[Symbol.matchAll] = Symbol(); +assert.throws(TypeError, function() { + ''.matchAll(regexp); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-throws.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-throws.js new file mode 100644 index 0000000000..343aaddfbb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-matchAll-throws.js @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Re-throws errors when calling @@matchAll +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). +features: [Symbol.matchAll, String.prototype.matchAll] +---*/ + +var regexp = /./g; +regexp[Symbol.matchAll] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + ''.matchAll(regexp); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-get-matchAll-throws.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-get-matchAll-throws.js new file mode 100644 index 0000000000..dbad3f4b1d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-get-matchAll-throws.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Re-throws errors thrown while accessing RegExp's @@matchAll property +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). +features: [Symbol.matchAll] +---*/ + +Object.defineProperty(RegExp.prototype, Symbol.matchAll, { + get() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.matchAll(/./g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-has-no-matchAll.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-has-no-matchAll.js new file mode 100644 index 0000000000..bd1d5fd466 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-has-no-matchAll.js @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Behavior when @@matchAll is removed from RegExp's prototype +info: | + String.prototype.matchAll ( regexp ) + 1. Let O be ? RequireObjectCoercible(this value). + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). + b. If matcher is not undefined, then + [...] + [...] + 4. Let rx be ? RegExpCreate(R, "g"). + 5. Return ? Invoke(rx, @@matchAll, « S »). + +features: [Symbol.matchAll, String.prototype.matchAll] +---*/ + +assert.sameValue(typeof String.prototype.matchAll, "function"); + +delete RegExp.prototype[Symbol.matchAll]; +var str = '/a/g*/b/g'; + +assert.throws(TypeError, function() { + str.matchAll(/\w/g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-invocation.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-invocation.js new file mode 100644 index 0000000000..0da71822e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-invocation.js @@ -0,0 +1,38 @@ +// Copyright (C) 2018 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Behavior when invoking of @@matchAll +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). + b. If matcher is not undefined, then + i. Return ? Call(matcher, regexp, « O »). +features: [Symbol.matchAll] +---*/ + +var obj = {}; +var returnVal = {}; +var callCount = 0; +var thisVal, args; + +RegExp.prototype[Symbol.matchAll] = function() { + callCount++; + thisVal = this; + args = arguments; + return returnVal; +}; + +var regexp = /./g; +var str = ''; + +assert.sameValue(str.matchAll(regexp), returnVal); +assert.sameValue(callCount, 1, 'Invokes the method exactly once'); +assert.sameValue(thisVal, regexp); +assert.notSameValue(args, undefined); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], str); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-throws.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-throws.js new file mode 100644 index 0000000000..febeeb440c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/regexp-prototype-matchAll-throws.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: Re-throws errors when calling @@matchAll +info: | + String.prototype.matchAll ( regexp ) + [...] + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). + b. If matcher is not undefined, then + i. Return ? Call(matcher, regexp, « O »). +features: [Symbol.matchAll] +---*/ + +RegExp.prototype[Symbol.matchAll] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + ''.matchAll(/./g); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/shell.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/shell.js new file mode 100644 index 0000000000..b2377bc5bc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/shell.js @@ -0,0 +1,150 @@ +// GENERATED, DO NOT EDIT +// file: compareIterator.js +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Compare the values of an iterator with an array of expected values +defines: [assert.compareIterator] +---*/ + +// Example: +// +// function* numbers() { +// yield 1; +// yield 2; +// yield 3; +// } +// +// assert.compareIterator(numbers(), [ +// v => assert.sameValue(v, 1), +// v => assert.sameValue(v, 2), +// v => assert.sameValue(v, 3), +// ]); +// +assert.compareIterator = function(iter, validators, message) { + message = message || ''; + + var i, result; + for (i = 0; i < validators.length; i++) { + result = iter.next(); + assert(!result.done, 'Expected ' + i + ' values(s). Instead iterator only produced ' + (i - 1) + ' value(s). ' + message); + validators[i](result.value); + } + + result = iter.next(); + assert(result.done, 'Expected only ' + i + ' values(s). Instead iterator produced more. ' + message); + assert.sameValue(result.value, undefined, 'Expected value of `undefined` when iterator completes. ' + message); +} + +// file: regExpUtils.js +// Copyright (C) 2017 Mathias Bynens. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Collection of functions used to assert the correctness of RegExp objects. +defines: [buildString, testPropertyEscapes, testPropertyOfStrings, testExtendedCharacterClass, matchValidator] +---*/ + +function buildString(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const loneCodePoints = args.loneCodePoints; + const ranges = args.ranges; + const CHUNK_SIZE = 10000; + let result = Reflect.apply(String.fromCodePoint, null, loneCodePoints); + for (let i = 0; i < ranges.length; i++) { + const range = ranges[i]; + const start = range[0]; + const end = range[1]; + const codePoints = []; + for (let length = 0, codePoint = start; codePoint <= end; codePoint++) { + codePoints[length++] = codePoint; + if (length === CHUNK_SIZE) { + result += Reflect.apply(String.fromCodePoint, null, codePoints); + codePoints.length = length = 0; + } + } + result += Reflect.apply(String.fromCodePoint, null, codePoints); + } + return result; +} + +function printCodePoint(codePoint) { + const hex = codePoint + .toString(16) + .toUpperCase() + .padStart(6, "0"); + return `U+${hex}`; +} + +function printStringCodePoints(string) { + const buf = []; + for (const symbol of string) { + const formatted = printCodePoint(symbol.codePointAt(0)); + buf.push(formatted); + } + return buf.join(' '); +} + +function testPropertyEscapes(regExp, string, expression) { + if (!regExp.test(string)) { + for (const symbol of string) { + const hex = printCodePoint(symbol.codePointAt(0)); + assert( + regExp.test(symbol), + `\`${ expression }\` should match U+${ hex } (\`${ symbol }\`)` + ); + } + } +} + +function testPropertyOfStrings(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const regExp = args.regExp; + const expression = args.expression; + const matchStrings = args.matchStrings; + const nonMatchStrings = args.nonMatchStrings; + const allStrings = matchStrings.join(''); + if (!regExp.test(allStrings)) { + for (const string of matchStrings) { + assert( + regExp.test(string), + `\`${ expression }\` should match ${ string } (U+${ printStringCodePoints(string) })` + ); + } + } + + const allNonMatchStrings = nonMatchStrings.join(''); + if (regExp.test(allNonMatchStrings)) { + for (const string of nonMatchStrings) { + assert( + !regExp.test(string), + `\`${ expression }\` should not match ${ string } (U+${ printStringCodePoints(string) })` + ); + } + } +} + +// The exact same logic can be used to test extended character classes +// as enabled through the RegExp `v` flag. This is useful to test not +// just standalone properties of strings, but also string literals, and +// set operations. +const testExtendedCharacterClass = testPropertyOfStrings; + +// Returns a function that validates a RegExp match result. +// +// Example: +// +// var validate = matchValidator(['b'], 1, 'abc'); +// validate(/b/.exec('abc')); +// +function matchValidator(expectedEntries, expectedIndex, expectedInput) { + return function(match) { + assert.compareArray(match, expectedEntries, 'Match entries'); + assert.sameValue(match.index, expectedIndex, 'Match index'); + assert.sameValue(match.input, expectedInput, 'Match input'); + } +} diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/this-val-non-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/this-val-non-obj-coercible.js new file mode 100644 index 0000000000..6e214fc416 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/this-val-non-obj-coercible.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: The `this` value cannot be coerced into an object +info: | + String.prototype.matchAll ( regexp ) + 1. Let O be RequireObjectCoercible(this value). +features: [String.prototype.matchAll] +---*/ + +var matchAll = String.prototype.matchAll; + +assert.sameValue(typeof matchAll, 'function'); + +assert.throws(TypeError, function() { + matchAll.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + matchAll.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/matchAll/toString-this-val.js b/js/src/tests/test262/built-ins/String/prototype/matchAll/toString-this-val.js new file mode 100644 index 0000000000..6652e29f06 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/matchAll/toString-this-val.js @@ -0,0 +1,43 @@ +// Copyright (C) 2018 Peter Wong. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: pending +description: | + Verify ToString is called when regexp[@@matchAll] is undefined or null +info: | + String.prototype.matchAll ( regexp ) + 1. Let O be ? RequireObjectCoercible(this value). + 2. If regexp is neither undefined nor null, then + a. Let matcher be ? GetMethod(regexp, @@matchAll). + b. If matcher is not undefined, then + [...] + 3. Let S be ? ToString(O). + 4. Let rx be ? RegExpCreate(R, "g"). + 5. Return ? Invoke(rx, @@matchAll, « S »). +features: [Symbol.matchAll, String.prototype.matchAll] +---*/ + +var regexp = /./; +var callCount = 0; +var arg; +var obj = {}; +var toStringResult = 'abc'; +var receiver = { + [Symbol.toPrimitive]: function() { + callCount++; + return toStringResult; + } +}; +RegExp.prototype[Symbol.matchAll] = function(string) { + arg = string; +}; + +String.prototype.matchAll.call(receiver, null); +assert.sameValue(callCount, 1); +assert.sameValue(arg, toStringResult); + +String.prototype.matchAll.call(receiver, undefined); +assert.sameValue(callCount, 2); +assert.sameValue(arg, toStringResult); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/browser.js b/js/src/tests/test262/built-ins/String/prototype/normalize/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/form-is-not-valid-throws.js b/js/src/tests/test262/built-ins/String/prototype/normalize/form-is-not-valid-throws.js new file mode 100644 index 0000000000..85db8ba768 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/form-is-not-valid-throws.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Throws a RangeError if ToString(form) value is not a valid form name. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError + exception. +---*/ + +assert.throws(RangeError, function() { + 'foo'.normalize('bar'); +}); + +assert.throws(RangeError, function() { + 'foo'.normalize('NFC1'); +}); + +assert.throws(RangeError, function() { + 'foo'.normalize(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/length.js b/js/src/tests/test262/built-ins/String/prototype/normalize/length.js new file mode 100644 index 0000000000..f95c97046e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + String.prototype.normalize.length value and descriptor. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.normalize.length, 0, + 'The value of `String.prototype.normalize.length` is `0`' +); + +verifyNotEnumerable(String.prototype.normalize, 'length'); +verifyNotWritable(String.prototype.normalize, 'length'); +verifyConfigurable(String.prototype.normalize, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/name.js b/js/src/tests/test262/built-ins/String/prototype/normalize/name.js new file mode 100644 index 0000000000..e3d3ef3acc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + String.prototype.normalize.name value and descriptor. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.normalize.name, 'normalize', + 'The value of `String.prototype.normalize.name` is `"normalize"`' +); + +verifyNotEnumerable(String.prototype.normalize, 'name'); +verifyNotWritable(String.prototype.normalize, 'name'); +verifyConfigurable(String.prototype.normalize, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/normalize.js b/js/src/tests/test262/built-ins/String/prototype/normalize/normalize.js new file mode 100644 index 0000000000..4304be9bbf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/normalize.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Property type and descriptor. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof String.prototype.normalize, + 'function', + '`typeof String.prototype.normalize` is `function`' +); + +verifyNotEnumerable(String.prototype, 'normalize'); +verifyWritable(String.prototype, 'normalize'); +verifyConfigurable(String.prototype, 'normalize'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/normalize/not-a-constructor.js new file mode 100644 index 0000000000..e1c16b4e10 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/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.normalize 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.normalize), + false, + 'isConstructor(String.prototype.normalize) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.normalize(); +}, '`new String.prototype.normalize()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form-as-symbol.js new file mode 100644 index 0000000000..b8e6a56ec8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form-as-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(form) as a Symbol. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). +features: [Symbol] +---*/ + +var s = Symbol('foo'); + +assert.throws(TypeError, function() { + 'foo'.normalize(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form.js new file mode 100644 index 0000000000..907bc55a05 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-form.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. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(form) +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + 'foo'.normalize(o); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this-as-symbol.js new file mode 100644 index 0000000000..67004180bc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this-as-symbol.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(this) where this is a Symbol +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol] +---*/ + +var s = Symbol('foo'); + +assert.throws(TypeError, function() { + String.prototype.normalize.call(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this.js new file mode 100644 index 0000000000..217a13754b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns abrupt from ToString(this) +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.normalize.call(o); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-from-coerced-form.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-from-coerced-form.js new file mode 100644 index 0000000000..63c4f5a3c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-from-coerced-form.js @@ -0,0 +1,43 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns normalized string from coerced form. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + 5. Let f be ToString(form). + 6. ReturnIfAbrupt(f). + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError + exception. + 8. Let ns be the String value that is the result of normalizing S into the + normalization form named by f as specified in + http://www.unicode.org/reports/tr15/tr15-29.html. + 9. Return ns. +---*/ + +var s = '\u00C5\u2ADC\u0958\u2126\u0344'; +var nfc = '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301'; +var nfd = 'A\u030A\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301'; +var o = { + toString: function() { + return 'NFC'; + } +}; + +assert.sameValue(s.normalize(['NFC']), nfc, 'coerced array - NFC'); +assert.sameValue(s.normalize(o), nfc, 'coerced object - NFC'); + +o = { + toString: function() { + return 'NFD'; + } +}; + +assert.sameValue(s.normalize(['NFD']), nfd, 'coerced array - NFD'); +assert.sameValue(s.normalize(o), nfd, 'coerced object - NFD'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-using-default-parameter.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-using-default-parameter.js new file mode 100644 index 0000000000..06219727ba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string-using-default-parameter.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns normalized string. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 4. If form is not provided or form is undefined, let form be "NFC". + ... + 8. Let ns be the String value that is the result of normalizing S into the + normalization form named by f as specified in + http://www.unicode.org/reports/tr15/tr15-29.html. + 9. Return ns. +---*/ + +var s = '\u00C5\u2ADC\u0958\u2126\u0344'; +var nfc = '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301'; + +assert.sameValue(s.normalize(), nfc, 'Use NFC as the default form'); +assert.sameValue(s.normalize(undefined), nfc, 'Use NFC as the default form'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string.js b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string.js new file mode 100644 index 0000000000..d7caf14ea7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/return-normalized-string.js @@ -0,0 +1,50 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Returns normalized string. +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + ... + 7. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError + exception. + 8. Let ns be the String value that is the result of normalizing S into the + normalization form named by f as specified in + http://www.unicode.org/reports/tr15/tr15-29.html. + 9. Return ns. +---*/ + +var s = '\u1E9B\u0323'; + +assert.sameValue(s.normalize('NFC'), '\u1E9B\u0323', 'Normalized on NFC'); +assert.sameValue(s.normalize('NFD'), '\u017F\u0323\u0307', 'Normalized on NFD'); +assert.sameValue(s.normalize('NFKC'), '\u1E69', 'Normalized on NFKC'); +assert.sameValue(s.normalize('NFKD'), '\u0073\u0323\u0307', 'Normalized on NFKD'); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFC'), + '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFC' +); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFD'), + 'A\u030A\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFD' +); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFKC'), + '\xC5\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFKC' +); + +assert.sameValue( + '\u00C5\u2ADC\u0958\u2126\u0344'.normalize('NFKD'), + 'A\u030A\u2ADD\u0338\u0915\u093C\u03A9\u0308\u0301', + 'Normalized on NFKD' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/shell.js b/js/src/tests/test262/built-ins/String/prototype/normalize/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-null-throws.js new file mode 100644 index 0000000000..899eec94fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-null-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Throws TypeError when `this` is null +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.normalize.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-undefined-throws.js new file mode 100644 index 0000000000..41ef7ba087 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/normalize/this-is-undefined-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.12 +description: > + Throws TypeError when `this` is undefined +info: | + 21.1.3.12 String.prototype.normalize ( [ form ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.normalize.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/browser.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-fill-string-symbol.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-fill-string-symbol.js new file mode 100644 index 0000000000..37b9eb63ce --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-fill-string-symbol.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should fail if given a Symbol fillString. +author: Jordan Harband +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + 'abc'.padEnd(10, Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-not-object-coercible.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-not-object-coercible.js new file mode 100644 index 0000000000..ba7c08faf1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-not-object-coercible.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: > + String#padEnd should fail if given a null or undefined value, + or an object not coercible to a string. +author: Jordan Harband +---*/ + +assert.throws(TypeError, function() { + String.prototype.padEnd.call(null); +}); + +assert.throws(TypeError, function() { + String.prototype.padEnd.call(undefined); +}); + +var notCoercible = { + toString: function() { + throw new Test262Error('attempted toString'); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.padEnd.call(notCoercible); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-symbol.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-symbol.js new file mode 100644 index 0000000000..deac35a8b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/exception-symbol.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should fail if given a Symbol receiver. +author: Jordan Harband +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + String.prototype.padEnd.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-empty.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-empty.js new file mode 100644 index 0000000000..e22ee5a185 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-empty.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: > + String#padEnd should return the string unchanged when + an explicit empty string is provided +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padEnd(5, ''), 'abc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-non-strings.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-non-strings.js new file mode 100644 index 0000000000..76bbe749ce --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-non-strings.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should stringify a non-string fillString value +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padEnd(10, false), 'abcfalsefa'); +assert.sameValue('abc'.padEnd(10, true), 'abctruetru'); +assert.sameValue('abc'.padEnd(10, null), 'abcnullnul'); +assert.sameValue('abc'.padEnd(10, 0), 'abc0000000'); +assert.sameValue('abc'.padEnd(10, -0), 'abc0000000'); +assert.sameValue('abc'.padEnd(10, NaN), 'abcNaNNaNN'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-omitted.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-omitted.js new file mode 100644 index 0000000000..f0a6c475dc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/fill-string-omitted.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should default to a fillString of " " when omitted +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padEnd(5), 'abc '); +assert.sameValue('abc'.padEnd(5, undefined), 'abc '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/function-length.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-length.js new file mode 100644 index 0000000000..4b38c5a4a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-length.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should have length 1 +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue(String.prototype.padEnd.length, 1, 'Expected String#padEnd.length to be 1'); + +verifyNotEnumerable(String.prototype.padEnd, 'length'); +verifyNotWritable(String.prototype.padEnd, 'length'); +verifyConfigurable(String.prototype.padEnd, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/function-name.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-name.js new file mode 100644 index 0000000000..cf0c201497 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should have name property with value 'padEnd' +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.padEnd.name, + 'padEnd', + 'Expected String#padEnd.name to be "padEnd"' +); + +verifyNotEnumerable(String.prototype.padEnd, 'name'); +verifyNotWritable(String.prototype.padEnd, 'name'); +verifyConfigurable(String.prototype.padEnd, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/function-property-descriptor.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-property-descriptor.js new file mode 100644 index 0000000000..9dd0ce8aec --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/function-property-descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should be writable, non-enumerable, and configurable +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(String.prototype, 'padEnd'); +verifyWritable(String.prototype, 'padEnd'); +verifyConfigurable(String.prototype, 'padEnd'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/max-length-not-greater-than-string.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/max-length-not-greater-than-string.js new file mode 100644 index 0000000000..79a4f59169 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/max-length-not-greater-than-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: > + String#padEnd should return the string unchanged when an integer max + length is not greater than the string length +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padEnd(undefined, 'def'), 'abc'); +assert.sameValue('abc'.padEnd(null, 'def'), 'abc'); +assert.sameValue('abc'.padEnd(NaN, 'def'), 'abc'); +assert.sameValue('abc'.padEnd(-Infinity, 'def'), 'abc'); +assert.sameValue('abc'.padEnd(0, 'def'), 'abc'); +assert.sameValue('abc'.padEnd(-1, 'def'), 'abc'); +assert.sameValue('abc'.padEnd(3, 'def'), 'abc'); +assert.sameValue('abc'.padEnd(3.9999, 'def'), 'abc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/normal-operation.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/normal-operation.js new file mode 100644 index 0000000000..0b5b1023da --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/normal-operation.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should work in the general case +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padEnd(7, 'def'), 'abcdefd'); +assert.sameValue('abc'.padEnd(5, '*'), 'abc**'); + +// surrogate pairs +assert.sameValue('abc'.padEnd(6, '\uD83D\uDCA9'), 'abc\uD83D\uDCA9\uD83D'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/not-a-constructor.js new file mode 100644 index 0000000000..ed5f84458c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/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.padEnd 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.padEnd), + false, + 'isConstructor(String.prototype.padEnd) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.padEnd(); +}, '`new String.prototype.padEnd()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/observable-operations.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/observable-operations.js new file mode 100644 index 0000000000..6af105ca4b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/observable-operations.js @@ -0,0 +1,44 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padend +description: String#padEnd should perform observable operations in the correct order +author: Jordan Harband +---*/ + +var log = ""; + +function createPrimitiveObserver(name, string, value) { + return { + toString: function() { + log += '|toString:' + name; + return string; + }, + valueOf: function() { + log += '|valueOf:' + name; + return value; + } + }; +}; + +var receiver = createPrimitiveObserver('receiver', {}, 'abc'); + +var fillString = createPrimitiveObserver('fillString', {}, 'def'); + +var maxLength = createPrimitiveObserver('maxLength', 11, {}); + +var result = String.prototype.padEnd.call(receiver, maxLength, fillString); + +assert.sameValue(result, 'abcdefdefde'); + +assert.sameValue(log, '|' + [ + 'toString:receiver', + 'valueOf:receiver', + 'valueOf:maxLength', + 'toString:maxLength', + 'toString:fillString', + 'valueOf:fillString' +].join('|'), log); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padEnd/shell.js b/js/src/tests/test262/built-ins/String/prototype/padEnd/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padEnd/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/browser.js b/js/src/tests/test262/built-ins/String/prototype/padStart/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/exception-fill-string-symbol.js b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-fill-string-symbol.js new file mode 100644 index 0000000000..95d085bd77 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-fill-string-symbol.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should fail if given a Symbol fillString. +author: Jordan Harband +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + 'abc'.padStart(10, Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js new file mode 100644 index 0000000000..c690928c09 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: > + String#padStart should fail if given a null or undefined value, + or an object not coercible to a string. +author: Jordan Harband +---*/ + +assert.throws(TypeError, function() { + String.prototype.padStart.call(null); +}); + +assert.throws(TypeError, function() { + String.prototype.padStart.call(undefined); +}); + +var notCoercible = { + toString: function() { + throw new Test262Error('attempted toString'); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.padStart.call(notCoercible); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/exception-symbol.js b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-symbol.js new file mode 100644 index 0000000000..0c9de71626 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-symbol.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should fail if given a Symbol receiver. +author: Jordan Harband +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + String.prototype.padStart.call(Symbol()); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-empty.js b/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-empty.js new file mode 100644 index 0000000000..5d73afac3a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-empty.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: > + String#padStart should return the string unchanged when + an explicit empty string is provided +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padStart(5, ''), 'abc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-non-strings.js b/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-non-strings.js new file mode 100644 index 0000000000..cd1f0edc82 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-non-strings.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should stringify a non-string fillString value +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padStart(10, false), 'falsefaabc'); +assert.sameValue('abc'.padStart(10, true), 'truetruabc'); +assert.sameValue('abc'.padStart(10, null), 'nullnulabc'); +assert.sameValue('abc'.padStart(10, 0), '0000000abc'); +assert.sameValue('abc'.padStart(10, -0), '0000000abc'); +assert.sameValue('abc'.padStart(10, NaN), 'NaNNaNNabc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-omitted.js b/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-omitted.js new file mode 100644 index 0000000000..13a20abf32 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/fill-string-omitted.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should default to a fillString of " " when omitted +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padStart(5), ' abc'); +assert.sameValue('abc'.padStart(5, undefined), ' abc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/function-length.js b/js/src/tests/test262/built-ins/String/prototype/padStart/function-length.js new file mode 100644 index 0000000000..056e797a01 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/function-length.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should have length 1 +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue(String.prototype.padStart.length, 1, 'Expected String#padStart.length to be 1'); + +verifyNotEnumerable(String.prototype.padStart, 'length'); +verifyNotWritable(String.prototype.padStart, 'length'); +verifyConfigurable(String.prototype.padStart, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/function-name.js b/js/src/tests/test262/built-ins/String/prototype/padStart/function-name.js new file mode 100644 index 0000000000..f7fb59889b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/function-name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should have name property with value 'padStart' +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.padStart.name, + 'padStart', + 'Expected String#padStart.name to be "padStart"' +); + +verifyNotEnumerable(String.prototype.padStart, 'name'); +verifyNotWritable(String.prototype.padStart, 'name'); +verifyConfigurable(String.prototype.padStart, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/function-property-descriptor.js b/js/src/tests/test262/built-ins/String/prototype/padStart/function-property-descriptor.js new file mode 100644 index 0000000000..b49c71a64c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/function-property-descriptor.js @@ -0,0 +1,15 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should be writable, non-enumerable, and configurable +author: Jordan Harband +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(String.prototype, 'padStart'); +verifyWritable(String.prototype, 'padStart'); +verifyConfigurable(String.prototype, 'padStart'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/max-length-not-greater-than-string.js b/js/src/tests/test262/built-ins/String/prototype/padStart/max-length-not-greater-than-string.js new file mode 100644 index 0000000000..44476ecad0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/max-length-not-greater-than-string.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: > + String#padStart should return the string unchanged when an integer max + length is not greater than the string length +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padStart(undefined, 'def'), 'abc'); +assert.sameValue('abc'.padStart(null, 'def'), 'abc'); +assert.sameValue('abc'.padStart(NaN, 'def'), 'abc'); +assert.sameValue('abc'.padStart(-Infinity, 'def'), 'abc'); +assert.sameValue('abc'.padStart(0, 'def'), 'abc'); +assert.sameValue('abc'.padStart(-1, 'def'), 'abc'); +assert.sameValue('abc'.padStart(3, 'def'), 'abc'); +assert.sameValue('abc'.padStart(3.9999, 'def'), 'abc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/normal-operation.js b/js/src/tests/test262/built-ins/String/prototype/padStart/normal-operation.js new file mode 100644 index 0000000000..c18a0f58cb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/normal-operation.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should work in the general case +author: Jordan Harband +---*/ + +assert.sameValue('abc'.padStart(7, 'def'), 'defdabc'); +assert.sameValue('abc'.padStart(5, '*'), '**abc'); + +// surrogate pairs +assert.sameValue('abc'.padStart(6, '\uD83D\uDCA9'), '\uD83D\uDCA9\uD83Dabc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/padStart/not-a-constructor.js new file mode 100644 index 0000000000..22ae62b3b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/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.padStart 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.padStart), + false, + 'isConstructor(String.prototype.padStart) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.padStart(); +}, '`new String.prototype.padStart()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/observable-operations.js b/js/src/tests/test262/built-ins/String/prototype/padStart/observable-operations.js new file mode 100644 index 0000000000..470d53fdfd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/observable-operations.js @@ -0,0 +1,44 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: String#padStart should perform observable operations in the correct order +author: Jordan Harband +---*/ + +var log = ""; + +function createPrimitiveObserver(name, string, value) { + return { + toString: function() { + log += '|toString:' + name; + return string; + }, + valueOf: function() { + log += '|valueOf:' + name; + return value; + } + }; +}; + +var receiver = createPrimitiveObserver('receiver', {}, 'abc'); + +var fillString = createPrimitiveObserver('fillString', {}, 'def'); + +var maxLength = createPrimitiveObserver('maxLength', 11, {}); + +var result = String.prototype.padStart.call(receiver, maxLength, fillString); + +assert.sameValue(result, 'defdefdeabc'); + +assert.sameValue(log, '|' + [ + 'toString:receiver', + 'valueOf:receiver', + 'valueOf:maxLength', + 'toString:maxLength', + 'toString:fillString', + 'valueOf:fillString' +].join('|'), log); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/shell.js b/js/src/tests/test262/built-ins/String/prototype/padStart/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/browser.js b/js/src/tests/test262/built-ins/String/prototype/repeat/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js b/js/src/tests/test262/built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js new file mode 100644 index 0000000000..574a1731fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/count-coerced-to-zero-returns-empty-string.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + If ToInteger(count) is zero, returns an empty String. +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 8. Let T be a String value that is made from n copies of S appended together. + If n is 0, T is the empty String. + 9. Return T. +---*/ + +var str = 'ES2015'; + +assert.sameValue(str.repeat(NaN), '', 'str.repeat(NaN) returns ""'); +assert.sameValue(str.repeat(null), '', 'str.repeat(null) returns ""'); +assert.sameValue(str.repeat(undefined), '', 'str.repeat(undefined) returns ""'); +assert.sameValue(str.repeat(false), '', 'str.repeat(false) returns ""'); +assert.sameValue(str.repeat('0'), '', 'str.repeat("0") returns ""'); +assert.sameValue(str.repeat(0.9), '', 'str.repeat(0.9) returns ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/count-is-infinity-throws.js b/js/src/tests/test262/built-ins/String/prototype/repeat/count-is-infinity-throws.js new file mode 100644 index 0000000000..f8ac8b0eba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/count-is-infinity-throws.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Throws a RangeError if count < 0 +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 7. If n is +∞, throw a RangeError exception. +---*/ + +assert.throws(RangeError, function() { + ''.repeat(Infinity); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/count-is-zero-returns-empty-string.js b/js/src/tests/test262/built-ins/String/prototype/repeat/count-is-zero-returns-empty-string.js new file mode 100644 index 0000000000..5a0403b5e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/count-is-zero-returns-empty-string.js @@ -0,0 +1,17 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + If count is zero, returns an empty String. +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 8. Let T be a String value that is made from n copies of S appended together. + If n is 0, T is the empty String. + 9. Return T. +---*/ + +assert.sameValue('foo'.repeat(0), ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/count-less-than-zero-throws.js b/js/src/tests/test262/built-ins/String/prototype/repeat/count-less-than-zero-throws.js new file mode 100644 index 0000000000..3d589395e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/count-less-than-zero-throws.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Throws a RangeError if count < 0 +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 6. If n < 0, throw a RangeError exception. +---*/ + +assert.throws(RangeError, function() { + ''.repeat(-1); +}); + +assert.throws(RangeError, function() { + ''.repeat(-Infinity); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/empty-string-returns-empty.js b/js/src/tests/test262/built-ins/String/prototype/repeat/empty-string-returns-empty.js new file mode 100644 index 0000000000..848bd5417a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/empty-string-returns-empty.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + An empty repeated n times will return an empty string. +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 8. Let T be a String value that is made from n copies of S appended together. + If n is 0, T is the empty String. + 9. Return T. +---*/ + +assert.sameValue(''.repeat(1), '', '"".repeat(1)'); +assert.sameValue(''.repeat(3), '', '"".repeat(3)'); + +var maxSafe32bitInt = 2147483647; +assert.sameValue(''.repeat(maxSafe32bitInt), '', '"".repeat(maxSafe32bitInt)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/length.js b/js/src/tests/test262/built-ins/String/prototype/repeat/length.js new file mode 100644 index 0000000000..2151718be9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + String.prototype.repeat.length value and descriptor. +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.repeat.length, 1, + 'The value of `String.prototype.repeat.length` is `1`' +); + +verifyNotEnumerable(String.prototype.repeat, 'length'); +verifyNotWritable(String.prototype.repeat, 'length'); +verifyConfigurable(String.prototype.repeat, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/name.js b/js/src/tests/test262/built-ins/String/prototype/repeat/name.js new file mode 100644 index 0000000000..3c640857de --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + String.prototype.repeat.name value and descriptor. +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.repeat.name, 'repeat', + 'The value of `String.prototype.repeat.name` is `"repeat"`' +); + +verifyNotEnumerable(String.prototype.repeat, 'name'); +verifyNotWritable(String.prototype.repeat, 'name'); +verifyConfigurable(String.prototype.repeat, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/repeat/not-a-constructor.js new file mode 100644 index 0000000000..b8acfb0e7f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/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.repeat 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.repeat), + false, + 'isConstructor(String.prototype.repeat) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.repeat(); +}, '`new String.prototype.repeat()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/repeat-string-n-times.js b/js/src/tests/test262/built-ins/String/prototype/repeat/repeat-string-n-times.js new file mode 100644 index 0000000000..3e7905c1b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/repeat-string-n-times.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Returns a String made from n copies of the original String appended together. +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 8. Let T be a String value that is made from n copies of S appended together. + If n is 0, T is the empty String. + 9. Return T. +---*/ + +var str = 'abc'; +assert.sameValue(str.repeat(1), str, 'str.repeat(1) === str'); +assert.sameValue(str.repeat(3), 'abcabcabc', 'str.repeat(3) === "abcabcabc"'); + +str = ''; +var i = 0; +var count = 10000; + +while (i < count) { + str += '.'; + i++; +} + +assert.sameValue('.'.repeat(count), str); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/repeat.js b/js/src/tests/test262/built-ins/String/prototype/repeat/repeat.js new file mode 100644 index 0000000000..c6df5c1df3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/repeat.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Property type and descriptor. +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof String.prototype.repeat, + 'function', + '`typeof String.prototype.repeat` is `function`' +); + +verifyNotEnumerable(String.prototype, 'repeat'); +verifyWritable(String.prototype, 'repeat'); +verifyConfigurable(String.prototype, 'repeat'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-count-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-count-as-symbol.js new file mode 100644 index 0000000000..4f316daa43 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-count-as-symbol.js @@ -0,0 +1,21 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Returns abrupt from ToInteger(count) where count is a Symbol +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 4. Let n be ToInteger(count). + 5. ReturnIfAbrupt(n). +features: [Symbol] +---*/ + +var s = Symbol(''); + +assert.throws(TypeError, function() { + ''.repeat(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-count.js b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-count.js new file mode 100644 index 0000000000..a9e8df8091 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-count.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Returns abrupt from ToInteger(count) +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 4. Let n be ToInteger(count). + 5. ReturnIfAbrupt(n). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +} + +assert.throws(Test262Error, function() { + ''.repeat(o); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-this-as-symbol.js new file mode 100644 index 0000000000..58daa15d23 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-this-as-symbol.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Returns abrupt from ToString(this) where this is a Symbol +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol] +---*/ + +var s = Symbol(''); + +assert.throws(TypeError, function() { + String.prototype.repeat.call(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-this.js new file mode 100644 index 0000000000..5576d7108c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Returns abrupt from ToString(this) +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.repeat.call(o); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/shell.js b/js/src/tests/test262/built-ins/String/prototype/repeat/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/repeat/this-is-null-throws.js new file mode 100644 index 0000000000..a93f0e5592 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/this-is-null-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Throws TypeError when `this` is null +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.repeat.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/repeat/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/repeat/this-is-undefined-throws.js new file mode 100644 index 0000000000..0defa229b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/repeat/this-is-undefined-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.13 +description: > + Throws TypeError when `this` is undefined +info: | + 21.1.3.13 String.prototype.repeat ( count ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.repeat.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/15.5.4.11-1.js b/js/src/tests/test262/built-ins/String/prototype/replace/15.5.4.11-1.js new file mode 100644 index 0000000000..e7a7818938 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/15.5.4.11-1.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.11-1 +description: > + 'this' object used by the replaceValue function of a + String.prototype.replace invocation +flags: [noStrict] +---*/ + +var global = this; +var retVal = 'x'.replace(/x/, + function() { + if (this === global) { + return 'y'; + } else { + return 'z'; + } + }); + +assert.sameValue(retVal, 'y', 'retVal'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A12.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A12.js new file mode 100644 index 0000000000..de508e784f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A12.js @@ -0,0 +1,25 @@ +// Copyright 2011 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Call replaceValue passing undefined as the this value +es5id: 15.5.4.11_A12 +description: replaceValue tests that its this value is undefined +flags: [noStrict] +---*/ + +var global = this; +'x'.replace(/x/, function() { + "use strict"; + + if (this === global) { + throw new Test262Error('#1: String replace leaks global'); + } + if (this !== undefined) { + throw new Test262Error('#2: replaceValue should be called with this===undefined. ' + + 'Actual: ' + this); + } + return 'y'; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T1.js new file mode 100644 index 0000000000..7d915749b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T1 +description: Arguments are true and 1, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.replace = String.prototype.replace; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.replace(true, 1) !== "1") { + throw new Test262Error('#1: __instance = new Object(true); __instance.replace = String.prototype.replace; __instance.replace(true, 1) === "1". Actual: ' + __instance.replace(true, 1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T10.js new file mode 100644 index 0000000000..0b021fa5f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T10.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.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T10 +description: > + Call replace (searchValue, replaceValue) function with object and + function arguments of string. Object have overrided toString + function +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +}; + +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__obj, function() { + return x; + }) !== "undefinedBABABAB") { + throw new Test262Error('#1: var x; var __obj = {toString:function(){return "\u0041B";}}; var __str = "ABB\u0041BABAB"; replace(__obj, function(){return x;}) === "undefinedBABABAB". Actual: ' + __str.replace(__obj, function() { + return x; + })); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T11.js new file mode 100644 index 0000000000..0ec448e985 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T11.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T11 +description: > + Call replace (searchValue, replaceValue) function with objects + arguments of string object. Objects have overrided toString + function, that throw exception +---*/ + +var __obj = { + toString: function() { + throw "insearchValue"; + } +}; +var __obj2 = { + toString: function() { + throw "inreplaceValue"; + } +}; +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.replace(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.replace(__obj,__obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "insearchValue") { + throw new Test262Error('#1.1: Exception === "insearchValue". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T12.js new file mode 100644 index 0000000000..43cd91885f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T12.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.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T12 +description: > + Call replace (searchValue, replaceValue) function with objects + arguments of String object. First objects have overrided toString + and valueOf functions, valueOf throw exception. Second objects + have overrided toString function, that throw exception +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "insearchValue"; + } +}; +var __obj2 = { + toString: function() { + throw "inreplaceValue"; + } +}; +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.replace(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.replace(__obj,__obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "insearchValue") { + throw new Test262Error('#1.1: Exception === "insearchValue". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T13.js new file mode 100644 index 0000000000..1a98a4191a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T13.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.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T13 +description: > + Call replace (searchValue, replaceValue) function with objects + arguments of string. First objects have overrided toString and + valueOf functions. Second objects have overrided toString + function, that throw exception +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +}; +var __obj2 = { + toString: function() { + throw "inreplaceValue"; + } +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = "ABB\u0041BABAB\u0031BBAA".replace(__obj, __obj2); + throw new Test262Error('#1: var x = "ABB\\u0041BABAB\\u0031BBAA".replace(__obj,__obj2) lead to throwing exception'); +} catch (e) { + if (e !== "inreplaceValue") { + throw new Test262Error('#1.1: Exception === "inreplaceValue". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T14.js new file mode 100644 index 0000000000..e34b2fe7e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T14.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T14 +description: Instance is string, searchValue is regular expression +---*/ + +var __reg = new RegExp("77"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041BABAB\u0037\u0037BBAA".replace(__reg, 1) !== "ABBABABAB\u0031BBAA") { + throw new Test262Error('#1: var __reg = new RegExp("77"); "ABB\\u0041BABAB\\u0037\\u0037BBAA".replace(__reg, 1) === "ABBABABAB\\u0031BBAA". Actual: ' + ("ABB\u0041BABAB\u0037\u0037BBAA".replace(__reg, 1))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T15.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T15.js new file mode 100644 index 0000000000..7f1f20a554 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T15.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.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T15 +description: Instance is Object, searchValue is regular expression +---*/ + +var __obj = { + toString: function() { + return /77/ + } +}; + +var __instance = new Object(1100.00777001); + +Object.prototype.replace = String.prototype.replace; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.replace(__obj, 1) === "1100.0017001"; + throw new Test262Error('#1.0: x = __instance.replace(__obj, 1) === "1100.0017001" lead to throwing exception'); +} catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error('#1.1: Exception is instance of TypeError. Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T16.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T16.js new file mode 100644 index 0000000000..f38a86b388 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T16.js @@ -0,0 +1,39 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T16 +description: Instance is Number, searchValue is regular expression +---*/ + +var __re = /77/; + +var __instance = new Number(1100.00777001); + +Number.prototype.replace = String.prototype.replace; + +var __obj = { + toString: function() { + return function(a1, a2, a3) { + return a2 + "z" + }; + } +} +//__obj = function(a1,a2,a3){return a2+"z"}; + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.replace(__re, __obj) === "1100.007z7001"; + throw new Test262Error('#1.0: x = __instance.replace(__obj, 1) === "1100.007z7001" lead to throwing exception'); +} catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error('#1.1: Exception is instance of TypeError. Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T17.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T17.js new file mode 100644 index 0000000000..2a74db7349 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T17.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T17 +description: Instance is String object, searchValue is regular expression +---*/ + +var __re = new RegExp(x, "g"); + +var __instance = String("asdf"); + +var __str = "1"; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.replace(__re, __str) !== "1a1s1d1f1") { + throw new Test262Error('#1: var x; var __re = new RegExp(x,"g"); __instance = String("asdf"); __str = "1"; __instance.replace(__re, __str) === "1a1s1d1f1". Actual: ' + __instance.replace(__re, __str)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T2.js new file mode 100644 index 0000000000..7273ab9c74 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T2.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.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T2 +description: > + Argument is function that return boolean, and instance is Boolean + object +---*/ + +var __instance = new Boolean; + +__instance.replace = String.prototype.replace; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.replace(function() { + return false; + }(), x) !== "undefined") { + throw new Test262Error('#1: var x; __instance = new Boolean; __instance.replace = String.prototype.replace; __instance.replace(function(){return false;}(),x) === "undefined". Actual: ' + __instance.replace(function() { + return false; + }(), x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T4.js new file mode 100644 index 0000000000..e21689c161 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T4.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.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T4 +description: > + Call replace (searchValue, replaceValue) function with null and + function(a1,a2,a3){return a2+"";} arguments of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (function() { + return "gnulluna" + }().replace(null, function(a1, a2, a3) { + return a2 + ""; + }) !== "g1una") { + throw new Test262Error('#1: function(){return "gnulluna"}().replace(null,function(a1,a2,a3){return a2+"";}) === "g1una". Actual: ' + function() { + return "gnulluna" + }().replace(null, function(a1, a2, a3) { + return a2 + ""; + })); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T5.js new file mode 100644 index 0000000000..4d7aa0f7ef --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T5.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T5 +description: > + Call replace (searchValue, replaceValue) function with null and + Function() arguments of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (function() { + return "gnulluna" + }().replace(null, Function()) !== "gundefineduna") { + throw new Test262Error('#1: function(){return "gnulluna"}().replace(null, Function()) === "gundefineduna". Actual: ' + function() { + return "gnulluna" + }().replace(null, Function())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T6.js new file mode 100644 index 0000000000..d5ce769257 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T6 +description: > + Call replace (searchValue, replaceValue) function with x and + Function("return arguments[1]+42;") arguments of new String + object. x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (new String("undefined").replace(x, Function("return arguments[1]+42;")) !== "42") { + throw new Test262Error('#1: var x; new String("undefined").replace(x,Function("return arguments[1]+42;")) === "42". Actual: ' + new String("undefined").replace(x, Function("return arguments[1]+42;"))); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T7.js new file mode 100644 index 0000000000..a5071d2fdf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T7 +description: > + Call replace (searchValue, replaceValue) function with string and + undefined arguments of String object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String(void 0).replace("e", undefined) !== "undundefinedfined") { + throw new Test262Error('#1: String(void 0).replace("e",undefined) === "undundefinedfined". Actual: ' + String(void 0).replace("e", undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T8.js new file mode 100644 index 0000000000..c8749a3d73 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T8.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T8 +description: > + Call replace (searchValue, replaceValue) function with regular + expression and void 0 arguments of String object +---*/ + +var __obj = { + toString: function() {} +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String(__obj).replace(/e/g, void 0) !== "undundefinedfinundefinedd") { + throw new Test262Error('#1: __obj = {toString:function(){}}; String(__obj).replace(/e/g,void 0) === "undundefinedfinundefinedd". Actual: ' + String(__obj).replace(/e/g, void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T9.js new file mode 100644 index 0000000000..cfa8895ebe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A1_T9.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.replace (searchValue, replaceValue) +es5id: 15.5.4.11_A1_T9 +description: > + Call replace (searchValue, replaceValue) function with functions + arguments of new String object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (new String(__obj).replace(function() {}(), __func) !== "undefined0undefined") { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; function __func(a1,a2,a3){return a1+a2+a3;}; new String(__obj).replace(function(){}(),__func) === "undefined0undefined". Actual: ' + new String(__obj).replace(function() {}(), __func)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func(a1, a2, a3) { + return a1 + a2 + a3; +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T1.js new file mode 100644 index 0000000000..4e617aa030 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T1 +description: > + Don`t use $ in replaceValue, searchValue is regular expression + /sh/g +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, 'sch') !== 'She sells seaschells by the seaschore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/g; __str.replace(__re,\'sch\')===\'She sells seaschells by the seaschore.\'. Actual: ' + __str.replace(__re, 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T10.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T10.js new file mode 100644 index 0000000000..c1edeff76c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T10.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T10 +description: Use $' in replaceValue, searchValue is regular expression /sh/ +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$'" + 'sch') !== 'She sells seaells by the seashore.schells by the seashore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/; __str.replace(__re, "$\'" + \'sch\')===\'She sells seaells by the seashore.schells by the seashore.\'. Actual: ' + __str.replace(__re, "$'" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T2.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T2.js new file mode 100644 index 0000000000..276487a71e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T2.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T2 +description: Use $$ in replaceValue, searchValue is regular expression /sh/g +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$$" + 'sch') !== 'She sells sea$schells by the sea$schore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/g; __str.replace(__re,"$$" + \'sch\')===\'She sells sea$schells by the sea$schore.\'. Actual: ' + __str.replace(__re, "$$" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T3.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T3.js new file mode 100644 index 0000000000..89c8a6a111 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T3.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T3 +description: Use $& in replaceValue, searchValue is regular expression /sh/g +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$&" + 'sch') !== 'She sells seashschells by the seashschore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/g; __str.replace(__re,"$&" + \'sch\')===\'She sells seashschells by the seashschore.\'. Actual: ' + __str.replace(__re, "$&" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T4.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T4.js new file mode 100644 index 0000000000..b019004f21 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T4.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T4 +description: Use $` in replaceValue, searchValue is regular expression /sh/g +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$`" + 'sch') !== 'She sells seaShe sells seaschells by the seaShe sells seashells by the seaschore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/g; __str.replace(__re, "$`" + \'sch\')===\'She sells seaShe sells seaschells by the seaShe sells seashells by the seaschore.\'. Actual: ' + __str.replace(__re, "$`" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T5.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T5.js new file mode 100644 index 0000000000..2c4cf32b97 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T5 +description: Use $' in replaceValue, searchValue is regular expression /sh/g +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$'" + 'sch') !== 'She sells seaells by the seashore.schells by the seaore.schore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/g; __str.replace(__re, "$\'" + \'sch\')===\'She sells seaells by the seashore.schells by the seaore.schore.\'. Actual: ' + __str.replace(__re, "$'" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T6.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T6.js new file mode 100644 index 0000000000..668ae4a876 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T6 +description: Don`t use $ in replaceValue, searchValue is regular expression /sh/ +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, 'sch') !== 'She sells seaschells by the seashore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/; __str.replace(__re, \'sch\')===\'She sells seaschells by the seashore.\'. Actual: ' + __str.replace(__re, 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T7.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T7.js new file mode 100644 index 0000000000..7d50ab0f8b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T7.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T7 +description: Use $$ in replaceValue, searchValue is regular expression /sh/ +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$$" + 'sch') !== 'She sells sea$schells by the seashore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/; __str.replace(__re, "$$" + \'sch\')===\'She sells sea$schells by the seashore.\'. Actual: ' + __str.replace(__re, "$$" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T8.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T8.js new file mode 100644 index 0000000000..f2611147b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T8.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T8 +description: Use $& in replaceValue, searchValue is regular expression /sh/ +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$&" + 'sch') !== 'She sells seashschells by the seashore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/; __str.replace(__re, "$&" + \'sch\')===\'She sells seashschells by the seashore.\'. Actual: ' + __str.replace(__re, "$&" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T9.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T9.js new file mode 100644 index 0000000000..839d8f02fe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A2_T9.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The $ replacements are done left-to-right, and, once such are placement is performed, the new + replacement text is not subject to further replacements +es5id: 15.5.4.11_A2_T9 +description: Use $` in replaceValue, searchValue is regular expression /sh/ +---*/ + +var __str = 'She sells seashells by the seashore.'; +var __re = /sh/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$`" + 'sch') !== 'She sells seaShe sells seaschells by the seashore.') { + throw new Test262Error('#1: var __str = \'She sells seashells by the seashore.\'; var __re = /sh/; __str.replace(__re, "$`" + \'sch\')===\'She sells seaShe sells seaschells by the seashore.\'. Actual: ' + __str.replace(__re, "$`" + 'sch')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T1.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T1.js new file mode 100644 index 0000000000..56a378494c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T1.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: replace with regexp /(uid=)(\d+)/ returns +es5id: 15.5.4.11_A3_T1 +description: replaceValue is "$11" + 15 +---*/ + +var __str = 'uid=31'; +var __re = /(uid=)(\d+)/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$11" + 15) !== 'uid=115') { + throw new Test262Error('#1: var __str = \'uid=31\'; var __re = /(uid=)(\d+)/; __str.replace(__re, "$11" + 15)===\'uid=115\'. Actual: ' + __str.replace(__re, "$11" + 15)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T2.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T2.js new file mode 100644 index 0000000000..0eb7fd3d83 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T2.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: replace with regexp /(uid=)(\d+)/ returns +es5id: 15.5.4.11_A3_T2 +description: replaceValue is "$11" + '15' +---*/ + +var __str = 'uid=31'; +var __re = /(uid=)(\d+)/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$11" + '15') !== 'uid=115') { + throw new Test262Error('#1: var __str = \'uid=31\'; var __re = /(uid=)(\d+)/; __str.replace(__re, "$11" + \'15\')===\'uid=115\'. Actual: ' + __str.replace(__re, "$11" + '15')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T3.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T3.js new file mode 100644 index 0000000000..d8abc13544 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A3_T3.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: replace with regexp /(uid=)(\d+)/ returns +es5id: 15.5.4.11_A3_T3 +description: replaceValue is "$11" + 'A15' +---*/ + +var __str = 'uid=31'; +var __re = /(uid=)(\d+)/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__re, "$11" + 'A15') !== 'uid=1A15') { + throw new Test262Error('#1: var __str = \'uid=31\'; var __re = /(uid=)(\d+)/; __str.replace(__re, "$11" + \'A15\')===\'uid=1A15\' . Actual: ' + __str.replace(__re, "$11" + 'A15')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T1.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T1.js new file mode 100644 index 0000000000..968f54808e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: replace with regexp /([a-z]+)([0-9]+)/ and replace function returns +es5id: 15.5.4.11_A4_T1 +description: searchValue is /([a-z]+)([0-9]+)/ +---*/ + +var __str = "abc12 def34"; +var __pattern = /([a-z]+)([0-9]+)/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__pattern, __replFN) !== '12abc def34') { + throw new Test262Error('#1: var __str = "abc12 def34"; var __pattern = /([a-z]+)([0-9]+)/; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\'12abc def34\'. Actual: ' + __str.replace(__pattern, __replFN)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __replFN() { + return arguments[2] + arguments[1]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T2.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T2.js new file mode 100644 index 0000000000..35e33a7158 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: replace with regexp /([a-z]+)([0-9]+)/ and replace function returns +es5id: 15.5.4.11_A4_T2 +description: searchValue is /([a-z]+)([0-9]+)/g +---*/ + +var __str = "abc12 def34"; +var __pattern = /([a-z]+)([0-9]+)/g; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__pattern, __replFN) !== '12abc 34def') { + throw new Test262Error('#1: var __str = "abc12 def34"; var __pattern = /([a-z]+)([0-9]+)/g; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\'12abc 34def\'. Actual: ' + __str.replace(__pattern, __replFN)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __replFN() { + return arguments[2] + arguments[1]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T3.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T3.js new file mode 100644 index 0000000000..8dbcb0a9e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T3.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: replace with regexp /([a-z]+)([0-9]+)/ and replace function returns +es5id: 15.5.4.11_A4_T3 +description: searchValue is /([a-z]+)([0-9]+)/i +---*/ + +var __str = "aBc12 def34"; +var __pattern = /([a-z]+)([0-9]+)/i; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__pattern, __replFN) !== '12aBc def34') { + throw new Test262Error('#1: var __str = "aBc12 def34"; var __pattern = /([a-z]+)([0-9]+)/i; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\'12aBc def34\'. Actual: ' + __str.replace(__pattern, __replFN)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __replFN() { + return arguments[2] + arguments[1]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T4.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T4.js new file mode 100644 index 0000000000..c6527a9bad --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A4_T4.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: replace with regexp /([a-z]+)([0-9]+)/ and replace function returns +es5id: 15.5.4.11_A4_T4 +description: searchValue is /([a-z]+)([0-9]+)/ig +---*/ + +var __str = "aBc12 dEf34"; +var __pattern = /([a-z]+)([0-9]+)/ig; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__pattern, __replFN) !== '12aBc 34dEf') { + throw new Test262Error('#1: var __str = "aBc12 dEf34"; var __pattern = /([a-z]+)([0-9]+)/ig; function __replFN() {return arguments[2] + arguments[1];}; __str.replace(__pattern, __replFN)===\'12aBc 34dEf\'. Actual: ' + __str.replace(__pattern, __replFN)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __replFN() { + return arguments[2] + arguments[1]; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A5_T1.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A5_T1.js new file mode 100644 index 0000000000..491d0ae818 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A5_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: Use replace with regexp as searchValue and use $ in replaceValue +es5id: 15.5.4.11_A5_T1 +description: searchValue is regexp /^(a+)\1*,\1+$/ and replaceValue is "$1" +---*/ + +var __str = "aaaaaaaaaa,aaaaaaaaaaaaaaa"; +var __pattern = /^(a+)\1*,\1+$/; +var __repl = "$1"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.replace(__pattern, __repl) !== 'aaaaa') { + throw new Test262Error('#1: var __str = "aaaaaaaaaa,aaaaaaaaaaaaaaa"; var __pattern = /^(a+)\\1*,\\1+$/; var __repl = "$1"; __str.replace(__pattern, __repl)===\'aaaaa\'. Actual: ' + __str.replace(__pattern, __repl)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A6.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A6.js new file mode 100644 index 0000000000..f5f167a1fb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace has not prototype property +es5id: 15.5.4.11_A6 +description: Checking String.prototype.replace.prototype; +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.replace.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.replace.prototype === undefined. Actual: ' + String.prototype.replace.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A7.js b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A7.js new file mode 100644 index 0000000000..af06d225d7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/S15.5.4.11_A7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.replace can't be used as constructor +es5id: 15.5.4.11_A7 +description: Checking if creating the String.prototype.replace object fails +---*/ + +var __FACTORY = String.prototype.replace; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.replace; "__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/replace/browser.js b/js/src/tests/test262/built-ins/String/prototype/replace/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-get-err.js b/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-get-err.js new file mode 100644 index 0000000000..bad72b1bbc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-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 @@replace property +es6id: 21.1.3.14 +info: | + [...] + 3. If searchValue is neither undefined nor null, then + a. Let replacer be GetMethod(searchValue, @@replace). + b. ReturnIfAbrupt(replacer). +features: [Symbol.replace] +---*/ + +var poisonedReplace = {}; +Object.defineProperty(poisonedReplace, Symbol.replace, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.replace(poisonedReplace); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-invocation.js b/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-invocation.js new file mode 100644 index 0000000000..bde2b7ee0b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-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 @@replace property of user-supplied objects +es6id: 21.1.3.14 +info: | + [...] + 3. If searchValue is neither undefined nor null, then + a. Let replacer be GetMethod(searchValue, @@replace). + b. ReturnIfAbrupt(replacer). + c. If replacer is not undefined, then + i. Return Call(replacer, searchValue, «O, replaceValue»). +features: [Symbol.replace] +---*/ + +var searchValue = {}; +var returnVal = {}; +var callCount = 0; +var thisVal, args; + +searchValue[Symbol.replace] = function() { + callCount += 1; + thisVal = this; + args = arguments; + return returnVal; +}; + +assert.sameValue(''.replace(searchValue, 'replace value'), returnVal); +assert.sameValue(thisVal, searchValue); +assert.notSameValue(args, undefined); +assert.sameValue(args.length, 2); +assert.sameValue(args[0], ''); +assert.sameValue(args[1], 'replace value'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-is-null.js b/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-is-null.js new file mode 100644 index 0000000000..2654ed83bf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/cstm-replace-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.replace +description: > + If searchValue's Symbol.replace property is null, no error is thrown. +info: | + String.prototype.replace ( searchValue, replaceValue ) + + [...] + 2. If searchValue is neither undefined nor null, then + a. Let replacer be ? GetMethod(searchValue, @@replace). + b. If replacer is not undefined, then + [...] + [...] + 12. Return newString. + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. +features: [Symbol.replace] +---*/ + +var searchValue = {}; +searchValue[Symbol.replace] = null; +searchValue.toString = function() { return "3"; }; +searchValue.valueOf = function() { throw new Test262Error("should not be called"); }; + +var replacer = function() { return "<foo>"; }; +assert.sameValue("ab3c".replace(searchValue, replacer), "ab<foo>c"); +assert.sameValue("ab3c".replace(searchValue, "<foo>"), "ab<foo>c"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/length.js b/js/src/tests/test262/built-ins/String/prototype/replace/length.js new file mode 100644 index 0000000000..9146fd1fcb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replace +description: > + String.prototype.replace.length is 2. +info: | + String.prototype.replace ( searchValue, replaceValue ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype.replace, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/name.js b/js/src/tests/test262/built-ins/String/prototype/replace/name.js new file mode 100644 index 0000000000..7e783a3585 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/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.14 +description: > + String.prototype.replace.name is "replace". +info: | + String.prototype.replace (searchValue, replaceValue ) + + 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.replace.name, "replace"); + +verifyNotEnumerable(String.prototype.replace, "name"); +verifyNotWritable(String.prototype.replace, "name"); +verifyConfigurable(String.prototype.replace, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/replace/not-a-constructor.js new file mode 100644 index 0000000000..c28df5ae80 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/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.replace 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.replace), + false, + 'isConstructor(String.prototype.replace) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.replace(); +}, '`new String.prototype.replace()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/replaceValue-evaluation-order-regexp-object.js b/js/src/tests/test262/built-ins/String/prototype/replace/replaceValue-evaluation-order-regexp-object.js new file mode 100644 index 0000000000..1eb0d40aab --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/replaceValue-evaluation-order-regexp-object.js @@ -0,0 +1,29 @@ +// 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.replace +description: > + Non-callable replaceValue is evaluated via toString +info: | + String.prototype.replace ( searchValue, replaceValue ) + + If functionalReplace is false, then + Set replaceValue to ? ToString(replaceValue). +---*/ + +let calls = 0; +let replaceValue = /$/; +let oldToString = replaceValue.toString.bind(replaceValue); + +replaceValue.toString = () => { + calls += 1; + return oldToString(); +}; + +let newString = "".replace("a", replaceValue); +assert.sameValue(newString, ""); +assert.sameValue(calls, 1); +assert.sameValue("dollar".replace("dollar", /$/), "/$/"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/replaceValue-evaluation-order.js b/js/src/tests/test262/built-ins/String/prototype/replace/replaceValue-evaluation-order.js new file mode 100644 index 0000000000..aeb45287ba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/replaceValue-evaluation-order.js @@ -0,0 +1,31 @@ +// 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.replace +description: > + Non-callable replaceValue is evaluated before searching the string. +info: | + String.prototype.replace ( searchValue, replaceValue ) + + ... + 6. If functionalReplace is false, then + a. Set replaceValue to ? ToString(replaceValue). + 7. Search string for the first occurrence of searchString and let pos be the + index within string of the first code unit of the matched substring and let + matched be searchString. If no occurrences of searchString were found, return string. +---*/ + +var calls = 0; +var replaceValue = { + toString: function() { + calls += 1; + return "b"; + }, +}; + +var newString = "".replace("a", replaceValue); +assert.sameValue(newString, ""); +assert.sameValue(calls, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/shell.js b/js/src/tests/test262/built-ins/String/prototype/replace/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/replace/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/replace/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..50e7dd8457 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replace/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.replace +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var replace = String.prototype.replace; + +assert.sameValue(typeof replace, 'function'); + +assert.throws(TypeError, function() { + replace.call(undefined, '', ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + replace.call(null, '', ''); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/browser.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0024.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0024.js new file mode 100644 index 0000000000..c4e83a5636 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0024.js @@ -0,0 +1,72 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($$) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... +features: [String.prototype.replaceAll] +---*/ + +var str = 'Ninguém é igual a ninguém. Todo o ser humano é um estranho ímpar.'; + +var result; + +result = str.replaceAll('ninguém', '$$'); +assert.sameValue(result, 'Ninguém é igual a $. Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('é', '$$'); +assert.sameValue(result, 'Ningu$m $ igual a ningu$m. Todo o ser humano $ um estranho ímpar.'); + +result = str.replaceAll('é', '$$ -'); +assert.sameValue(result, 'Ningu$ -m $ - igual a ningu$ -m. Todo o ser humano $ - um estranho ímpar.'); + +result = str.replaceAll('é', '$$&'); +assert.sameValue(result, 'Ningu$&m $& igual a ningu$&m. Todo o ser humano $& um estranho ímpar.'); + +result = str.replaceAll('é', '$$$'); +assert.sameValue(result, 'Ningu$$m $$ igual a ningu$$m. Todo o ser humano $$ um estranho ímpar.'); + +result = str.replaceAll('é', '$$$$'); +assert.sameValue(result, 'Ningu$$m $$ igual a ningu$$m. Todo o ser humano $$ um estranho ímpar.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0026.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0026.js new file mode 100644 index 0000000000..17f2031231 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0026.js @@ -0,0 +1,66 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($&) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... +features: [String.prototype.replaceAll] +---*/ + +var str = 'Ninguém é igual a ninguém. Todo o ser humano é um estranho ímpar.'; + +var result; + +result = str.replaceAll('ninguém', '$&'); +assert.sameValue(result, 'Ninguém é igual a ninguém. Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('ninguém', '($&)'); +assert.sameValue(result, 'Ninguém é igual a (ninguém). Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('é', '($&)'); +assert.sameValue(result, 'Ningu(é)m (é) igual a ningu(é)m. Todo o ser humano (é) um estranho ímpar.'); + +result = str.replaceAll('é', '($&) $&'); +assert.sameValue(result, 'Ningu(é) ém (é) é igual a ningu(é) ém. Todo o ser humano (é) é um estranho ímpar.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0027.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0027.js new file mode 100644 index 0000000000..4bb9f00b60 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0027.js @@ -0,0 +1,66 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($') +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... +features: [String.prototype.replaceAll] +---*/ + +var str = 'Ninguém é igual a ninguém. Todo o ser humano é um estranho ímpar.'; + +var result; + +result = str.replaceAll('ninguém', '$\''); +assert.sameValue(result, 'Ninguém é igual a . Todo o ser humano é um estranho ímpar.. Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('.', '--- $\''); +assert.sameValue(result, 'Ninguém é igual a ninguém--- Todo o ser humano é um estranho ímpar. Todo o ser humano é um estranho ímpar--- '); + +result = str.replaceAll('é', '($\')'); +assert.sameValue(result, 'Ningu(m é igual a ninguém. Todo o ser humano é um estranho ímpar.)m ( igual a ninguém. Todo o ser humano é um estranho ímpar.) igual a ningu(m. Todo o ser humano é um estranho ímpar.)m. Todo o ser humano ( um estranho ímpar.) um estranho ímpar.'); + +result = str.replaceAll('é', '($\') $\''); +assert.sameValue(result, 'Ningu(m é igual a ninguém. Todo o ser humano é um estranho ímpar.) m é igual a ninguém. Todo o ser humano é um estranho ímpar.m ( igual a ninguém. Todo o ser humano é um estranho ímpar.) igual a ninguém. Todo o ser humano é um estranho ímpar. igual a ningu(m. Todo o ser humano é um estranho ímpar.) m. Todo o ser humano é um estranho ímpar.m. Todo o ser humano ( um estranho ímpar.) um estranho ímpar. um estranho ímpar.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x003C.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x003C.js new file mode 100644 index 0000000000..a41388960c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x003C.js @@ -0,0 +1,73 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($<) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... + + $< + 1. If namedCaptures is undefined, the replacement text is the String "$<". + ... +features: [String.prototype.replaceAll, Symbol.replace] +---*/ + +var str = 'aaaaaaaaaaaaaaaa aaaaaaaa aaaaaaaaaaaaaaaa'; + +var result; + +// captures is always an empty list if GetSubstitution is called from the string value of SearchValue + +result = str.replaceAll('a', '$<'); +assert.sameValue(result, '$<$<$<$<$<$<$<$<$<$<$<$<$<$<$<$< $<$<$<$<$<$<$<$< $<$<$<$<$<$<$<$<$<$<$<$<$<$<$<$<'); + +var customRE = /./g; + +Object.defineProperty(customRE, Symbol.replace, { + value: undefined +}); + +result = '------------------- /./g -------/./g'.replaceAll(customRE, 'a($<$<)'); +assert.sameValue(result, '------------------- a($<$<) -------a($<$<)'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0060.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0060.js new file mode 100644 index 0000000000..f82f575bf4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024-0x0060.js @@ -0,0 +1,69 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($`) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... +features: [String.prototype.replaceAll] +---*/ + +var str = 'Ninguém é igual a ninguém. Todo o ser humano é um estranho ímpar.'; + +var result; + +result = str.replaceAll('ninguém', '$`'); +assert.sameValue(result, 'Ninguém é igual a Ninguém é igual a . Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('Ninguém', '$`'); +assert.sameValue(result, ' é igual a ninguém. Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('ninguém', '($`)'); +assert.sameValue(result, 'Ninguém é igual a (Ninguém é igual a ). Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('é', '($`)'); +assert.sameValue(result, 'Ningu(Ningu)m (Ninguém ) igual a ningu(Ninguém é igual a ningu)m. Todo o ser humano (Ninguém é igual a ninguém. Todo o ser humano ) um estranho ímpar.'); + +result = str.replaceAll('é', '($`) $`'); +assert.sameValue(result, 'Ningu(Ningu) Ningum (Ninguém ) Ninguém igual a ningu(Ninguém é igual a ningu) Ninguém é igual a ningum. Todo o ser humano (Ninguém é igual a ninguém. Todo o ser humano ) Ninguém é igual a ninguém. Todo o ser humano um estranho ímpar.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024.js new file mode 100644 index 0000000000..125fcdd7dd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024.js @@ -0,0 +1,66 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... +features: [String.prototype.replaceAll] +---*/ + +var str = 'Ninguém é igual a ninguém. Todo o ser humano é um estranho ímpar.'; + +var result; + +result = str.replaceAll('ninguém', '$'); +assert.sameValue(result, 'Ninguém é igual a $. Todo o ser humano é um estranho ímpar.'); + +result = str.replaceAll('é', '$'); +assert.sameValue(result, 'Ningu$m $ igual a ningu$m. Todo o ser humano $ um estranho ímpar.'); + +result = str.replaceAll('é', '$ -'); +assert.sameValue(result, 'Ningu$ -m $ - igual a ningu$ -m. Todo o ser humano $ - um estranho ímpar.'); + +result = str.replaceAll('é', '$$$'); +assert.sameValue(result, 'Ningu$$m $$ igual a ningu$$m. Todo o ser humano $$ um estranho ímpar.'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024N.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024N.js new file mode 100644 index 0000000000..97e92fead1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024N.js @@ -0,0 +1,95 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($N) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... + + The nth element of captures, where n is a single digit in the range 1 to 9. If n ≤ m and the nth element of captures is undefined, use the empty String instead. If n > m, no replacement is done. +features: [String.prototype.replaceAll, Symbol.replace] +---*/ + +var str = 'ABC AAA ABC AAA'; + +var result; + +// captures is always an empty list if GetSubstitution is called from the string value of SearchValue + +result = str.replaceAll('ABC', '$1'); +assert.sameValue(result, '$1 AAA $1 AAA'); + +result = str.replaceAll('ABC', '$2'); +assert.sameValue(result, '$2 AAA $2 AAA'); + +result = str.replaceAll('ABC', '$3'); +assert.sameValue(result, '$3 AAA $3 AAA'); + +result = str.replaceAll('ABC', '$4'); +assert.sameValue(result, '$4 AAA $4 AAA'); + +result = str.replaceAll('ABC', '$5'); +assert.sameValue(result, '$5 AAA $5 AAA'); + +result = str.replaceAll('ABC', '$6'); +assert.sameValue(result, '$6 AAA $6 AAA'); + +result = str.replaceAll('ABC', '$7'); +assert.sameValue(result, '$7 AAA $7 AAA'); + +result = str.replaceAll('ABC', '$8'); +assert.sameValue(result, '$8 AAA $8 AAA'); + +result = str.replaceAll('ABC', '$9'); +assert.sameValue(result, '$9 AAA $9 AAA'); + +var customRE = /./g; + +Object.defineProperty(customRE, Symbol.replace, { + value: undefined +}); + +result = '--- /./g --- /a/g --- /./g ---'.replaceAll(customRE, 'a($1$1)'); +assert.sameValue(result, '--- a($1$1) --- /a/g --- a($1$1) ---'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024NN.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024NN.js new file mode 100644 index 0000000000..96c3798b35 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/getSubstitution-0x0024NN.js @@ -0,0 +1,74 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacement Text Symbol Substitutions ($NN) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. + + Table 53: Replacement Text Symbol Substitutions + ... + + The nnth element of captures, where nn is a two-digit decimal number in the range 01 to 99. If nn ≤ m and the nnth element of captures is undefined, use the empty String instead. If nn is 00 or nn > m, no replacement is done. +features: [String.prototype.replaceAll, Symbol.replace] +---*/ + +var str = 'aaaaaaaaaaaaaaaa aaaaaaaa aaaaaaaaaaaaaaaa'; + +var result; + +// captures is always an empty list if GetSubstitution is called from the string value of SearchValue + +result = str.replaceAll('a', '$11'); +assert.sameValue(result, '$11$11$11$11$11$11$11$11$11$11$11$11$11$11$11$11 $11$11$11$11$11$11$11$11 $11$11$11$11$11$11$11$11$11$11$11$11$11$11$11$11'); + +result = str.replaceAll('a', '$29'); +assert.sameValue(result, '$29$29$29$29$29$29$29$29$29$29$29$29$29$29$29$29 $29$29$29$29$29$29$29$29 $29$29$29$29$29$29$29$29$29$29$29$29$29$29$29$29'); + +var customRE = /./g; + +Object.defineProperty(customRE, Symbol.replace, { + value: undefined +}); + +result = '------------------- /./g -------/./g'.replaceAll(customRE, 'a($12$11)'); +assert.sameValue(result, '------------------- a($12$11) -------a($12$11)'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/length.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/length.js new file mode 100644 index 0000000000..9bd309d638 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + String.prototype.replaceAll.length value and descriptor. +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.replaceAll] +---*/ + +verifyProperty(String.prototype.replaceAll, 'length', { + value: 2, + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/name.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/name.js new file mode 100644 index 0000000000..9ca5c78acb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + String.prototype.replaceAll.name value and descriptor. +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.replaceAll] +---*/ + +verifyProperty(String.prototype.replaceAll, 'name', { + value: 'replaceAll', + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/not-a-constructor.js new file mode 100644 index 0000000000..b3b9ca6503 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/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.replaceAll 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.replaceAll), + false, + 'isConstructor(String.prototype.replaceAll) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.replaceAll(); +}, '`new String.prototype.replaceAll()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceAll.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceAll.js new file mode 100644 index 0000000000..d46cba45b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceAll.js @@ -0,0 +1,28 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Property type and descriptor. +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.replaceAll] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + '`typeof String.prototype.replaceAll` is `function`' +); + +verifyProperty(String.prototype, 'replaceAll', { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-abrupt.js new file mode 100644 index 0000000000..24c586519f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-abrupt.js @@ -0,0 +1,28 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Return abrupt from Call(replaceValue, ...) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + i. Let replacement be ? ToString(? Call(replaceValue, undefined, « searchString, position, string »). +features: [String.prototype.replaceAll] +---*/ + +function custom() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + 'a'.replaceAll('a', custom); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-each-match-position.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-each-match-position.js new file mode 100644 index 0000000000..0873c0dd28 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-each-match-position.js @@ -0,0 +1,44 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + If replaceValue is a function, it's called for each matching position +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + i. Let replacement be ? ToString(? Call(replaceValue, undefined, « searchString, position, string »). +features: [String.prototype.replaceAll] +includes: [compareArray.js] +---*/ + +var t = (function() { return this; })(); + +var calls = []; +var replaceValue = function(...args) { + calls.push([this, ...args]); + return 'z'; +}; + +var searchValue = new String('ab c'); + +var obj = new String('ab c ab cdab cab c'); + +var result = obj.replaceAll(searchValue, replaceValue); +assert.sameValue(calls.length, 4); +assert.sameValue(result, 'z zdzz'); + +var str = obj.toString(); + +assert.compareArray(calls[0], [t, 'ab c', 0, str]); +assert.compareArray(calls[1], [t, 'ab c', 5, str]); +assert.compareArray(calls[2], [t, 'ab c', 10, str]); +assert.compareArray(calls[3], [t, 'ab c', 14, str]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-matching-empty.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-matching-empty.js new file mode 100644 index 0000000000..20bad8d142 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-matching-empty.js @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + replaceValue can be called for matching position of an empty string +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + i. Let replacement be ? ToString(? Call(replaceValue, undefined, « searchString, position, string »). +features: [String.prototype.replaceAll] +includes: [compareArray.js] +---*/ + +var t = (function() { return this; })(); + +var calls = []; +var replaceValue = function(...args) { + calls.push([this, ...args]); + return 'abc'; +}; + +var searchValue = new String(''); + +var obj = new String(''); + +var result = obj.replaceAll(searchValue, replaceValue); +assert.sameValue(calls.length, 1); +assert.sameValue(result, 'abc'); + +var str = obj.toString(); + +assert.compareArray(calls[0], [t, '', 0, str]); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-skip-no-match.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-skip-no-match.js new file mode 100644 index 0000000000..d8e75b817b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-skip-no-match.js @@ -0,0 +1,34 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + replaceValue is not called if there isn't a match +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + i. Let replacement be ? ToString(? Call(replaceValue, undefined, « searchString, position, string »). +features: [String.prototype.replaceAll] +---*/ + +function replaceValue() { + throw new Test262Error(); +} + +assert.sameValue( + 'a'.replaceAll('b', replaceValue), + 'a' +); + +assert.sameValue( + 'a'.replaceAll('aa', replaceValue), + 'a' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-tostring-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-tostring-abrupt.js new file mode 100644 index 0000000000..d4d605a456 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-call-tostring-abrupt.js @@ -0,0 +1,44 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Return abrupt from ToString(Call(replaceValue, ...)) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + i. Let replacement be ? ToString(? Call(replaceValue, undefined, « searchString, position, string »). +features: [String.prototype.replaceAll, Symbol] +---*/ + +function custom() { + return { + toString() { + throw new Test262Error(); + } + } +} + +assert.throws(Test262Error, function() { + 'a'.replaceAll('a', custom); +}); + +function symbol() { + return { + toString() { + return Symbol(); + } + } +} + +assert.throws(TypeError, function() { + 'a'.replaceAll('a', symbol); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-fn-skip-toString.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-fn-skip-toString.js new file mode 100644 index 0000000000..77c34425fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-fn-skip-toString.js @@ -0,0 +1,41 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Skip ToString(replaceValue) if it's a function +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + ... + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... +features: [String.prototype.replaceAll] +---*/ + +var called = 0; +var replaceValue = function() { + called += 1; + return 'b'; +}; +var poisoned = 0; +Object.defineProperty(replaceValue, 'toString', { + value: function() { + poisoned += 1; + throw 'should not call this'; + } +}); + +var result = 'aaa'.replaceAll('a', replaceValue); +assert.sameValue(called, 3); +assert.sameValue(poisoned, 0); +assert.sameValue(result, 'bbb'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-tostring-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-tostring-abrupt.js new file mode 100644 index 0000000000..c674303092 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-tostring-abrupt.js @@ -0,0 +1,77 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Returns abrupt completions from ToString(replaceValue) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + ... + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... +features: [String.prototype.replaceAll, Symbol] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +var thisValueCalled = 0; +var thisValue = { + toString() { + thisValueCalled += 1; + return ''; + } +}; + +var searchValueCalled = 0; +var searchValue = { + toString() { + searchValueCalled += 1; + return ''; + } +}; + +var called = 0; +var replaceValue = { + toString() { + called += 1; + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(thisValue, searchValue, replaceValue); +}, 'custom'); +assert.sameValue(called, 1); +assert.sameValue(thisValueCalled, 1); +assert.sameValue(searchValueCalled, 1); + +searchValueCalled = 0; +thisValueCalled = 0; +called = 0; +replaceValue = { + toString() { + called += 1; + return Symbol(); + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(thisValue, searchValue, replaceValue); +}, 'Symbol'); +assert.sameValue(called, 1); +assert.sameValue(thisValueCalled, 1); +assert.sameValue(searchValueCalled, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-value-replaces-string.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-value-replaces-string.js new file mode 100644 index 0000000000..e009730f8d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-value-replaces-string.js @@ -0,0 +1,38 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + replaceValue is used to replace matching positions in string +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). +features: [String.prototype.replaceAll] +---*/ + +var result = 'aaab a a aac'.replaceAll('aa', 'z'); +assert.sameValue(result, 'zab a a zc'); + +result = 'aaab a a aac'.replaceAll('aa', 'a'); +assert.sameValue(result, 'aab a a ac'); + +result = 'aaab a a aac'.replaceAll('a', 'a'); +assert.sameValue(result, 'aaab a a aac'); + +result = 'aaab a a aac'.replaceAll('a', 'z'); +assert.sameValue(result, 'zzzb z z zzc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-value-tostring.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-value-tostring.js new file mode 100644 index 0000000000..aa9d1a5549 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/replaceValue-value-tostring.js @@ -0,0 +1,99 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + ToString(replaceValue) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). +features: [String.prototype.replaceAll, Symbol.toPrimitive] +---*/ + +var result; + +var called; +var replaceValue; + +called = 0; +replaceValue = { + [Symbol.toPrimitive](){ + called += 1; + return 'z'; + }, + toString() { + throw 'poison'; + }, + valueOf() { + throw 'poison'; + }, +}; + +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, 'zz', 'object @@toPrimitive'); +assert.sameValue(called, 1, '@@toPrimitive is called only once'); + +called = 0; +replaceValue = { + [Symbol.toPrimitive]: undefined, + toString() { + called += 1; + return 'z'; + }, + valueOf() { + throw 'poison'; + }, +}; + +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, 'zz', 'object toString'); +assert.sameValue(called, 1, 'toString is called only once'); + +called = 0; +replaceValue = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf() { + called += 1; + return 'z'; + }, +}; + +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, 'zz', 'object valueOf'); +assert.sameValue(called, 1, 'valueOf is called only once'); + +replaceValue = 42; +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, '4242', 'number'); + +replaceValue = true; +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, 'truetrue', 'Boolean true'); + +replaceValue = false; +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, 'falsefalse', 'Boolean false'); + +replaceValue = undefined; +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, 'undefinedundefined', 'undefined'); + +replaceValue = null; +result = 'aa'.replaceAll('a', replaceValue); +assert.sameValue(result, 'nullnull', 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-empty-string-this-empty-string.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-empty-string-this-empty-string.js new file mode 100644 index 0000000000..db3e44c1f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-empty-string-this-empty-string.js @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Matching empty string for the this value and the searchValue +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. +features: [String.prototype.replaceAll] +---*/ + +var result = ''.replaceAll('', 'abc'); +assert.sameValue(result, 'abc'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-empty-string.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-empty-string.js new file mode 100644 index 0000000000..3ab6dde25a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-empty-string.js @@ -0,0 +1,55 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Replacements when the search value is the empty string +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 10. Let position be ! StringIndexOf(string, searchString, 0). + 11. Repeat, while position is not -1 + a. Append position to the end of matchPositions. + b. Let position be ! StringIndexOf(string, searchString, position + advanceBy). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). + + StringIndexOf ( string, searchValue, fromIndex ) + + ... + 4. Let len be the length of string. + 5. If searchValue is the empty string, and fromIndex <= len, return fromIndex. + 6. Let searchLen be the length of searchValue. + 7. If there exists any integer k such that fromIndex ≤ k ≤ len - searchLen and for all nonnegative integers j less than searchLen, the code unit at index k + j within string is the same as the code unit at index j within searchValue, let pos be the smallest (closest to -∞) such integer. Otherwise, let pos be -1. + 8. Return pos. + + Runtime Semantics: GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ) + + ... + 2. Let matchLength be the number of code units in matched. + ... + 4. Let stringLength be the number of code units in str. + ... + 9. Let tailPos be position + matchLength. + 10. Let m be the number of elements in captures. + 11. Let result be the String value derived from replacement by copying code unit elements from replacement to result while performing replacements as specified in Table 53. These $ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements. + 12 Return result. +features: [String.prototype.replaceAll] +---*/ + +var result; + +result = 'aab c \nx'.replaceAll('', '_'); +assert.sameValue(result, '_a_a_b_ _c_ _ _\n_x_'); + +result = 'a'.replaceAll('', '_'); +assert.sameValue(result, '_a_'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-no-g-throws.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-no-g-throws.js new file mode 100644 index 0000000000..4bf1ad9aa9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-no-g-throws.js @@ -0,0 +1,64 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Throws a TypeError if flags does not contain "g" +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + ... +features: [String.prototype.replaceAll, Symbol.match, Symbol] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +var searchValue = /./; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'flags is the empty string'); + +Object.defineProperty(searchValue, 'flags', { + value: 'G', + writable: true, + configurable: true, +}); + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'case sensitive G'); + +Object.defineProperty(searchValue, 'flags', { + value: 'i', + writable: true, + configurable: true, +}); + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'i'); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-null-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-null-undefined-throws.js new file mode 100644 index 0000000000..feb898c2de --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-null-undefined-throws.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Throws a TypeError if flags is not an ObjectCoercible (null or undefined) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + ... +features: [String.prototype.replaceAll, Symbol.match] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +var called = 0; +var value = undefined; +var searchValue = { + [Symbol.match]: true, + get flags() { + called += 1; + return value; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'undefined'); +assert.sameValue(called, 1); + +called = 0; +value = null; +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'null'); +assert.sameValue(called, 1); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-toString-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-toString-abrupt.js new file mode 100644 index 0000000000..de261a961c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-flags-toString-abrupt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Returns abrupt completions from ToString(flags) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + ... +features: [String.prototype.replaceAll, Symbol.match, Symbol] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +var searchValue = { + [Symbol.match]: true, + flags: Symbol(), + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'Symbol'); + +searchValue.flags = { + toString() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'custom abrupt'); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-get-flags-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-get-flags-abrupt.js new file mode 100644 index 0000000000..bf9bb3edc4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-get-flags-abrupt.js @@ -0,0 +1,86 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Return Abrupt completion from Get(searchValue, "flags") +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + ... +features: [String.prototype.replaceAll, Symbol.match] +---*/ + +var searchValue = { + [Symbol.match]: true, + get flags() { + throw new Test262Error; + } +}; + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'from custom searchValue object'); + +var re1 = /./; +Object.defineProperty(re1, 'flags', { + get() { throw new Test262Error(); } +}); + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, re1, poison); +}, 'from RE instance, using default Symbol.match check'); + +var called = 0; +var re2 = /./; +Object.defineProperty(re2, Symbol.match, { + get() { + called += 1; + return true; + } +}); +Object.defineProperty(re2, 'flags', { + get() { throw new Test262Error(); } +}); + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, re2, poison); +}, 'from RE instance, using Symbol.match check (true)'); +assert.sameValue(called, 1); + +called = 0; +var re3 = /./; +Object.defineProperty(re3, Symbol.match, { + get() { + called += 1; + return 1; + } +}); +Object.defineProperty(re3, 'flags', { + get() { throw new Test262Error(); } +}); + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, re3, poison); +}, 'from RE instance, using Symbol.match check (1), uses Internal for IsRegExp'); +assert.sameValue(called, 1); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-isRegExp-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-isRegExp-abrupt.js new file mode 100644 index 0000000000..8933fa13b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-isRegExp-abrupt.js @@ -0,0 +1,49 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Return Abrupt completion from isRegExp +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + ... + + IsRegExp ( argument ) + + 1. If Type(argument) is not Object, return false. + 2. Let matcher be ? Get(argument, @@match). + 3. If matcher is not undefined, return ! ToBoolean(matcher). + 4. If argument has a [[RegExpMatcher]] internal slot, return true. + 5. Return false. +features: [String.prototype.replaceAll, Symbol.match] +---*/ + +var searchValue = { + get [Symbol.match]() { + throw new Test262Error(); + }, + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, searchValue, poison); +}); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-RegExp-call-fn.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-RegExp-call-fn.js new file mode 100644 index 0000000000..b81dfe90ba --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-RegExp-call-fn.js @@ -0,0 +1,125 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + A RegExp searchValue's Symbol.replace can be called instead of the next steps of replaceAll +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + c. Let replacer be ? GetMethod(searchValue, @@replace). + d. If replacer is not undefined, then + i. Return ? Call(replacer, searchValue, « O, replaceValue »). + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + ... +features: [String.prototype.replaceAll, Symbol.replace, class] +includes: [compareArray.js] +---*/ + +let called = 0; + +class RE extends RegExp { + [Symbol.replace](...args) { + const actual = super[Symbol.replace](...args); + + // Ordering is intentional to observe call from super + called += 1; + return actual; + } + + toString() { + throw 'Should not call toString on searchValue'; + } +} + +const t = (function() { return this; })(); +let calls; + +function getFn(val) { + return function replaceValueFn(...args) { + calls.push([this, ...args]); + return val; + }; +} + +const samples = [ + [ '(a)', 'aaa abc', 'z', 'zzz zbc' ], + [ '(a)', 'aaa abc', '$1', '$1$1$1 $1bc' ], + [ '(a)', 'aaa abc', '$$', '$$$$$$ $$bc' ], + [ '(a)', 'aaa abc', '$&', '$&$&$& $&bc' ], + [ '(a)', 'aaa abc', '$\'', '$\'$\'$\' $\'bc' ], + [ '(a)', 'aaa abc', '$`', '$`$`$` $`bc' ], +]; + +let count = 0; +for (const [ reStr, thisValue, replaceValue, expected ] of samples) { + const searchValue = new RE(reStr, 'g'); + const replaceFn = getFn(replaceValue); + + // Observes the toString + const obj = new String(thisValue); + + called = 0; + calls = []; + + const actual = obj.replaceAll(searchValue, replaceFn); + + const message = `sample ${count}: '${thisValue}'.replaceAll(/${reStr}/g, () => '${replaceValue}')`; + + assert.sameValue(called, 1, `called -- ${message}`); + assert.sameValue(actual, expected, `actual -- ${message}`); + + assert.sameValue(calls.length, 4, `calls.length -- ${message}`); + assert.compareArray(calls[0], [t, 'a', 'a', 0, thisValue]); + assert.compareArray(calls[1], [t, 'a', 'a', 1, thisValue]); + assert.compareArray(calls[2], [t, 'a', 'a', 2, thisValue]); + assert.compareArray(calls[3], [t, 'a', 'a', 4, thisValue]); + + count += 1; +} + +const samplesSticky = [ + [ '(a)', 'aaa abc', 'z', 'zzz abc' ], + [ '(a)', 'aaa abc', '$1', '$1$1$1 abc' ], + [ '(a)', 'aaa abc', '$$', '$$$$$$ abc' ], + [ '(a)', 'aaa abc', '$&', '$&$&$& abc' ], + [ '(a)', 'aaa abc', '$\'', '$\'$\'$\' abc' ], + [ '(a)', 'aaa abc', '$`', '$`$`$` abc' ], +]; + +count = 0; +for (const [ reStr, thisValue, replaceValue, expected ] of samplesSticky) { + const searchValue = new RE(reStr, 'gy'); + const replaceFn = getFn(replaceValue); + + // Observes the toString + const obj = new String(thisValue); + + called = 0; + calls = []; + + const actual = obj.replaceAll(searchValue, replaceFn); + + const message = `sample ${count}: '${thisValue}'.replaceAll(/${reStr}/gy, () => '${replaceValue}')`; + + assert.sameValue(called, 1, `called -- ${message}`); + assert.sameValue(actual, expected, `actual -- ${message}`); + + assert.sameValue(calls.length, 3, `calls.length -- ${message}`); + assert.compareArray(calls[0], [t, 'a', 'a', 0, thisValue]); + assert.compareArray(calls[1], [t, 'a', 'a', 1, thisValue]); + assert.compareArray(calls[2], [t, 'a', 'a', 2, thisValue]); + + count += 1; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-RegExp-call.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-RegExp-call.js new file mode 100644 index 0000000000..d556547a38 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-RegExp-call.js @@ -0,0 +1,84 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + A RegExp searchValue's Symbol.replace can be called instead of the next steps of replaceAll +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + c. Let replacer be ? GetMethod(searchValue, @@replace). + d. If replacer is not undefined, then + i. Return ? Call(replacer, searchValue, « O, replaceValue »). + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + ... +features: [String.prototype.replaceAll, Symbol.replace, class] +---*/ + +let called = 0; + +class RE extends RegExp { + [Symbol.replace](...args) { + const actual = super[Symbol.replace](...args); + + // Ordering is intentional to observe call from super + called += 1; + return actual; + } + + toString() { + throw 'Should not call toString on searchValue'; + } +} + +const samples = [ + [ ['b', 'g'], 'abc abc abc', 'z', 'azc azc azc' ], + [ ['b', 'gy'], 'abc abc abc', 'z', 'abc abc abc' ], + [ ['b', 'giy'], 'abc abc abc', 'z', 'abc abc abc' ], + [ [ '[A-Z]', 'g' ], 'No Uppercase!', '', 'o ppercase!' ], + [ [ '[A-Z]', 'gy' ], 'No Uppercase?', '', 'o Uppercase?' ], + [ [ '[A-Z]', 'gy' ], 'NO UPPERCASE!', '', ' UPPERCASE!' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '$2-$1', 'ca-bbcca-bbc' ], + [ [ '(a(.))', 'g' ], 'abcabcabcabc', '$1$2$3', 'abb$3cabb$3cabb$3cabb$3c' ], + [ [ '(((((((((((((a(.).).).).).).).).))))))', 'g' ], 'aabacadaeafagahaiajakalamano a azaya', '($10)-($12)-($1)', '(aabaca)-(aaba)-(aabacadaea)f(agahai)-(agah)-(agahaiajak)(alaman)-(alam)-(alamano a )azaya' ], + [ [ 'b', 'g' ], 'abcba', '$\'', 'acbacaa' ], + [ [ 'b', 'g' ], 'abcba', '$`', 'aacabca' ], + [ [ '(?<named>b)', 'g' ], 'abcba', '($<named>)', 'a(b)c(b)a' ], + [ [ '(?<named>b)', 'g' ], 'abcba', '($<named)', 'a($<named)c($<named)a' ], + [ [ '(?<named>b)', 'g' ], 'abcba', '($<unnamed>)', 'a()c()a' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($$)', '($)bc($)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($)', '($)bc($)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($$$$)', '($$)bc($$)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($$$)', '($$)bc($$)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($$&)', '($&)bc($&)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($$1)', '($1)bc($1)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($$`)', '($`)bc($`)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($$\')', '($\')bc($\')bc' ], + [ [ 'a(?<z>b)(ca)', 'g' ], 'abcabcabcabc', '($$<z>)', '($<z>)bc($<z>)bc' ], + [ [ 'a(b)(ca)', 'g' ], 'abcabcabcabc', '($&)', '(abca)bc(abca)bc' ], +]; + +let count = 0; +for (const [ [ reStr, flags ], thisValue, replaceValue, expected ] of samples) { + const searchValue = new RE(reStr, flags); + + called = 0; + const actual = thisValue.replaceAll(searchValue, replaceValue); + + const message = `sample ${count}: '${thisValue}'.replaceAll(/${reStr}/${flags}, '${replaceValue}')`; + + assert.sameValue(called, 1, message); + assert.sameValue(actual, expected, message); + count += 1; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-before-tostring.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-before-tostring.js new file mode 100644 index 0000000000..82136a4b42 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-before-tostring.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + The searchValue is observed before ToString(this value) and ToString(replaceValue) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + c. Let replacer be ? GetMethod(searchValue, @@replace). + d. If replacer is not undefined, then + i. Return ? Call(replacer, searchValue, « O, replaceValue »). + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + ... +features: [String.prototype.replaceAll, Symbol.replace] +---*/ + +var called = 0; +var searchValue = /./g; +Object.defineProperty(searchValue, Symbol.replace, { + value: function(O, replaceValue) { + assert.sameValue(this, searchValue); + assert.sameValue(O, poison, 'first arg is the this value of replaceAll'); + assert.sameValue(replaceValue, poison, 'second arg is the replaceValue'); + assert.sameValue(arguments.length, 2); + called += 1; + return 'return from searchValue'; + } +}); + +Object.defineProperty(searchValue, 'toString', { + value: function() { + throw 'Should not call toString on searchValue'; + } +}); + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +var returned = ''.replaceAll.call(poison, searchValue, poison); + +assert.sameValue(returned, 'return from searchValue'); +assert.sameValue(called, 1); +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-call-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-call-abrupt.js new file mode 100644 index 0000000000..ed35fa7ed1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-call-abrupt.js @@ -0,0 +1,50 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Return abrupt completion from Call.call(poison, replacer, poison) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + c. Let replacer be ? GetMethod(searchValue, @@replace). + d. If replacer is not undefined, then + i. Return ? Call(replacer, searchValue, « O, replaceValue »). + ... +features: [String.prototype.replaceAll, Symbol.match, Symbol.replace] +---*/ + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +var searchValue = { + [Symbol.match]: false, + flags: 'g', + [Symbol.replace]() { + throw new Test262Error(); + }, + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, searchValue, poison); +}); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-call.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-call.js new file mode 100644 index 0000000000..2ad07f3c18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-call.js @@ -0,0 +1,57 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Return value from Call(replacer, ...) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + c. Let replacer be ? GetMethod(searchValue, @@replace). + d. If replacer is not undefined, then + i. Return ? Call(replacer, searchValue, « O, replaceValue »). + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... +features: [String.prototype.replaceAll, Symbol.replace] +---*/ + +var called = 0; +var searchValue = /./g; +Object.defineProperty(searchValue, Symbol.replace, { + value: function(O, replaceValue) { + assert.sameValue(this, searchValue); + assert.sameValue(O, str, 'first arg is the this value of replaceAll'); + assert.sameValue(replaceValue, obj, 'second arg is the replaceValue'); + assert.sameValue(arguments.length, 2); + called += 1; + return 42; + } +}); + +Object.defineProperty(searchValue, 'toString', { + value: function() { + throw 'Should not call searchValue toString' + } +}); + +var str = new String('Leo'); +var obj = {}; + +var returned = str.replaceAll(searchValue, obj); + +assert.sameValue(returned, 42); +assert.sameValue(called, 1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-is-null.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-is-null.js new file mode 100644 index 0000000000..9614eec319 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-is-null.js @@ -0,0 +1,37 @@ +// 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.replaceall +description: > + If searchValue's Symbol.replace property is null, no error is thrown. +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + [...] + 2. If searchValue is neither undefined nor null, then + [...] + c. Let replacer be ? GetMethod(searchValue, @@replace). + d. If replacer is not undefined, then + [...] + [...] + 16. Return result. + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. +features: [String.prototype.replaceAll, Symbol.replace] +---*/ + +var searchValue = {}; +searchValue[Symbol.replace] = null; +searchValue.toString = function() { return "2"; }; +searchValue.valueOf = function() { throw new Test262Error("should not be called"); }; + +var replacer = function() { return "<foo>"; }; +assert.sameValue("a2b2c".replaceAll(searchValue, replacer), "a<foo>b<foo>c"); +assert.sameValue("a2b2c".replaceAll(searchValue, "<foo>"), "a<foo>b<foo>c"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-method-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-method-abrupt.js new file mode 100644 index 0000000000..1556a15ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-replacer-method-abrupt.js @@ -0,0 +1,131 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Return abrupt completion from GetMethod(searchValue.@@replace) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + a. Let isRegExp be ? IsRegExp(searchString). + b. If isRegExp is true, then + i. Let flags be ? Get(searchValue, "flags"). + ii. Perform ? RequireObjectCoercible(flags). + iii. If ? ToString(flags) does not contain "g", throw a TypeError exception. + c. Let replacer be ? GetMethod(searchValue, @@replace). + ... + + GetMethod ( V, P ) + + ... + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. + 4. If IsCallable(func) is false, throw a TypeError exception. + 5. Return func. +features: [String.prototype.replaceAll, Symbol, Symbol.match, Symbol.replace] +---*/ + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on this/replaceValue'; + }, +}; + +var searchValue = { + [Symbol.match]: false, + flags: 'g', + get [Symbol.replace]() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, 'custom abrupt'); + +searchValue = { + [Symbol.match]: false, + flags: 'g', + [Symbol.replace]: {}, + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, '@@replace is an object (not callable)'); + +searchValue = { + [Symbol.match]: false, + flags: 'g', + [Symbol.replace]: '', + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, '@@replace is a string'); + +searchValue = { + [Symbol.match]: false, + flags: 'g', + [Symbol.replace]: 42, + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, '@@replace is a number'); + +searchValue = { + [Symbol.match]: false, + flags: 'g', + [Symbol.replace]: Symbol(), + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, '@@replace is a symbol'); + +searchValue = { + [Symbol.match]: false, + flags: 'g', + [Symbol.replace]: true, + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, '@@replace is true'); + +searchValue = { + [Symbol.match]: false, + flags: 'g', + [Symbol.replace]: false, + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(poison, searchValue, poison); +}, '@@replace is false'); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-tostring-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-tostring-abrupt.js new file mode 100644 index 0000000000..fa7926c90a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-tostring-abrupt.js @@ -0,0 +1,76 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Returns abrupt completions from ToString(searchValue) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + ... + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... +features: [String.prototype.replaceAll, Symbol] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on replaceValue'; + }, +}; + +var thisValueCalled = 0; +var thisValue = { + toString() { + thisValueCalled += 1; + return ''; + } +}; + +var called = 0; +var searchValue = { + toString() { + called += 1; + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(thisValue, searchValue, poison); +}, 'custom'); +assert.sameValue(called, 1); +assert.sameValue(thisValueCalled, 1); + +thisValueCalled = 0; +called = 0; +searchValue = { + toString() { + called += 1; + return Symbol(); + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(thisValue, searchValue, poison); +}, 'Symbol'); +assert.sameValue(called, 1); +assert.sameValue(thisValueCalled, 1); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-tostring-regexp.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-tostring-regexp.js new file mode 100644 index 0000000000..1cdfdbc2e7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/searchValue-tostring-regexp.js @@ -0,0 +1,58 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + ToString(searchValue) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 4. Let searchString be ? ToString(searchValue). + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). +features: [String.prototype.replaceAll, Symbol.replace] +---*/ + +var result; +var searchValue; + +searchValue = /./g; + +Object.defineProperty(searchValue, Symbol.replace, { value: undefined }); + +result = 'aa /./g /./g aa'.replaceAll(searchValue, 'z'); +assert.sameValue(result, 'aa z z aa', '/./g'); + +searchValue = /./gy; + +Object.defineProperty(searchValue, Symbol.replace, { value: undefined }); + +result = 'aa /./gy /./gy aa'.replaceAll(searchValue, 'z'); +assert.sameValue(result, 'aa z z aa', '/./gy'); + +searchValue = /./gi; + +Object.defineProperty(searchValue, Symbol.replace, { value: undefined }); + +result = 'aa /./gi /./gi aa'.replaceAll(searchValue, 'z'); +assert.sameValue(result, 'aa z z aa', '/./gi'); + +searchValue = /./iyg; + +Object.defineProperty(searchValue, Symbol.replace, { value: undefined }); + +result = 'aa /./giy /./iyg /./gyi /./giy aa'.replaceAll(searchValue, 'z'); +assert.sameValue(result, 'aa z /./iyg /./gyi z aa', '/./iyg'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/shell.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-is-null-throws.js new file mode 100644 index 0000000000..eb84d25c5b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-is-null-throws.js @@ -0,0 +1,32 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Throws TypeError when `this` is null +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + ... + + RequireObjectCoercible ( argument ) + + - Undefined: Throw a TypeError exception. + - Null: Throw a TypeError exception. +features: [String.prototype.replaceAll] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +assert.throws(TypeError, function() { + String.prototype.replaceAll.call(null); +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-is-undefined-throws.js new file mode 100644 index 0000000000..eadce773df --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-is-undefined-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Throws TypeError when `this` is undefined +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + ... + + RequireObjectCoercible ( argument ) + + - Undefined: Throw a TypeError exception. + - Null: Throw a TypeError exception. +features: [String.prototype.replaceAll] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +assert.throws(TypeError, function() { + String.prototype.replaceAll.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-tostring-abrupt.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-tostring-abrupt.js new file mode 100644 index 0000000000..fc3376918c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-tostring-abrupt.js @@ -0,0 +1,67 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + Returns abrupt completions from ToString(this value) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + 1. Let O be RequireObjectCoercible(this value). + 2. If searchValue is neither undefined nor null, then + ... + 3. Let string be ? ToString(O). + ... +features: [String.prototype.replaceAll, Symbol] +---*/ + +assert.sameValue( + typeof String.prototype.replaceAll, + 'function', + 'function must exist' +); + +var poisoned = 0; +var poison = { + toString() { + poisoned += 1; + throw 'Should not call toString on replaceValue'; + }, +}; + +var called = 0; +var thisValue = { + toString() { + called += 1; + throw new Test262Error(); + } +} + +var searchValue = { + toString() { + throw 'Should not call toString on searchValue'; + } +}; + +assert.throws(Test262Error, function() { + ''.replaceAll.call(thisValue, searchValue, poison); +}, 'custom'); +assert.sameValue(called, 1); + +called = 0; +thisValue = { + toString() { + called += 1; + return Symbol(); + } +}; + +assert.throws(TypeError, function() { + ''.replaceAll.call(thisValue, searchValue, poison); +}, 'Symbol'); +assert.sameValue(called, 1); + +assert.sameValue(poisoned, 0); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-tostring.js b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-tostring.js new file mode 100644 index 0000000000..3de2a9919a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/replaceAll/this-tostring.js @@ -0,0 +1,93 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.replaceall +description: > + ToString(this value) +info: | + String.prototype.replaceAll ( searchValue, replaceValue ) + + ... + 3. Let string be ? ToString(O). + 4. Let searchString be ? ToString(searchValue). + 5. Let functionalReplace be IsCallable(replaceValue). + 6. If functionalReplace is false, then + a. Let replaceValue be ? ToString(replaceValue). + ... + 14. For each position in matchPositions, do + a. If functionalReplace is true, then + ... + b. Else, + ... + ii. Let captures be a new empty List. + iii. Let replacement be GetSubstitution(searchString, string, position, captures, undefined, replaceValue). +features: [String.prototype.replaceAll, Symbol.toPrimitive] +---*/ + +var result; + +var called; +var thisValue; + +called = 0; +thisValue = { + [Symbol.toPrimitive](){ + called += 1; + return 'aa'; + }, + toString() { + throw 'poison'; + }, + valueOf() { + throw 'poison'; + }, +}; + +result = ''.replaceAll.call(thisValue, 'a', 'z'); +assert.sameValue(result, 'zz', 'object @@toPrimitive'); +assert.sameValue(called, 1, '@@toPrimitive is called only once'); + +called = 0; +thisValue = { + [Symbol.toPrimitive]: undefined, + toString() { + called += 1; + return 'aa'; + }, + valueOf() { + throw 'poison'; + }, +}; + +result = ''.replaceAll.call(thisValue, 'a', 'z'); +assert.sameValue(result, 'zz', 'object toString'); +assert.sameValue(called, 1, 'toString is called only once'); + +called = 0; +thisValue = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf() { + called += 1; + return 'aa'; + }, +}; + +result = ''.replaceAll.call(thisValue, 'a', 'z'); +assert.sameValue(result, 'zz', 'object valueOf'); +assert.sameValue(called, 1, 'valueOf is called only once'); + +thisValue = 4244; +result = ''.replaceAll.call(thisValue, '4', 'z'); +assert.sameValue(result, 'z2zz', 'number'); + +thisValue = true; +result = ''.replaceAll.call(thisValue, 'ru', 'o m'); +assert.sameValue(result, 'to me', 'Boolean true'); + +thisValue = false; +result = ''.replaceAll.call(thisValue, 'al', 'on'); +assert.sameValue(result, 'fonse', 'Boolean false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1.1_T1.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1.1_T1.js new file mode 100644 index 0000000000..7b2bf39051 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1.1_T1.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.search (regexp) without arguments behaves like with + argument "undefined" +es5id: 15.5.4.12_A1.1_T1 +description: Call search() is the same search(undefined) +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +var x = "".search(); +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A10.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A10.js new file mode 100644 index 0000000000..030386b614 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A10.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: The String.prototype.search.length property has the attribute ReadOnly +es5id: 15.5.4.12_A10 +description: > + Checking if varying the String.prototype.search.length property + fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.search.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.search.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.search.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.search.length; + +verifyNotWritable(String.prototype.search, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.search.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.search.length; String.prototype.search.length = function(){return "shifted";}; String.prototype.search.length === __obj. Actual: ' + String.prototype.search.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A11.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A11.js new file mode 100644 index 0000000000..795e80eb73 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A11.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 length property of the search method is 1 +es5id: 15.5.4.12_A11 +description: Checking String.prototype.search.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.search.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.search.hasOwnProperty("length") return true. Actual: ' + String.prototype.search.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.search.length !== 1) { + throw new Test262Error('#2: String.prototype.search.length === 1. Actual: ' + String.prototype.search.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T1.js new file mode 100644 index 0000000000..79d929eb54 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) +es5id: 15.5.4.12_A1_T1 +description: Argument is true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.search = String.prototype.search; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.search(true) !== 0) { + throw new Test262Error('#1: __instance = new Object(true); __instance.search = String.prototype.search; __instance.search(true) === 0. Actual: ' + __instance.search(true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T10.js new file mode 100644 index 0000000000..334411e1a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T10.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.search (regexp) +es5id: 15.5.4.12_A1_T10 +description: > + Argument is object, and instance is string. Object with overrided + toString function +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +}; +var __str = "ssABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.search(__obj) !== 2) { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041B";}}; var __str = "ssABB\u0041BABAB"; __str.search(__obj) ===2. Actual: ' + __str.search(__obj)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T11.js new file mode 100644 index 0000000000..a07f263f8f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T11.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.search (regexp) +es5id: 15.5.4.12_A1_T11 +description: > + Argument is object, and instance is string. Object with overrided + toString function, that throw exception +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.search(__obj); + throw new Test262Error('#1: var x = __str.search(__obj) lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T12.js new file mode 100644 index 0000000000..c35de14041 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T12.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.search (regexp) +es5id: 15.5.4.12_A1_T12 +description: > + Argument is object, and instance is string. Object with overrided + toString and valueOf functions, valueOf throw exception +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +} +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.search(__obj); + throw new Test262Error('#1: var x = __str.search(__obj) lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T13.js new file mode 100644 index 0000000000..73014d35cf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T13.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.search (regexp) +es5id: 15.5.4.12_A1_T13 +description: > + Argument is object, and instance is string. Object with overrided + toString and valueOf functions +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041B\u0031ABAB\u0031BBAA".search(__obj) !== 5) { + throw new Test262Error('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; "ABB\\u0041B\\u0031ABAB\\u0031BBAA".search(__obj) ===5. Actual: ' + ("ABB\u0041B\u0031ABAB\u0031BBAA".search(__obj))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T14.js new file mode 100644 index 0000000000..289769742f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T14.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) +es5id: 15.5.4.12_A1_T14 +description: Instance is string, argument is regular expression +---*/ + +var __reg = new RegExp("77"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041BABAB\u0037\u0037BBAA".search(__reg) !== 9) { + throw new Test262Error('#1: var __reg = new RegExp("77"); "ABB\\u0041BABAB\\u0037\\u0037BBAA".search(__reg) === 9. Actual: ' + ("ABB\u0041BABAB\u0037\u0037BBAA".search(__reg))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T2.js new file mode 100644 index 0000000000..7598936a11 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T2.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.search (regexp) +es5id: 15.5.4.12_A1_T2 +description: Argument is function call, and instance is Boolean +---*/ + +var __instance = new Boolean; + +__instance.search = String.prototype.search; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.search(function() { + return false; + }()) !== 0) { + throw new Test262Error('#1: __instance = new Boolean; __instance.search = String.prototype.search; __instance.search(function(){return false;}()) === 0. Actual: ' + __instance.search(function() { + return false; + }())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T4.js new file mode 100644 index 0000000000..d537dae330 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T4.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) +es5id: 15.5.4.12_A1_T4 +description: Call search (regexp) without arguments +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString() evaluates to "" search() evaluates to search("") +if ("".search() !== 0) { + throw new Test262Error('#1: "".search() === 0. Actual: ' + ("".search())); +} + +if ("--undefined--".search() != 0) { + throw new Test262Error('#1: "--undefined--".search() === 0. Actual: ' + ("--undefined--".search())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T5.js new file mode 100644 index 0000000000..3b391cea83 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) +es5id: 15.5.4.12_A1_T5 +description: Argument is null, and instance is function call, that return string +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" search(null) evaluates to search("null") +if (function() { + return "gnulluna" + }().search(null) !== 1) { + throw new Test262Error('#1: function(){return "gnulluna"}().search(null) === 1. Actual: ' + function() { + return "gnulluna" + }().search(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T6.js new file mode 100644 index 0000000000..b576d87328 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T6.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.search (regexp) +es5id: 15.5.4.12_A1_T6 +description: Argument is x, and instance is new String, x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" search(undefined) evaluates to search("undefined") +if (new String("undefined").search(x) !== 0) { + throw new Test262Error('#1: var x; new String("undefined").search(x) === 0. Actual: ' + new String("undefined").search(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T7.js new file mode 100644 index 0000000000..a63e0ef059 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) +es5id: 15.5.4.12_A1_T7 +description: Argument is undefined, and instance is new String +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" search(undefined) evaluates to search("undefined") +if (String("undefined").search(undefined) !== 0) { + throw new Test262Error('#1: String("undefined").search(undefined) === 0. Actual: ' + String("undefined").search(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T8.js new file mode 100644 index 0000000000..71b0c1603f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T8.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) +es5id: 15.5.4.12_A1_T8 +description: > + Argument is void 0, and instance is String object with overrided + toString function +---*/ + +var __obj = { + toString: function() {} +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(void 0) evaluates to "undefined" search(void 0) evaluates to search("undefined") +if (String(__obj).search(void 0) !== 0) { + throw new Test262Error('#1: __obj = {toString:function(){}}; String(__obj).search(void 0) === 0. Actual: ' + String(__obj).search(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T9.js new file mode 100644 index 0000000000..eb6fefb2b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A1_T9.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.search (regexp) +es5id: 15.5.4.12_A1_T9 +description: > + Argument is function call, and instance is String object with + overrided toString and valueOf functions +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" search(undefined) evaluates to search("undefined") +if (new String(__obj).search(function() {}()) !== 0) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; new String(__obj).search(function(){}()) === 0. Actual: ' + new String(__obj).search(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T1.js new file mode 100644 index 0000000000..2adddf946b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) returns ... +es5id: 15.5.4.12_A2_T1 +description: Simple search substring inside string +---*/ + +var aString = new String("test string"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (aString.search("string") !== 5) { + throw new Test262Error('#1: var aString = new String("test string"); aString.search("string")=== 5. Actual: ' + aString.search("string")); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T2.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T2.js new file mode 100644 index 0000000000..3d967fad65 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) returns ... +es5id: 15.5.4.12_A2_T2 +description: Checking case sensitive of search, argument is string +---*/ + +var aString = new String("test string"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (aString.search("String") !== -1) { + throw new Test262Error('#1: var aString = new String("test string"); aString.search("String")=== -1. Actual: ' + aString.search("String")); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T3.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T3.js new file mode 100644 index 0000000000..ca382ff62c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) returns ... +es5id: 15.5.4.12_A2_T3 +description: Checking disabling of case sensitive of search, argument is RegExp +---*/ + +var aString = new String("test string"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (aString.search(/String/i) !== 5) { + throw new Test262Error('#1: var aString = new String("test string"); aString.search(/String/i)=== 5. Actual: ' + aString.search(/String/i)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T4.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T4.js new file mode 100644 index 0000000000..9f5f130e23 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T4.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) returns ... +es5id: 15.5.4.12_A2_T4 +description: > + Checking case sensitive of search, argument is RegExp with + uppercase symbols +---*/ + +var bString = new String("one two three four five"); +var regExp = /Four/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (bString.search(regExp) !== -1) { + throw new Test262Error('#1: var bString = new String("one two three four five"); var regExp = /Four/; bString.search(regExp)=== -1. Actual: ' + bString.search(regExp)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T5.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T5.js new file mode 100644 index 0000000000..3dcb067da5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) returns ... +es5id: 15.5.4.12_A2_T5 +description: > + Checking case sensitive of search, argument is RegExp without + uppercase symbols +---*/ + +var bString = new String("one two three four five"); +var regExp = /four/; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (bString.search(regExp) !== 14) { + throw new Test262Error('#1: var bString = new String("one two three four five"); var regExp = /four/; bString.search(regExp)=== 14. Actual: ' + bString.search(regExp)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T6.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T6.js new file mode 100644 index 0000000000..fd4dc1a24f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) returns ... +es5id: 15.5.4.12_A2_T6 +description: Searching the non-existent "notexist" substring +---*/ + +var aString = new String("test string"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (aString.search("notexist") !== -1) { + throw new Test262Error('#1: var aString = new String("test string"); aString.search("notexist")=== -1. Actual: ' + aString.search("notexist")); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T7.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T7.js new file mode 100644 index 0000000000..ddd916faad --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A2_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) returns ... +es5id: 15.5.4.12_A2_T7 +description: Simple search sentence inside string +---*/ + +var aString = new String("test string probe"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (aString.search("string pro") !== 5) { + throw new Test262Error('#1: var aString = new String("test string probe"); aString.search("string pro")=== 5. Actual: ' + aString.search("string pro")); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A3_T1.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A3_T1.js new file mode 100644 index 0000000000..8f2594a3ca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A3_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) ignores global properties of regexp +es5id: 15.5.4.12_A3_T1 +description: > + Checking results of search regexp with and without global + properties +---*/ + +var aString = new String("power of the power of the power of the power of the power of the power of the great sword"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (aString.search(/the/) !== aString.search(/the/g)) { + throw new Test262Error('#1: var aString = new String("power of the power of the power of the power of the power of the power of the great sword"); aString.search(/the/)=== aString.search(/the/g). Actual: ' + aString.search(/the/)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A3_T2.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A3_T2.js new file mode 100644 index 0000000000..c46377f63d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A3_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search (regexp) ignores global properties of regexp +es5id: 15.5.4.12_A3_T2 +description: > + Checking results of search regexp with and without global + properties. Unicode symbols used +---*/ + +var aString = new String("power \u006F\u0066 the power of the power \u006F\u0066 the power of the power \u006F\u0066 the power of the great sword"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (aString.search(/of/) !== aString.search(/of/g)) { + throw new Test262Error('#1: var aString = new String("power \\u006F\\u0066 the power of the power \\u006F\\u0066 the power of the power \\u006F\\u0066 the power of the great sword"); aString.search(/of/)=== aString.search(/of/g). Actual: ' + aString.search(/of/)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A6.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A6.js new file mode 100644 index 0000000000..e4f90d82a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.search has not prototype property +es5id: 15.5.4.12_A6 +description: Checking String.prototype.search.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.search.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.search.prototype === undefined. Actual: ' + String.prototype.search.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A7.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A7.js new file mode 100644 index 0000000000..d8e865cd03 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A7.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.search can't be used as constructor +es5id: 15.5.4.12_A7 +description: Checking if creating the String.prototype.search object fails +---*/ + +var __FACTORY = String.prototype.search; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.search; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.1: __FACTORY = String.prototype.search; "__instance = new __FACTORY" throw a TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A8.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A8.js new file mode 100644 index 0000000000..1735dfb811 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A8.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: The String.prototype.search.length property has the attribute DontEnum +es5id: 15.5.4.12_A8 +description: > + Checking if enumerating the String.prototype.search.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.search.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.search.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.search.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.search.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.search.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.search) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.search){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A9.js b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A9.js new file mode 100644 index 0000000000..ffe40c992a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/S15.5.4.12_A9.js @@ -0,0 +1,38 @@ +// 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.search.length property does not have the attribute + DontDelete +es5id: 15.5.4.12_A9 +description: > + Checking if deleting the String.prototype.search.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.search.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.search.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.search.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.search.length) { + throw new Test262Error('#1: delete String.prototype.search.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.search.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.search.length; String.prototype.search.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.search.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/browser.js b/js/src/tests/test262/built-ins/String/prototype/search/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-get-err.js b/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-get-err.js new file mode 100644 index 0000000000..c9b996d864 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-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 @@search property +es6id: 21.1.3.15 +info: | + [...] + 3. If regexp is neither undefined nor null, then + a. Let searcher be GetMethod(regexp, @@search). + b. ReturnIfAbrupt(searcher). +features: [Symbol.search] +---*/ + +var poisonedSearch = {}; +Object.defineProperty(poisonedSearch, Symbol.search, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.search(poisonedSearch); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-invocation.js b/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-invocation.js new file mode 100644 index 0000000000..2ec7e813ef --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-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 @@search property of user-supplied objects +es6id: 21.1.3.15 +info: | + [...] + 3. If regexp is neither undefined nor null, then + a. Let searcher be GetMethod(regexp, @@search). + b. ReturnIfAbrupt(searcher). + c. If searcher is not undefined, then + i. Return Call(searcher, regexp, «O») +features: [Symbol.search] +---*/ + +var regexp = {}; +var returnVal = {}; +var callCount = 0; +var thisVal, args; + +regexp[Symbol.search] = function() { + callCount += 1; + thisVal = this; + args = arguments; + return returnVal; +}; + +assert.sameValue('O'.search(regexp), returnVal); +assert.sameValue(callCount, 1, 'Invokes the method exactly once'); +assert.sameValue(thisVal, regexp); +assert.notSameValue(args, undefined); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], 'O'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-is-null.js b/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-is-null.js new file mode 100644 index 0000000000..ef09cfdaec --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/cstm-search-is-null.js @@ -0,0 +1,35 @@ +// 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.search +description: > + If regexp's Symbol.search property is null, no error is thrown. +info: | + String.prototype.search ( regexp ) + + [...] + 2. If regexp is neither undefined nor null, then + a. Let searcher be ? GetMethod(regexp, @@search). + b. If searcher is not undefined, then + [...] + [...] + 5. Return ? Invoke(rx, @@search, « string »). + + GetMethod ( V, P ) + + [...] + 2. Let func be ? GetV(V, P). + 3. If func is either undefined or null, return undefined. +features: [Symbol.search] +---*/ + +var regexp = {}; +regexp[Symbol.search] = null; +regexp.toString = function() { return "\\d"; }; +regexp.valueOf = function() { throw new Test262Error("should not be called"); }; + +assert.sameValue("abc".search(regexp), -1); +assert.sameValue("ab3c".search(regexp), 2); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/invoke-builtin-search-searcher-undef.js b/js/src/tests/test262/built-ins/String/prototype/search/invoke-builtin-search-searcher-undef.js new file mode 100644 index 0000000000..5a92adc0a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/invoke-builtin-search-searcher-undef.js @@ -0,0 +1,53 @@ +// Copyright (C) 2015 Mike Pennisi. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Invocation of @@search property of internally-created RegExps when `this` value has an `undefined` @@search property +es6id: 21.1.3.15 +info: | + [...] + 3. If regexp is neither undefined nor null, then + a. Let searcher be GetMethod(regexp, @@search). + b. ReturnIfAbrupt(searcher). + c. If searcher is not undefined , then + [...] + [...] + 6. Let rx be RegExpCreate(regexp, undefined) (see 21.2.3.2.3). + 7. ReturnIfAbrupt(rx). + 8. Return Invoke(rx, @@search, «S»). +features: [Symbol.search] +---*/ + +var target = new String('target'); +var originalSearch = RegExp.prototype[Symbol.search]; +var returnVal = {}; +var result, thisVal, args; + +target[Symbol.search] = undefined; + +// Fail early if the method is undefined. This test's cleanup logic would +// otherwise install the value `undefined` to the `Symbol.search` property of +// the built-in prototype. +assert.notSameValue(originalSearch, undefined); + +RegExp.prototype[Symbol.search] = function() { + thisVal = this; + args = arguments; + return returnVal; +}; + +try { + result = target.search('string source'); + + assert(thisVal instanceof RegExp); + assert.sameValue(thisVal.source, 'string source'); + assert.sameValue(thisVal.flags, ''); + assert.sameValue(args.length, 1); + assert.sameValue(args[0], 'target'); + assert.sameValue(result, returnVal); +} finally { + RegExp.prototype[Symbol.search] = originalSearch; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/invoke-builtin-search.js b/js/src/tests/test262/built-ins/String/prototype/search/invoke-builtin-search.js new file mode 100644 index 0000000000..6eec9da7fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/invoke-builtin-search.js @@ -0,0 +1,43 @@ +// 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 @@search property of internally-created RegExps +es6id: 21.1.3.15 +info: | + [...] + 6. Let rx be RegExpCreate(regexp, undefined) (see 21.2.3.2.3). + 7. ReturnIfAbrupt(rx). + 8. Return Invoke(rx, @@search, «S»). +features: [Symbol.search] +---*/ + +var originalSearch = RegExp.prototype[Symbol.search]; +var returnVal = {}; +var result, thisVal, args; + +// Fail early if the method is undefined. This test's cleanup logic would +// otherwise install the value `undefined` to the `Symbol.search` property of +// the built-in prototype. +assert.notSameValue(originalSearch, undefined); + +RegExp.prototype[Symbol.search] = function() { + thisVal = this; + args = arguments; + return returnVal; +}; + +try { + result = 'target'.search('string source'); + + assert(thisVal instanceof RegExp); + assert.sameValue(thisVal.source, 'string source'); + assert.sameValue(thisVal.flags, ''); + assert.sameValue(args.length, 1); + assert.sameValue(args[0], 'target'); + assert.sameValue(result, returnVal); +} finally { + RegExp.prototype[Symbol.search] = originalSearch; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/name.js b/js/src/tests/test262/built-ins/String/prototype/search/name.js new file mode 100644 index 0000000000..ad555b4841 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/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.15 +description: > + String.prototype.search.name is "search". +info: | + String.prototype.search ( regexp ) + + 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.search.name, "search"); + +verifyNotEnumerable(String.prototype.search, "name"); +verifyNotWritable(String.prototype.search, "name"); +verifyConfigurable(String.prototype.search, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/search/not-a-constructor.js new file mode 100644 index 0000000000..c61e4f3b16 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/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.search 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.search), + false, + 'isConstructor(String.prototype.search) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.search(); +}, '`new String.prototype.search()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/search/shell.js b/js/src/tests/test262/built-ins/String/prototype/search/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/search/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/search/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..955dac4149 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/search/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.search +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var search = String.prototype.search; + +assert.sameValue(typeof search, 'function'); + +assert.throws(TypeError, function() { + search.call(undefined, /./); +}, 'undefined'); + +assert.throws(TypeError, function() { + search.call(null, /./); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/shell.js b/js/src/tests/test262/built-ins/String/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A10.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A10.js new file mode 100644 index 0000000000..d49e0f0bc9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A10.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: The String.prototype.slice.length property has the attribute ReadOnly +es5id: 15.5.4.13_A10 +description: > + Checking if varying the String.prototype.slice.length property + fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.slice.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.slice.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.slice.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.slice.length; + +verifyNotWritable(String.prototype.slice, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.slice.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.slice.length; String.prototype.slice.length = function(){return "shifted";}; String.prototype.slice.length === __obj. Actual: ' + String.prototype.slice.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A11.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A11.js new file mode 100644 index 0000000000..a32c1aec5e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A11.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 length property of the slice method is 2 +es5id: 15.5.4.13_A11 +description: Checking String.prototype.slice.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.slice.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.slice.hasOwnProperty("length") return true. Actual: ' + String.prototype.slice.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.slice.length !== 2) { + throw new Test262Error('#2: String.prototype.slice.length === 2. Actual: ' + String.prototype.slice.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T1.js new file mode 100644 index 0000000000..3461e53037 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T1 +description: Arguments are false and true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.slice = String.prototype.slice; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.slice(false, true) !== "t") { + throw new Test262Error('#1: __instance = new Object(true); __instance.slice = String.prototype.slice; __instance.slice(false, true) === "t". Actual: ' + __instance.slice(false, true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T10.js new file mode 100644 index 0000000000..022f26c334 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T10.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.slice (start, end) +es5id: 15.5.4.13_A1_T10 +description: > + Arguments are object and function call, and instance is String, + object have overrided valueOf function +---*/ + +var __obj = { + valueOf: function() { + return 2; + } +}; + +var __str = "\u0035ABBBABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.slice(__obj, function() { + return __str.slice(0, 1); + }()) !== "BBB") { + throw new Test262Error('#1: var x; var __obj = {valueOf:function(){return 2;}}; var __str = "\u0035ABBBABAB"; __str.slice(__obj, function(){return __str.slice(0,1);}()) === "BBB". Actual: ' + __str.slice(__obj, function() { + return __str.slice(0, 1); + }())); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T11.js new file mode 100644 index 0000000000..7b2ec19713 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T11.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: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T11 +description: > + Arguments are objects, and instance is string, objects have + overrided valueOf function, that return exception +---*/ + +var __obj = { + valueOf: function() { + throw "instart"; + } +}; +var __obj2 = { + valueOf: function() { + throw "inend"; + } +}; +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.slice(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.slice(__obj,__obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "instart") { + throw new Test262Error('#1.1: Exception === "instart". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T12.js new file mode 100644 index 0000000000..49463b1948 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T12.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.slice (start, end) +es5id: 15.5.4.13_A1_T12 +description: > + Arguments are objects, and instance is string. First object have + overrided valueOf function and toString function, that return + exception. Second object have overrided valueOf function, that + return exception +---*/ + +var __obj = { + valueOf: function() { + return {}; + }, + toString: function() { + throw "instart"; + } +}; +var __obj2 = { + valueOf: function() { + throw "inend"; + } +}; +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.slice(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.slice(__obj,__obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "instart") { + throw new Test262Error('#1.1: Exception === "instart". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T13.js new file mode 100644 index 0000000000..90f54f8122 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T13.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T13 +description: > + Arguments are objects, and instance is string. First object have + overrided valueOf and toString functions. Second object have + overrided toString function, that return exception +---*/ + +var __obj = { + valueOf: function() { + return {}; + }, + toString: function() { + return 1; + } +}; +var __obj2 = { + toString: function() { + throw "inend"; + } +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = "ABB\u0041BABAB\u0031BBAA".slice(__obj, __obj2); + throw new Test262Error('#1: "var x = slice(__obj,__obj2)" lead to throwing exception'); +} catch (e) { + if (e !== "inend") { + throw new Test262Error('#1.1: Exception === "inend". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T14.js new file mode 100644 index 0000000000..5288bfdd93 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T14.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T14 +description: Used one argument, that is function(){}(). Instance is string +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("report".slice(function() {}()) !== "report") { + throw new Test262Error('#1: "report".slice(function(){}()) === "report". Actual: ' + "report".slice(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T15.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T15.js new file mode 100644 index 0000000000..df74079d4f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T15.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T15 +description: > + Call slice without arguments. Instance is Number with + prototype.slice = String.prototype.slice +---*/ + +var __num = 11.001002; + +Number.prototype.slice = String.prototype.slice; + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__num.slice() !== "11.001002") { + throw new Test262Error('#1: var __num = 11.001002; Number.prototype.slice = String.prototype.slice; __num.slice()==="11.001002". Actual: ' + __num.slice()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T2.js new file mode 100644 index 0000000000..d2f88a47e9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T2.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.slice (start, end) +es5id: 15.5.4.13_A1_T2 +description: > + Arguments are function call and x, and instance is Boolean. x is + undefined variable +---*/ + +var __instance = new Boolean; + +__instance.slice = String.prototype.slice; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.slice(function() { + return true; + }(), x) !== "alse") { + throw new Test262Error('#1: var x; __instance = new Boolean; __instance.slice = String.prototype.slice; __instance.slice(function(){return true;}(),x) === "alse". Actual: ' + __instance.slice(function() { + return true; + }(), x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T4.js new file mode 100644 index 0000000000..f425a58d9d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T4.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T4 +description: > + Arguments are null and number, and instance is function call, that + returned string +---*/ + +//since ToInteger(null) yelds 0 +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (function() { + return "gnulluna" + }().slice(null, -3) !== "gnull") { + throw new Test262Error('#1: function(){return "gnulluna"}().slice(null, -3) === "gnull". Actual: ' + function() { + return "gnulluna" + }().slice(null, -3)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T5.js new file mode 100644 index 0000000000..663dd48624 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T5.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.slice (start, end) +es5id: 15.5.4.13_A1_T5 +description: > + Arguments are null and call other slice(start, end), and instance + is function object, that have overrided valueOf and toString + functions +---*/ + +__func.valueOf = function() { + return "gnulluna" +}; +__func.toString = function() { + return __func; +}; + +Function.prototype.slice = String.prototype.slice; + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.slice(null, Function().slice(__func, 5).length) !== "gnull") { + throw new Test262Error('#1: __func.slice(null, Function().slice(__func,5).length) === "gnull". Actual: ' + __func.slice(null, Function().slice(__func, 5).length)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func() {}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T6.js new file mode 100644 index 0000000000..3bd4a0d1f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T6 +description: > + Arguments are x and number, and instance is new String, x is + undefined variable +---*/ + +//since ToInteger(undefined yelds 0) +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (new String("undefined").slice(x, 3) !== "und") { + throw new Test262Error('#1: var x; new String("undefined").slice(x,3) === "und". Actual: ' + new String("undefined").slice(x, 3)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T7.js new file mode 100644 index 0000000000..710b0a7c11 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T7.js @@ -0,0 +1,19 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T7 +description: Arguments are symbol and undefined, and instance is String +---*/ + +//since ToInteger("e") yelds 0 +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String(void 0).slice("e", undefined) !== "undefined") { + throw new Test262Error('#1: String(void 0).slice("e",undefined) === "undefined". Actual: ' + String(void 0).slice("e", undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T8.js new file mode 100644 index 0000000000..fac372584a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T8.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) +es5id: 15.5.4.13_A1_T8 +description: > + Arguments are negative number and void 0, and instance is + String(object), object have overrided toString function +---*/ + +var __obj = { + toString: function() {} +}; + +//since void 0 yelds 0 +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String(__obj).slice(-4, void 0) !== "ined") { + throw new Test262Error('#1: __obj = {toString:function(){}}; String(__obj).slice(-4,void 0) === "ined". Actual: ' + String(__obj).slice(-4, void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T9.js new file mode 100644 index 0000000000..463a9fc99f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A1_T9.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.slice (start, end) +es5id: 15.5.4.13_A1_T9 +description: > + Arguments are undefined and object, and instance is + String(object), object have overrided valueOf and toString + functions +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +//since ToInteger(undefined) yelds 0 +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (new String(__obj).slice( /*(function(){})()*/ undefined, __obj) !== "") { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; new String(__obj).slice(//*(function(){})()*//undefined,__obj) === "". Actual: ' + new String(__obj).slice( /*(function(){})()*/ undefined, __obj)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T1.js new file mode 100644 index 0000000000..90608aa0a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T1 +description: Checking type of slice() +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __string.slice() !== "string") { + throw new Test262Error('#1: __string = new String("this is a string object"); typeof __string.slice() === "string". Actual: ' + typeof __string.slice()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T2.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T2.js new file mode 100644 index 0000000000..9e12cb4c71 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T2 +description: start is NaN, end is Infinity +---*/ + +var __string = new String('this is a string object'); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(NaN, Infinity) !== "this is a string object") { + throw new Test262Error('#1: __string = new String(\'this is a string object\'); __string.slice(NaN, Infinity) === "this is a string object". Actual: ' + __string.slice(NaN, Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T3.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T3.js new file mode 100644 index 0000000000..5ee4bae1b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T3 +description: Call slice from empty String object +---*/ + +var __string = new String(""); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(1, 0) !== "") { + throw new Test262Error('#1: __string = new String(""); __string.slice(1,0) === "". Actual: ' + __string.slice(1, 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T4.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T4.js new file mode 100644 index 0000000000..1852bd1144 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T4.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T4 +description: start is Infinity, end is NaN +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(Infinity, NaN) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.slice(Infinity, NaN) === "". Actual: ' + __string.slice(Infinity, NaN)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T5.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T5.js new file mode 100644 index 0000000000..69ce875fbe --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T5.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T5 +description: start is Infinity, end is Infinity +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(Infinity, Infinity) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.slice(Infinity, Infinity) === "". Actual: ' + __string.slice(Infinity, Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T6.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T6.js new file mode 100644 index 0000000000..42eb813c45 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T6 +description: start is negative float number, end is 0 +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(-0.01, 0) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.slice(-0.01,0) === "". Actual: ' + __string.slice(-0.01, 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T7.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T7.js new file mode 100644 index 0000000000..990ddb476c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T7 +description: start is tested_string.length, end is tested_string.length +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(__string.length, __string.length) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.slice(__string.length, __string.length) === "". Actual: ' + __string.slice(__string.length, __string.length)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T8.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T8.js new file mode 100644 index 0000000000..5fd8ab1a43 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T8.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T8 +description: start is tested_string.length+1, end is 0 +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(__string.length + 1, 0) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.slice(__string.length+1, 0) === "". Actual: ' + __string.slice(__string.length + 1, 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T9.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T9.js new file mode 100644 index 0000000000..bde6e28c01 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A2_T9.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) returns a string value(not object) +es5id: 15.5.4.13_A2_T9 +description: start is -Infinity, end is -Infinity +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.slice(-Infinity, -Infinity) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.slice(-Infinity, -Infinity) === "". Actual: ' + __string.slice(-Infinity, -Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T1.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T1.js new file mode 100644 index 0000000000..524901cf46 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) can be applied to object instances +es5id: 15.5.4.13_A3_T1 +description: Apply String.prototype.slice to Object instance +---*/ + +var __instance = new Object(); + +__instance.slice = String.prototype.slice; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.slice(0, 8) !== "[object ") { + throw new Test262Error('#1: __instance = new Object(); __instance.slice = String.prototype.slice; __instance.slice(0,8) === "[object ". Actual: ' + __instance.slice(0, 8)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T2.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T2.js new file mode 100644 index 0000000000..a5317e1274 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T2.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice (start, end) can be applied to object instances +es5id: 15.5.4.13_A3_T2 +description: > + Apply String.prototype.slice to Object instance, use other value + for start and end values +---*/ + +var __instance = new Object(); + +__instance.slice = String.prototype.slice; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.slice(8, __instance.toString().length) !== "Object]") { + throw new Test262Error('#1: __instance = new Object(); __instance.slice = String.prototype.slice; __instance.slice(8,__instance.toString().length) === "Object]". Actual: ' + __instance.slice(8, __instance.toString().length)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T3.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T3.js new file mode 100644 index 0000000000..b34ec5e159 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T3.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.slice (start, end) can be applied to object instances +es5id: 15.5.4.13_A3_T3 +description: > + Apply String.prototype.slice to Object instance, and call + instance.slice(...).slice(...) +---*/ + +var __instance = { + toString: function() { + return "function(){}"; + } +}; + +__instance.slice = String.prototype.slice; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.slice(-Infinity, 8).slice(1, Infinity) !== "unction") { + throw new Test262Error('#1: __instance = function(){}; __instance.slice = String.prototype.slice; __instance.slice(-Infinity,8).slice(1,Infinity) === "unction". Actual: ' + __instance.slice(-Infinity, 8).slice(1, Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T4.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T4.js new file mode 100644 index 0000000000..5753adc20b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A3_T4.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.slice (start, end) can be applied to object instances +es5id: 15.5.4.13_A3_T4 +description: > + Checknig if applying String.prototype.slice to Function object + instance passes +---*/ + +__FACTORY.prototype.toString = function() { + return this.value + ''; +}; + +var __instance = new __FACTORY(void 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.slice(0, 100) !== "undefined") { + throw new Test262Error('#1: __instance.slice(0,100) === "undefined". Actual: ' + __instance.slice(0, 100)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(value) { + this.value = value, + this.slice = String.prototype.slice; + //this.substring = String.prototype.substring; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A6.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A6.js new file mode 100644 index 0000000000..fff0252d31 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.slice has not prototype property +es5id: 15.5.4.13_A6 +description: Checking String.prototype.slice.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.slice.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.slice.prototype === undefined. Actual: ' + String.prototype.slice.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A7.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A7.js new file mode 100644 index 0000000000..aba0108631 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A7.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.slice can't be used as constructor +es5id: 15.5.4.13_A7 +description: Checking if creating the String.prototype.slice object fails +---*/ + +var FACTORY = String.prototype.slice; + +assert.throws(TypeError, function() { + new FACTORY; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A8.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A8.js new file mode 100644 index 0000000000..a2af98ed75 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A8.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: The String.prototype.slice.length property has the attribute DontEnum +es5id: 15.5.4.13_A8 +description: > + Checking if enumerating the String.prototype.slice.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.slice.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.slice.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.slice.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.slice.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.slice.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.slice) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.slice){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A9.js b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A9.js new file mode 100644 index 0000000000..2f555102c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/S15.5.4.13_A9.js @@ -0,0 +1,38 @@ +// 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.slice.length property does not have the attribute + DontDelete +es5id: 15.5.4.13_A9 +description: > + Checking if deleting the String.prototype.slice.length property + fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.slice.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.slice.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.slice.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.slice.length) { + throw new Test262Error('#1: delete String.prototype.slice.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.slice.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.slice.length; String.prototype.slice.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.slice.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/browser.js b/js/src/tests/test262/built-ins/String/prototype/slice/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/name.js b/js/src/tests/test262/built-ins/String/prototype/slice/name.js new file mode 100644 index 0000000000..24ea647443 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/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.16 +description: > + String.prototype.slice.name is "slice". +info: | + String.prototype.slice ( start, end ) + + 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.slice.name, "slice"); + +verifyNotEnumerable(String.prototype.slice, "name"); +verifyNotWritable(String.prototype.slice, "name"); +verifyConfigurable(String.prototype.slice, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/slice/not-a-constructor.js new file mode 100644 index 0000000000..e4220ef5b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/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.slice 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.slice), + false, + 'isConstructor(String.prototype.slice) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.slice(); +}, '`new String.prototype.slice()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/shell.js b/js/src/tests/test262/built-ins/String/prototype/slice/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/slice/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/slice/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..8aa09aaa5d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/slice/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.slice +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var slice = String.prototype.slice; + +assert.sameValue(typeof slice, 'function'); + +assert.throws(TypeError, function() { + slice.call(undefined, 0); +}, 'undefined'); + +assert.throws(TypeError, function() { + slice.call(null, 0); +}, 'null'); + +reportCompare(0, 0); 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); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/browser.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/coerced-values-of-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/coerced-values-of-position.js new file mode 100644 index 0000000000..b12e6d8e0f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/coerced-values-of-position.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns based on coerced values of position. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 9. Let pos be ToInteger(position). (If position is undefined, this step + produces the value 0). + 10. ReturnIfAbrupt(pos). + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. If searchLength+start is greater than len, return false. + 15. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + 16. Otherwise, return false. + ... +---*/ + +var str = 'The future is cool!'; + +assert(str.startsWith('The future', NaN), 'NaN coerced to 0'); +assert(str.startsWith('The future', null), 'null coerced to 0'); +assert(str.startsWith('The future', false), 'false coerced to 0'); +assert(str.startsWith('The future', ''), '"" coerced to 0'); +assert(str.startsWith('The future', '0'), '"0" coerced to 0'); +assert(str.startsWith('The future', undefined), 'undefined coerced to 0'); +assert(str.startsWith('The future', 0.4), '0.4 coerced to 0'); + +assert.sameValue( + str.startsWith('The future', true), false, + 'true coerced to 1' +); +assert.sameValue(str.startsWith('The future', '1'), false, '"1" coerced to 1'); +assert.sameValue(str.startsWith('The future', 1.4), false, '1.4 coerced to 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js new file mode 100644 index 0000000000..3e19e74994 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/length.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + String.prototype.startsWith.length value and descriptor. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + The length property of the startsWith method is 1. + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.startsWith.length, 1, + 'The value of `String.prototype.startsWith.length` is `1`' +); + +verifyNotEnumerable(String.prototype.startsWith, 'length'); +verifyNotWritable(String.prototype.startsWith, 'length'); +verifyConfigurable(String.prototype.startsWith, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js new file mode 100644 index 0000000000..4baa4a3076 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + String.prototype.startsWith.name value and descriptor. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.prototype.startsWith.name, 'startsWith', + 'The value of `String.prototype.startsWith.name` is `"startsWith"`' +); + +verifyNotEnumerable(String.prototype.startsWith, 'name'); +verifyNotWritable(String.prototype.startsWith, 'name'); +verifyConfigurable(String.prototype.startsWith, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/not-a-constructor.js new file mode 100644 index 0000000000..a286537efc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/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.startsWith 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.startsWith), + false, + 'isConstructor(String.prototype.startsWith) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.startsWith(); +}, '`new String.prototype.startsWith()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/out-of-bounds-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/out-of-bounds-position.js new file mode 100644 index 0000000000..820e85662d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/out-of-bounds-position.js @@ -0,0 +1,45 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns false if searchLength + start position is greater than string length. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. If searchLength+start is greater than len, return false. + ... +---*/ + +var str = 'The future is cool!'; + +assert.sameValue( + str.startsWith('!', str.length), false, + 'str.startsWith("!", str.length) returns false' +); + +assert.sameValue( + str.startsWith('!', 100), false, + 'str.startsWith("!", 100) returns false' +); + +assert.sameValue( + str.startsWith('!', Infinity), false, + 'str.startsWith("!", Infinity) returns false' +); + +assert( + str.startsWith('The future', -1), + 'position argument < 0 will search from the start of the string (-1)' +); + +assert( + str.startsWith('The future', -Infinity), + 'position argument < 0 will search from the start of the string (-Infinity)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position-as-symbol.js new file mode 100644 index 0000000000..668ab343aa --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position-as-symbol.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns abrupt from ToInteger(position) as a Symbol. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 9. Let pos be ToInteger(position). (If position is undefined, this step + produces the value 0). + 10. ReturnIfAbrupt(pos). + ... +features: [Symbol] +---*/ + +var position = Symbol(); + +assert.throws(TypeError, function() { + ''.startsWith('', position); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position.js new file mode 100644 index 0000000000..2a8e9b9917 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-position.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns abrupt from ToInteger(position). +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 9. Let pos be ToInteger(position). (If position is undefined, this step + produces the value 0). + 10. ReturnIfAbrupt(pos). + ... +---*/ + +var position = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.startsWith('', position); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-as-symbol.js new file mode 100644 index 0000000000..d4a53cff06 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-as-symbol.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns abrupt from ToString(searchString) as a Symbol +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 7. Let searchStr be ToString(searchString). + 8. ReturnIfAbrupt(searchString). + ... +features: [Symbol] +---*/ + +var s = Symbol(); + +assert.throws(TypeError, function() { + ''.startsWith(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js new file mode 100644 index 0000000000..5fd775ad0b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring-regexp-test.js @@ -0,0 +1,44 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns abrupt from IsRegExp(searchString). +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 4. Let isRegExp be IsRegExp(searchString). + 5. ReturnIfAbrupt(isRegExp). + ... + + 7.2.8 IsRegExp ( argument ) + + 2. Let isRegExp be Get(argument, @@match). + 3. ReturnIfAbrupt(isRegExp). +features: [Symbol.match] +---*/ + +var obj = {}; +Object.defineProperty(obj, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.startsWith(obj); +}); + +var regexp = /./; +Object.defineProperty(regexp, Symbol.match, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + ''.startsWith(regexp); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring.js new file mode 100644 index 0000000000..26a9376388 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-searchstring.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. +/*--- +es6id: 21.1.3.18 +description: > + Returns abrupt from ToString(searchString) +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 7. Let searchStr be ToString(searchString). + 8. ReturnIfAbrupt(searchString). + ... +---*/ + +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + ''.startsWith(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this-as-symbol.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this-as-symbol.js new file mode 100644 index 0000000000..2e66a64380 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this-as-symbol.js @@ -0,0 +1,22 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns abrupt from ToString(this) where this is a Symbol +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +features: [Symbol] +---*/ + +var s = Symbol(''); + +assert.throws(TypeError, function() { + String.prototype.startsWith.call(s, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this.js new file mode 100644 index 0000000000..727cd25b93 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns abrupt from ToString(this) +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). + 3. ReturnIfAbrupt(S). +---*/ + +var o = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.startsWith.call(o, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js new file mode 100644 index 0000000000..a65c494055 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/return-true-if-searchstring-is-empty.js @@ -0,0 +1,42 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns true if searchString.length == 0. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. If searchLength+start is greater than len, return false. + 15. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + ... +---*/ + +var str = 'The future is cool!'; + +assert( + str.startsWith(''), + 'str.startsWith("") returns true' +); + +assert( + str.startsWith('', str.length), + 'str.startsWith("", str.length) returns true' +); + +assert( + str.startsWith(''), + 'str.startsWith("") returns true' +); + +assert( + str.startsWith('', Infinity), + 'str.startsWith("", Infinity) returns true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-with-position.js new file mode 100644 index 0000000000..bae9a17f2e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-with-position.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. +/*--- +es6id: 21.1.3.18 +description: > + Returns true if searchString appears as a substring of the given string with a + given position. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. If searchLength+start is greater than len, return false. + 15. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + ... +---*/ + +var str = 'The future is cool!'; + +assert( + str.startsWith('The future', 0), + 'str.startsWith("The future", 0) === true' +); +assert( + str.startsWith('future', 4), + 'str.startsWith("future", 4) === true' +); +assert( + str.startsWith(' is cool!', 10), + 'str.startsWith(" is cool!", 10) === true' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-without-position.js new file mode 100644 index 0000000000..252a877cae --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-found-without-position.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. +/*--- +es6id: 21.1.3.18 +description: > + Returns true if searchString appears as a substring of the given string. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. If searchLength+start is greater than len, return false. + 15. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + ... +---*/ + +var str = 'The future is cool!'; + +assert(str.startsWith('The '), 'str.startsWith("The ") === true'); +assert(str.startsWith('The future'), 'str.startsWith("The future") === true'); +assert(str.startsWith(str), 'str.startsWith(str) === true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js new file mode 100644 index 0000000000..e07883e18b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-is-regexp-throws.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Throws a TypeError if searchString is a RegExp. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 4. Let isRegExp be IsRegExp(searchString). + 5. ReturnIfAbrupt(isRegExp). + 6. If isRegExp is true, throw a TypeError exception. + ... +---*/ + +var searchString = /./; + +assert.throws(TypeError, function() { + ''.startsWith(searchString); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-with-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-with-position.js new file mode 100644 index 0000000000..103223214b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-with-position.js @@ -0,0 +1,33 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Returns false if searchString is not found with a given position. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. If searchLength+start is greater than len, return false. + 15. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + 16. Otherwise, return false. + ... +---*/ + +var str = 'The future is cool!'; + +assert.sameValue( + str.startsWith('The future', 1), false, + 'str.startsWith("The future", 1) === false' +); + +assert.sameValue( + str.startsWith(str, 1), false, + 'str.startsWith(str, 1) === false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-without-position.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-without-position.js new file mode 100644 index 0000000000..04afa3c929 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/searchstring-not-found-without-position.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. +/*--- +es6id: 21.1.3.18 +description: > + Returns false if searchString is not found. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + ... + 11. Let len be the number of elements in S. + 12. Let start be min(max(pos, 0), len). + 13. Let searchLength be the number of elements in searchStr. + 14. If searchLength+start is greater than len, return false. + 15. If the sequence of elements of S starting at start of length searchLength + is the same as the full element sequence of searchStr, return true. + 16. Otherwise, return false. + ... +---*/ + +var str = 'The future is cool!'; + +assert.sameValue( + str.startsWith('Flash'), false, + 'str.startsWith("Flash") === false' +); +assert.sameValue( + str.startsWith('THE FUTURE'), false, + 'startsWith is case sensitive' +); +assert.sameValue( + str.startsWith('future is cool!'), false, + 'str.startsWith("future is cool!") === false' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/shell.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/startsWith.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/startsWith.js new file mode 100644 index 0000000000..a0f0397a0c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/startsWith.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Property type and descriptor. +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof String.prototype.startsWith, + 'function', + '`typeof String.prototype.startsWith` is `function`' +); + +verifyNotEnumerable(String.prototype, 'startsWith'); +verifyWritable(String.prototype, 'startsWith'); +verifyConfigurable(String.prototype, 'startsWith'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-null-throws.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-null-throws.js new file mode 100644 index 0000000000..962a68f925 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-null-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Throws TypeError when `this` is null +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.startsWith.call(null, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-undefined-throws.js b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-undefined-throws.js new file mode 100644 index 0000000000..6b0803a2f6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/startsWith/this-is-undefined-throws.js @@ -0,0 +1,18 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.3.18 +description: > + Throws TypeError when `this` is undefined +info: | + 21.1.3.18 String.prototype.startsWith ( searchString [ , position ] ) + + 1. Let O be RequireObjectCoercible(this value). + 2. Let S be ToString(O). +---*/ + +assert.throws(TypeError, function() { + String.prototype.startsWith.call(undefined, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A10.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A10.js new file mode 100644 index 0000000000..975f744408 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A10.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: The String.prototype.substring.length property has the attribute ReadOnly +es5id: 15.5.4.15_A10 +description: > + Checking if varying the String.prototype.substring.length property + fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.substring.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.substring.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.substring.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.substring.length; + +verifyNotWritable(String.prototype.substring, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.substring.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.substring.length; String.prototype.substring.length = function(){return "shifted";}; String.prototype.substring.length === __obj. Actual: ' + String.prototype.substring.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A11.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A11.js new file mode 100644 index 0000000000..e47ca07b9b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A11.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 length property of the substring method is 2 +es5id: 15.5.4.15_A11 +description: Checking String.prototype.substring.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.substring.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.substring.hasOwnProperty("length") return true. Actual: ' + String.prototype.substring.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.substring.length !== 2) { + throw new Test262Error('#2: String.prototype.substring.length === 2. Actual: ' + String.prototype.substring.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T1.js new file mode 100644 index 0000000000..ff536ea56c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T1 +description: Arguments are false and true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(false, true) !== "t") { + throw new Test262Error('#1: __instance = new Object(true); __instance.substring = String.prototype.substring; __instance.substring(false, true) === "t". Actual: ' + __instance.substring(false, true)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T10.js new file mode 100644 index 0000000000..0f25e1444a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T10.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.substring (start, end) +es5id: 15.5.4.15_A1_T10 +description: > + Arguments are object and function call, and instance is String, + object have overrided valueOf function +---*/ + +var __obj = { + valueOf: function() { + return 2; + } +}; + +var __str = "\u0035ABBBABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.substring(__obj, function() { + return __str.substring(0, 1); + }()) !== "BBB") { + throw new Test262Error('#1: var __obj = {valueOf:function(){return 2;}}; var __str = "\u0035ABBBABAB"; __str.substring(__obj, function(){return __str.substring(0,1);}()) === "BBB". Actual: ' + __str.substring(__obj, function() { + return __str.substring(0, 1); + }())); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T11.js new file mode 100644 index 0000000000..8a26c02d22 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T11.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: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T11 +description: > + Arguments are objects, and instance is string, objects have + overrided valueOf function, that return exception +---*/ + +var __obj = { + valueOf: function() { + throw "instart"; + } +}; +var __obj2 = { + valueOf: function() { + throw "inend"; + } +}; +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.substring(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.substring(__obj,__obj2)" lead to throw exception'); +} catch (e) { + if (e !== "instart") { + throw new Test262Error('#1.1: Exception === "instart". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T12.js new file mode 100644 index 0000000000..f201db16aa --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T12.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.substring (start, end) +es5id: 15.5.4.15_A1_T12 +description: > + Arguments are objects, and instance is string. First object have + overrided valueOf function and toString function, that return + exception. Second object have overrided valueOf function, that + return exception +---*/ + +var __obj = { + valueOf: function() { + return {}; + }, + toString: function() { + throw "instart"; + } +}; +var __obj2 = { + valueOf: function() { + throw "inend"; + } +}; +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.substring(__obj, __obj2); + throw new Test262Error('#1: "var x = __str.substring(__obj,__obj2)" lead to throw exception'); +} catch (e) { + if (e !== "instart") { + throw new Test262Error('#1.1: Exception ==="instart". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T13.js new file mode 100644 index 0000000000..2f4c8c017b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T13.js @@ -0,0 +1,40 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T13 +description: > + Arguments are objects, and instance is string. First object have + overrided valueOf and toString functions. Second object have + overrided toString function, that return exception +---*/ + +var __obj = { + valueOf: function() { + return {}; + }, + toString: function() { + return 1; + } +}; +var __obj2 = { + toString: function() { + throw "inend"; + } +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = "ABB\u0041BABAB\u0031BBAA".substring(__obj, __obj2); + throw new Test262Error('#1: var x = "ABB\\u0041BABAB\\u0031BBAA".substring(__obj,__obj2) lead to throw exception'); +} catch (e) { + if (e !== "inend") { + throw new Test262Error('#1.1: Exception === "inend". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T14.js new file mode 100644 index 0000000000..1df3613662 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T14.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T14 +description: Used one argument, that is function(){}(). Instance is string +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("report".substring(function() {}()) !== "report") { + throw new Test262Error('#1: "report".substring(function(){}()) === "report". Actual: ' + "report".substring(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T15.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T15.js new file mode 100644 index 0000000000..9055b4be17 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T15.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T15 +description: > + Call substring without arguments. Instance is Number with + prototype.substring = String.prototype.substring +---*/ + +var __num = 11.001002; + +Number.prototype.substring = String.prototype.substring; + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__num.substring() !== "11.001002") { + throw new Test262Error('#1: var __num = 11.001002; Number.prototype.substring = String.prototype.substring; __num.substring()==="11.001002". Actual: ' + __num.substring()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T2.js new file mode 100644 index 0000000000..8d9aaba34b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T2.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.substring (start, end) +es5id: 15.5.4.15_A1_T2 +description: > + Arguments are function call and x, and instance is Boolean. x is + undefined variable +---*/ + +var __instance = new Boolean; + +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(function() { + return true; + }(), x) !== "alse") { + throw new Test262Error('#1: var x; __instance = new Boolean; __instance.substring = String.prototype.substring; __instance.substring(function(){return true;}(),x) === "alse". Actual: ' + __instance.substring(function() { + return true; + }(), x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T4.js new file mode 100644 index 0000000000..fbc683ea59 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T4.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T4 +description: > + Arguments are null and number, and instance is function call, that + returned string +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (function() { + return "gnulluna" + }().substring(null, -3) !== "") { + throw new Test262Error('#1: function(){return "gnulluna"}().substring(null, -3) === "". Actual: ' + function() { + return "gnulluna" + }().substring(null, -3)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T5.js new file mode 100644 index 0000000000..38486f9119 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T5.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.substring (start, end) +es5id: 15.5.4.15_A1_T5 +description: > + Arguments are null and Function(), and instance is function + object, that have overrided valueOf function +---*/ + +__func.valueOf = function() { + return "gnulluna" +}; + +Function.prototype.substring = String.prototype.substring; + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__func.substring(null, Function()) !== "") { + throw new Test262Error('#1: __func.valueOf=function(){return "gnulluna"}; Function.prototype.substring=String.prototype.substring; function __func(){}; __func.substring(null, Function()) === "". Actual: ' + __func.substring(null, Function())); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __func() {}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T6.js new file mode 100644 index 0000000000..b776857af7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T6.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T6 +description: > + Arguments are x and number, and instance is new String, x is + undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (new String("undefined").substring(x, 3) !== "und") { + throw new Test262Error('#1: var x; new String("undefined").substring(x,3) === "und". Actual: ' + new String("undefined").substring(x, 3)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T7.js new file mode 100644 index 0000000000..f65314fcf0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T7.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T7 +description: Arguments are symbol and undefined, and instance is String +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String(void 0).substring("e", undefined) !== "undefined") { + throw new Test262Error('#1: String(void 0).substring("e",undefined) === "undefined". Actual: ' + String(void 0).substring("e", undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T8.js new file mode 100644 index 0000000000..9e7462fb26 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T8.js @@ -0,0 +1,24 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) +es5id: 15.5.4.15_A1_T8 +description: > + Arguments are negative number and void 0, and instance is + String(object), object have overrided toString function +---*/ + +var __obj = { + toString: function() {} +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String(__obj).substring(-4, void 0) !== "undefined") { + throw new Test262Error('#1: __obj = {toString:function(){}}; String(__obj).substring(-4,void 0) === "undefined". Actual: ' + String(__obj).substring(-4, void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T9.js new file mode 100644 index 0000000000..a95c31d8cd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A1_T9.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.substring (start, end) +es5id: 15.5.4.15_A1_T9 +description: > + Arguments are undefined and object, and instance is new + String(object), object have overrided valueOf and toString + functions +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (new String(__obj).substring( /*(function(){})()*/ undefined, undefined) !== "undefined") { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; new String(__obj).substring(/*(function(){})()*/undefined,undefined) === "undefined". Actual: ' + new String(__obj).substring( /*(function(){})()*/ undefined, undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T1.js new file mode 100644 index 0000000000..f8d5f6ca18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T1.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T1 +description: Checking type of substring() +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (typeof __string.substring() !== "string") { + throw new Test262Error('#1: __string = new String("this is a string object"); typeof __string.substring() === "string". Actual: ' + typeof __string.substring()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T10.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T10.js new file mode 100644 index 0000000000..7bd4973cda --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T10.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T10 +description: start is 0, end is 8 +---*/ + +var __string = new String("this_is_a_string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(0, 8) !== "this_is_") { + throw new Test262Error('#1: __string = new String("this_is_a_string object"); __string.substring(0,8) === "this_is_". Actual: ' + __string.substring(0, 8)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T2.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T2.js new file mode 100644 index 0000000000..58866341a9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T2.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T2 +description: start is NaN, end is Infinity +---*/ + +var __string = new String('this is a string object'); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(NaN, Infinity) !== "this is a string object") { + throw new Test262Error('#1: __string = new String(\'this is a string object\'); __string.substring(NaN, Infinity) === "this is a string object". Actual: ' + __string.substring(NaN, Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T3.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T3.js new file mode 100644 index 0000000000..ba88236409 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T3.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T3 +description: Call substring from empty String object +---*/ + +var __string = new String(""); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(1, 0) !== "") { + throw new Test262Error('#1: __string = new String(""); __string.substring(1,0) === "". Actual: ' + __string.substring(1, 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T4.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T4.js new file mode 100644 index 0000000000..02f8ffe3da --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T4.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T4 +description: start is Infinity, end is NaN +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(Infinity, NaN) !== "this is a string object") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.substring(Infinity, NaN) === "this is a string object". Actual: ' + __string.substring(Infinity, NaN)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T5.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T5.js new file mode 100644 index 0000000000..49d234a938 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T5.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T5 +description: start is Infinity, end is Infinity +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(Infinity, Infinity) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.substring(Infinity, Infinity) === "". Actual: ' + __string.substring(Infinity, Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T6.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T6.js new file mode 100644 index 0000000000..2c685d97bc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T6 +description: start is negative float number, end is 0 +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(-0.01, 0) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.substring(-0.01,0) === "". Actual: ' + __string.substring(-0.01, 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T7.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T7.js new file mode 100644 index 0000000000..cb82b6b5bd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T7 +description: start is tested_string.length, end is tested_string.length +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(__string.length, __string.length) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.substring(__string.length, __string.length) === "". Actual: ' + __string.substring(__string.length, __string.length)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T8.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T8.js new file mode 100644 index 0000000000..9764869573 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T8.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T8 +description: start is tested_string.length+1, end is 0 +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(__string.length + 1, 0) !== "this is a string object") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.substring(__string.length+1, 0) === "this is a string object". Actual: ' + __string.substring(__string.length + 1, 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T9.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T9.js new file mode 100644 index 0000000000..a485ba798b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A2_T9.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring (start, end) returns a string value(not object) +es5id: 15.5.4.15_A2_T9 +description: start is -Infinity, end is -Infinity +---*/ + +var __string = new String("this is a string object"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__string.substring(-Infinity, -Infinity) !== "") { + throw new Test262Error('#1: __string = new String("this is a string object"); __string.substring(-Infinity, -Infinity) === "". Actual: ' + __string.substring(-Infinity, -Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T1.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T1.js new file mode 100644 index 0000000000..386e80c7ae --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T1.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T1 +description: > + Apply String.prototype.substring to Array instance. Start is + Infinity, end is -Infinity +---*/ + +var __instance = new Array(1, 2, 3, 4, 5); +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(Infinity, -Infinity) !== "1,2,3,4,5") { + throw new Test262Error('#1: __instance = new Array(1,2,3,4,5); __instance.substring = String.prototype.substring; __instance.substring(Infinity,-Infinity) === "1,2,3,4,5". Actual: ' + __instance.substring(Infinity, -Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T10.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T10.js new file mode 100644 index 0000000000..6e2f22bd65 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T10.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.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T10 +description: > + Checknig if applying String.prototype.substring to Function object + instance passes +---*/ + +__FACTORY.prototype.substring = String.prototype.substring; + +var __instance = new __FACTORY(void 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(0, 100) !== "undefined") { + throw new Test262Error('#1: __instance.substring(0, 100) === "undefined". Actual: ' + __instance.substring(0, 100)); +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(value) { + this.value = value; + this.toString = function() { + return this.value + ''; + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T11.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T11.js new file mode 100644 index 0000000000..75a5470692 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T11.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.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T11 +description: > + Apply String.prototype.substring to Boolean instance. Start is new + Array(), end is new Boolean(1) +---*/ + +var __instance = new Boolean(); + +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(new Array(), new Boolean(1)) !== "f") { + throw new Test262Error('#1: __instance = new Boolean(); __instance.substring = String.prototype.substring; __instance.substring(new Array(), new Boolean(1)) === "f". Actual: ' + __instance.substring(new Array(), new Boolean(1))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T2.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T2.js new file mode 100644 index 0000000000..06dca8eb98 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T2.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T2 +description: > + Apply String.prototype.substring to Array instance. Start is 9, + end is -Infinity +---*/ + +var __instance = new Array(1, 2, 3, 4, 5); +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(9, -Infinity) !== "1,2,3,4,5") { + throw new Test262Error('#1: __instance = new Array(1,2,3,4,5); __instance.substring = String.prototype.substring; __instance.substring(9,-Infinity) === "1,2,3,4,5". Actual: ' + __instance.substring(9, -Infinity)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T3.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T3.js new file mode 100644 index 0000000000..02eefd05f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T3.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T3 +description: > + Apply String.prototype.substring to Array instance. Start is true, + end is false +---*/ + +var __instance = new Array(1, 2, 3, 4, 5); +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(true, false) !== "1") { + throw new Test262Error('#1: __instance = new Array(1,2,3,4,5); __instance.substring = String.prototype.substring; __instance.substring(true, false) === "1". Actual: ' + __instance.substring(true, false)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T4.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T4.js new file mode 100644 index 0000000000..8e0e93c8a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T4.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T4 +description: > + Apply String.prototype.substring to Array instance. Start is '4', + end is '5' +---*/ + +var __instance = new Array(1, 2, 3, 4, 5); +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring('4', '5') !== "3") { + throw new Test262Error('#1: __instance = new Array(1,2,3,4,5); __instance.substring = String.prototype.substring; __instance.substring(\'4\', \'5\') === "3". Actual: ' + __instance.substring('4', '5')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T5.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T5.js new file mode 100644 index 0000000000..2f84981f98 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T5.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T5 +description: > + Apply String.prototype.substring to Object instance. Start is 8, + end is 0 +---*/ + +var __instance = new Object(); +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(8, 0) !== "[object ") { + throw new Test262Error('#1: __instance = new Object(); __instance.substring = String.prototype.substring; __instance.substring(8,0) === "[object ". Actual: ' + __instance.substring(8, 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T6.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T6.js new file mode 100644 index 0000000000..8da063c0d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T6.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + String.prototype.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T6 +description: > + Apply String.prototype.substring to Object instance. Start is 8, + end is length of object.toString +---*/ + +var __instance = new Object(); +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(8, __instance.toString().length) !== "Object]") { + throw new Test262Error('#1: __instance = new Object(); __instance.substring = String.prototype.substring; __instance.substring(8, __instance.toString().length) === "Object]". Actual: ' + __instance.substring(8, __instance.toString().length)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T7.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T7.js new file mode 100644 index 0000000000..bb2d01fb15 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T7.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.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T7 +description: > + Apply String.prototype.substring to Object instance. Call + instance.substring(...).substring(...) +---*/ + +var __instance = { + toString: function() { + return "function(){}"; + } +}; + +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(-Infinity, 8) !== "function") { + throw new Test262Error('#1: __instance = function(){}; __instance.substring = String.prototype.substring; __instance.substring(-Infinity,8) === "function". Actual: ' + __instance.substring(8, Infinity).substring(-Infinity, 1)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T8.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T8.js new file mode 100644 index 0000000000..cda929c34d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T8.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.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T8 +description: > + Apply String.prototype.substring to Number instance. Start is + Infinity, end is NaN +---*/ + +var __instance = new Number(NaN); + +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(Infinity, NaN) !== "NaN") { + throw new Test262Error('#1: __instance = new Number(NaN); __instance.substring = String.prototype.substring; __instance.substring(Infinity, NaN) === "NaN". Actual: ' + __instance.substring(Infinity, NaN)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T9.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T9.js new file mode 100644 index 0000000000..885958b1db --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A3_T9.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.substring (start, end) can be applied to non String object instance and + returns a string value(not object) +es5id: 15.5.4.15_A3_T9 +description: > + Apply String.prototype.substring to Math instance. Start is + Math.PI, end is -10 +---*/ + +var __instance = Math; + +__instance.substring = String.prototype.substring; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.substring(Math.PI, -10) !== "[ob") { + throw new Test262Error('#1: __instance = Math; __instance.substring = String.prototype.substring; __instance.substring(Math.PI, -10) === "[ob". Actual: ' + __instance.substring(Math.PI, -10)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A6.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A6.js new file mode 100644 index 0000000000..41d75122b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.substring has not prototype property +es5id: 15.5.4.15_A6 +description: Checking String.prototype.substring.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.substring.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.substring.prototype === undefined. Actual: ' + String.prototype.substring.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A7.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A7.js new file mode 100644 index 0000000000..1f850f3a0a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A7.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.substring can't be used as constructor +es5id: 15.5.4.15_A7 +description: Checking if creating the String.prototype.substring object fails +---*/ + +var __FACTORY = String.prototype.substring; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.substring; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.2: undefined = 1 throw a TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A8.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A8.js new file mode 100644 index 0000000000..af1656d8ed --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A8.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: The String.prototype.substring.length property has the attribute DontEnum +es5id: 15.5.4.15_A8 +description: > + Checking if enumerating the String.prototype.substring.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.substring.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.substring.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.substring.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.substring.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.substring.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.substring) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.substring){if (p==="length") count++;} count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A9.js b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A9.js new file mode 100644 index 0000000000..4e5a3df24b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/S15.5.4.15_A9.js @@ -0,0 +1,38 @@ +// 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.substring.length property does not have the + attribute DontDelete +es5id: 15.5.4.15_A9 +description: > + Checking if deleting the String.prototype.substring.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.substring.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.substring.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.substring.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.substring.length) { + throw new Test262Error('#1: delete String.prototype.substring.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.substring.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.substring.length; String.prototype.substring.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.substring.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/browser.js b/js/src/tests/test262/built-ins/String/prototype/substring/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/name.js b/js/src/tests/test262/built-ins/String/prototype/substring/name.js new file mode 100644 index 0000000000..bbfb54a254 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/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.19 +description: > + String.prototype.substring.name is "substring". +info: | + String.prototype.substring ( start, end ) + + 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.substring.name, "substring"); + +verifyNotEnumerable(String.prototype.substring, "name"); +verifyNotWritable(String.prototype.substring, "name"); +verifyConfigurable(String.prototype.substring, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/substring/not-a-constructor.js new file mode 100644 index 0000000000..981b8cd665 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/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.substring 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.substring), + false, + 'isConstructor(String.prototype.substring) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.substring(); +}, '`new String.prototype.substring()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/shell.js b/js/src/tests/test262/built-ins/String/prototype/substring/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/substring/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/substring/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..8f59e5810f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/substring/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.substring +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var substring = String.prototype.substring; + +assert.sameValue(typeof substring, 'function'); + +assert.throws(TypeError, function() { + substring.call(undefined, 0, 1); +}, 'undefined'); + +assert.throws(TypeError, function() { + substring.call(null, 0, 1); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/Final_Sigma_U180E.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/Final_Sigma_U180E.js new file mode 100644 index 0000000000..a4a033efb7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/Final_Sigma_U180E.js @@ -0,0 +1,62 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tolocalelowercase +description: > + Check if String.prototype.toLocaleLowerCase supports conditional mappings defined in SpecialCasings, + test Final_Sigma context with Mongolian Vowel Separator +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +features: [u180e] +---*/ + +// SpecialCasing.txt, conditional, language-insensitive mappings. + +// <code>; <lower>; <title>; <upper>; (<condition_list>;)? # <comment> +// 03A3; 03C2; 03A3; 03A3; Final_Sigma; # GREEK CAPITAL LETTER SIGMA +// 03A3; 03C3; 03A3; 03A3; # GREEK CAPITAL LETTER SIGMA + +// Final_Sigma is defined in Unicode 8.0, 3.13 Default Case Algorithms +// General_Category of Mongolian Vowel Separator is Cf (Format), characters in Cf are Case_Ignorable. + + +// Sigma preceded by Mongolian Vowel Separator. +assert.sameValue( + "A\u180E\u03A3".toLocaleLowerCase(), + "a\u180E\u03C2", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR" +); +assert.sameValue( + "A\u180E\u03A3B".toLocaleLowerCase(), + "a\u180E\u03C3b", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR, followed by LATIN CAPITAL LETTER B" +); + +// Sigma followed by Mongolian Vowel Separator. +assert.sameValue( + "A\u03A3\u180E".toLocaleLowerCase(), + "a\u03C2\u180E", + "Sigma preceded by LATIN CAPITAL LETTER A, followed by MONGOLIAN VOWEL SEPARATOR" +); +assert.sameValue( + "A\u03A3\u180EB".toLocaleLowerCase(), + "a\u03C3\u180Eb", + "Sigma preceded by LATIN CAPITAL LETTER A, followed by MONGOLIAN VOWEL SEPARATOR, LATIN CAPITAL LETTER B" +); + +// Sigma preceded and followed by Mongolian Vowel Separator. +assert.sameValue( + "A\u180E\u03A3\u180E".toLocaleLowerCase(), + "a\u180E\u03C2\u180E", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR" +); +assert.sameValue( + "A\u180E\u03A3\u180EB".toLocaleLowerCase(), + "a\u180E\u03C3\u180Eb", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR, LATIN CAPITAL LETTER B" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A10.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A10.js new file mode 100644 index 0000000000..2ded16975e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A10.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.toLocaleLowerCase.length property has the attribute + ReadOnly +es5id: 15.5.4.17_A10 +description: > + Checking if varying the String.prototype.toLocaleLowerCase.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toLocaleLowerCase.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.toLocaleLowerCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLocaleLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.toLocaleLowerCase.length; + +verifyNotWritable(String.prototype.toLocaleLowerCase, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLocaleLowerCase.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.toLocaleLowerCase.length; String.prototype.toLocaleLowerCase.length = function(){return "shifted";}; String.prototype.toLocaleLowerCase.length === __obj. Actual: ' + String.prototype.toLocaleLowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A11.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A11.js new file mode 100644 index 0000000000..debab23e39 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A11.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 length property of the toLocaleLowerCase method is 0 +es5id: 15.5.4.17_A11 +description: Checking String.prototype.toLocaleLowerCase.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toLocaleLowerCase.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.toLocaleLowerCase.hasOwnProperty("length") return true. Actual: ' + String.prototype.toLocaleLowerCase.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLocaleLowerCase.length !== 0) { + throw new Test262Error('#2: String.prototype.toLocaleLowerCase.length === 0. Actual: ' + String.prototype.toLocaleLowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T1.js new file mode 100644 index 0000000000..a1c589a0a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T1 +description: Arguments is true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toLocaleLowerCase() !== "true") { + throw new Test262Error('#1: __instance = new Object(true); __instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __instance.toLocaleLowerCase() === "true". Actual: ' + __instance.toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T10.js new file mode 100644 index 0000000000..bcf3194fdf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T10.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.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T10 +description: > + Call toLocaleLowerCase() function of object with overrode toString + function +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toLocaleLowerCase() !== "ab") { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041B";}}; __obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __obj.toLocaleLowerCase() ==="ab". Actual: ' + __obj.toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T11.js new file mode 100644 index 0000000000..a5e13954aa --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T11.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.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T11 +description: > + Override toString function, toString throw exception, then call + toLocaleLowerCase() function for this object +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +} +__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toLocaleLowerCase(); + throw new Test262Error('#1: "var x = __obj.toLocaleLowerCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T12.js new file mode 100644 index 0000000000..05b7bebbfd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T12.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.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T12 +description: > + Override toString and valueOf functions, valueOf throw exception, + then call toLocaleLowerCase() function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +} +__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toLocaleLowerCase(); + throw new Test262Error('#1: "var x = __obj.toLocaleLowerCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T13.js new file mode 100644 index 0000000000..83236032ed --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T13.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T13 +description: > + Override toString and valueOf functions, then call + toLocaleLowerCase() function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +} +__obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toLocaleLowerCase() !== "1") { + throw new Test262Error('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __obj.toLocaleLowerCase() ==="1". Actual: ' + __obj.toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.toLocaleLowerCase().length !== 1) { + throw new Test262Error('#2: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __obj.toLocaleLowerCase().length === 1. Actual: ' + __obj.toLocaleLowerCase().length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T14.js new file mode 100644 index 0000000000..99fdc2b935 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T14.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.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T14 +description: Call toLocaleLowerCase() function for RegExp object +---*/ + +var __reg = new RegExp("ABC"); +__reg.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__reg.toLocaleLowerCase() !== "/abc/") { + throw new Test262Error('#1: var __reg = new RegExp("ABC"); __reg.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __reg.toLocaleLowerCase() === "/abc/". Actual: ' + __reg.toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T2.js new file mode 100644 index 0000000000..4d1fa0e042 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T2 +description: Instance is Boolean object +---*/ + +var __instance = new Boolean; + +__instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toLocaleLowerCase() !== "false") { + throw new Test262Error('#1: __instance = new Boolean; __instance.toLocaleLowerCase = String.prototype.toLocaleLowerCase; __instance.toLocaleLowerCase() === "false". Actual: ' + __instance.toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T3.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T3.js new file mode 100644 index 0000000000..9798385f74 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T3.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T3 +description: Checking by using eval +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (eval("\"BJ\"").toLocaleLowerCase() !== "bj") { + throw new Test262Error('#1: eval("\\"BJ\\"").toLocaleLowerCase() === "bj". Actual: ' + eval("\"BJ\"").toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T4.js new file mode 100644 index 0000000000..5dccd7105f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T4.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.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T4 +description: > + Call toLocaleLowerCase() function without arguments of string and + from empty string +---*/ + +var __lowerCase = "".toLocaleLowerCase(); + +var __expected = ""; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__lowerCase.length !== __expected.length) { + throw new Test262Error('#1: __lowerCase = "".toLocaleLowerCase(); __expected = ""; __lowerCase.length === __expected.length. Actual: ' + __lowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__lowerCase.index !== __expected.index) { + throw new Test262Error('#2: __lowerCase = "".toLocaleLowerCase(); __expected = ""; __lowerCase.index === __expected.index. Actual: ' + __lowerCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__lowerCase.input !== __expected.input) { + throw new Test262Error('#3: __lowerCase = "".toLocaleLowerCase(); __expected = ""; __lowerCase.input === __expected.input. Actual: ' + __lowerCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__lowerCase[0] !== __expected[0]) { + throw new Test262Error('#4: __lowerCase = "".toLocaleLowerCase(); __expected = ""; __lowerCase[0]===__expected[0]. Actual: ' + __lowerCase[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T5.js new file mode 100644 index 0000000000..34618bd677 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T5 +description: Call toLocaleLowerCase() function for function call +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" match(null) evaluates to match("null") +if (function() { + return "GnulLuNa" + }().toLocaleLowerCase() !== "gnulluna") { + throw new Test262Error('#1: function(){return "GnulLuNa"}().toLocaleLowerCase() === "gnulluna". Actual: ' + function() { + return "GnulLuNa" + }().toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T6.js new file mode 100644 index 0000000000..0268b030e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T6 +description: Call toLocaleLowerCase() function of Number.NEGATIVE_INFINITY +---*/ + +Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((Number.NEGATIVE_INFINITY).toLocaleLowerCase() !== "-infinity") { + throw new Test262Error('#1: Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; (Number.NEGATIVE_INFINITY).toLocaleLowerCase() === "-infinity". Actual: ' + (Number.NEGATIVE_INFINITY).toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T7.js new file mode 100644 index 0000000000..285ee723ec --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T7 +description: Call toLocaleLowerCase() function of NaN +---*/ + +Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (NaN.toLocaleLowerCase() !== "nan") { + throw new Test262Error('#1: Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; NaN.toLocaleLowerCase()=== "nan". Actual: ' + NaN.toLocaleLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T8.js new file mode 100644 index 0000000000..1967c6547d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T8.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.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T8 +description: Call toLocaleLowerCase() function of Infinity +---*/ + +Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +if (Infinity.toLocaleLowerCase() !== "infinity") { + throw new Test262Error('#1: Number.prototype.toLocaleLowerCase = String.prototype.toLocaleLowerCase; Infinity.toLocaleLowerCase()=== "infinity". Actual: ' + Infinity.toLocaleLowerCase()); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T9.js new file mode 100644 index 0000000000..9defa73f86 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A1_T9.js @@ -0,0 +1,54 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase() +es5id: 15.5.4.17_A1_T9 +description: Call toLocaleLowerCase() function of string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +var __lowerCase = new String(__obj).toLocaleLowerCase(); + + +var __expected = "undefined"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__lowerCase.length !== __expected.length) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected ="undefined"; __lowerCase.length === __expected.length. Actual: ' + __lowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__lowerCase.index !== __expected.index) { + throw new Test262Error('#2: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected ="undefined"; __lowerCase.index === __expected.index. Actual: ' + __lowerCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__lowerCase.input !== __expected.input) { + throw new Test262Error('#3: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected ="undefined"; __lowerCase.input === __expected.input. Actual: ' + __lowerCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__lowerCase[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleLowerCase(); __expected ="undefined"; __lowerCase[' + index + ']=== ' + __expected[index] + '. Actual: ' + __lowerCase[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A2_T1.js new file mode 100644 index 0000000000..7dfdb60f3e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A2_T1.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.toLocaleLowerCase() return a string, but not a String + object +es5id: 15.5.4.17_A2_T1 +description: Checking returned result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("Hello, WoRlD!".toLocaleLowerCase() !== "hello, world!") { + throw new Test262Error('#1: "Hello, WoRlD!".toLocaleLowerCase() === "hello, world!". Actual: ' + ("Hello, WoRlD!".toLocaleLowerCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if ("Hello, WoRlD!".toLocaleLowerCase() !== String("hello, world!")) { + throw new Test262Error('#2: "Hello, WoRlD!".toLocaleLowerCase() === String("hello, world!"). Actual: ' + ("Hello, WoRlD!".toLocaleLowerCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if ("Hello, WoRlD!".toLocaleLowerCase() === new String("hello, world!")) { + throw new Test262Error('#3: "Hello, WoRlD!".toLocaleLowerCase() !== new String("hello, world!")'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A6.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A6.js new file mode 100644 index 0000000000..dadbf9893d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase has not prototype property +es5id: 15.5.4.17_A6 +description: Checking String.prototype.toLocaleLowerCase.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.toLocaleLowerCase.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.toLocaleLowerCase.prototype === undefined. Actual: ' + String.prototype.toLocaleLowerCase.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A7.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A7.js new file mode 100644 index 0000000000..48e315755d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A7.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleLowerCase can't be used as constructor +es5id: 15.5.4.17_A7 +description: > + Checking if creating the String.prototype.toLocaleLowerCase object + fails +---*/ + +var __FACTORY = String.prototype.toLocaleLowerCase; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: var __FACTORY = String.prototype.toLocaleLowerCase; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.1: var __FACTORY = String.prototype.toLocaleLowerCase; "var __instance = new __FACTORY" throw a TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A8.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A8.js new file mode 100644 index 0000000000..fc35b73e84 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A8.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: | + The String.prototype.toLocaleLowerCase.length property has the attribute + DontEnum +es5id: 15.5.4.17_A8 +description: > + Checking if enumerating the + String.prototype.toLocaleLowerCase.length property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toLocaleLowerCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toLocaleLowerCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLocaleLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.toLocaleLowerCase.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.toLocaleLowerCase.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.toLocaleLowerCase) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.toLocaleLowerCase){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A9.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A9.js new file mode 100644 index 0000000000..3e03922bc8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/S15.5.4.17_A9.js @@ -0,0 +1,38 @@ +// 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.toLocaleLowerCase.length property does not have the + attribute DontDelete +es5id: 15.5.4.17_A9 +description: > + Checking if deleting the String.prototype.toLocaleLowerCase.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toLocaleLowerCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toLocaleLowerCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLocaleLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.toLocaleLowerCase.length) { + throw new Test262Error('#1: delete String.prototype.toLocaleLowerCase.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLocaleLowerCase.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.toLocaleLowerCase.length; String.prototype.toLocaleLowerCase.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.toLocaleLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/browser.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/name.js new file mode 100644 index 0000000000..0293ba687b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/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.20 +description: > + String.prototype.toLocaleLowerCase.name is "toLocaleLowerCase". +info: | + String.prototype.toLocaleLowerCase ( [ reserved1 [ , reserved2 ] ] ) + + 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.toLocaleLowerCase.name, "toLocaleLowerCase"); + +verifyNotEnumerable(String.prototype.toLocaleLowerCase, "name"); +verifyNotWritable(String.prototype.toLocaleLowerCase, "name"); +verifyConfigurable(String.prototype.toLocaleLowerCase, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/not-a-constructor.js new file mode 100644 index 0000000000..c6b26ea910 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/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.toLocaleLowerCase 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.toLocaleLowerCase), + false, + 'isConstructor(String.prototype.toLocaleLowerCase) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.toLocaleLowerCase(); +}, '`new String.prototype.toLocaleLowerCase()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/shell.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/special_casing.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/special_casing.js new file mode 100644 index 0000000000..43cfaa1a9e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/special_casing.js @@ -0,0 +1,138 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Check if String.prototype.toLocaleLowerCase supports mappings defined in SpecialCasings +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +es5id: 15.5.4.17 +es6id: 21.1.3.20 +---*/ + +// SpecialCasing.txt, except for conditional mappings. + +assert.sameValue("\u00DF".toLocaleLowerCase(), "\u00DF", "LATIN SMALL LETTER SHARP S"); + +// Locale-sensitive for Turkish and Azeri. +// assert.sameValue("\u0130".toLocaleLowerCase(), "\u0069\u0307", "LATIN CAPITAL LETTER I WITH DOT ABOVE"); + +assert.sameValue("\uFB00".toLocaleLowerCase(), "\uFB00", "LATIN SMALL LIGATURE FF"); +assert.sameValue("\uFB01".toLocaleLowerCase(), "\uFB01", "LATIN SMALL LIGATURE FI"); +assert.sameValue("\uFB02".toLocaleLowerCase(), "\uFB02", "LATIN SMALL LIGATURE FL"); +assert.sameValue("\uFB03".toLocaleLowerCase(), "\uFB03", "LATIN SMALL LIGATURE FFI"); +assert.sameValue("\uFB04".toLocaleLowerCase(), "\uFB04", "LATIN SMALL LIGATURE FFL"); +assert.sameValue("\uFB05".toLocaleLowerCase(), "\uFB05", "LATIN SMALL LIGATURE LONG S T"); +assert.sameValue("\uFB06".toLocaleLowerCase(), "\uFB06", "LATIN SMALL LIGATURE ST"); + +assert.sameValue("\u0587".toLocaleLowerCase(), "\u0587", "ARMENIAN SMALL LIGATURE ECH YIWN"); +assert.sameValue("\uFB13".toLocaleLowerCase(), "\uFB13", "ARMENIAN SMALL LIGATURE MEN NOW"); +assert.sameValue("\uFB14".toLocaleLowerCase(), "\uFB14", "ARMENIAN SMALL LIGATURE MEN ECH"); +assert.sameValue("\uFB15".toLocaleLowerCase(), "\uFB15", "ARMENIAN SMALL LIGATURE MEN INI"); +assert.sameValue("\uFB16".toLocaleLowerCase(), "\uFB16", "ARMENIAN SMALL LIGATURE VEW NOW"); +assert.sameValue("\uFB17".toLocaleLowerCase(), "\uFB17", "ARMENIAN SMALL LIGATURE MEN XEH"); + +assert.sameValue("\u0149".toLocaleLowerCase(), "\u0149", "LATIN SMALL LETTER N PRECEDED BY APOSTROPHE"); + +assert.sameValue("\u0390".toLocaleLowerCase(), "\u0390", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS"); +assert.sameValue("\u03B0".toLocaleLowerCase(), "\u03B0", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS"); + +assert.sameValue("\u01F0".toLocaleLowerCase(), "\u01F0", "LATIN SMALL LETTER J WITH CARON"); +assert.sameValue("\u1E96".toLocaleLowerCase(), "\u1E96", "LATIN SMALL LETTER H WITH LINE BELOW"); +assert.sameValue("\u1E97".toLocaleLowerCase(), "\u1E97", "LATIN SMALL LETTER T WITH DIAERESIS"); +assert.sameValue("\u1E98".toLocaleLowerCase(), "\u1E98", "LATIN SMALL LETTER W WITH RING ABOVE"); +assert.sameValue("\u1E99".toLocaleLowerCase(), "\u1E99", "LATIN SMALL LETTER Y WITH RING ABOVE"); +assert.sameValue("\u1E9A".toLocaleLowerCase(), "\u1E9A", "LATIN SMALL LETTER A WITH RIGHT HALF RING"); + +assert.sameValue("\u1F50".toLocaleLowerCase(), "\u1F50", "GREEK SMALL LETTER UPSILON WITH PSILI"); +assert.sameValue("\u1F52".toLocaleLowerCase(), "\u1F52", "GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA"); +assert.sameValue("\u1F54".toLocaleLowerCase(), "\u1F54", "GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA"); +assert.sameValue("\u1F56".toLocaleLowerCase(), "\u1F56", "GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI"); +assert.sameValue("\u1FB6".toLocaleLowerCase(), "\u1FB6", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI"); +assert.sameValue("\u1FC6".toLocaleLowerCase(), "\u1FC6", "GREEK SMALL LETTER ETA WITH PERISPOMENI"); +assert.sameValue("\u1FD2".toLocaleLowerCase(), "\u1FD2", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FD3".toLocaleLowerCase(), "\u1FD3", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FD6".toLocaleLowerCase(), "\u1FD6", "GREEK SMALL LETTER IOTA WITH PERISPOMENI"); +assert.sameValue("\u1FD7".toLocaleLowerCase(), "\u1FD7", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FE2".toLocaleLowerCase(), "\u1FE2", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FE3".toLocaleLowerCase(), "\u1FE3", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FE4".toLocaleLowerCase(), "\u1FE4", "GREEK SMALL LETTER RHO WITH PSILI"); +assert.sameValue("\u1FE6".toLocaleLowerCase(), "\u1FE6", "GREEK SMALL LETTER UPSILON WITH PERISPOMENI"); +assert.sameValue("\u1FE7".toLocaleLowerCase(), "\u1FE7", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FF6".toLocaleLowerCase(), "\u1FF6", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI"); + +assert.sameValue("\u1F80".toLocaleLowerCase(), "\u1F80", "GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F81".toLocaleLowerCase(), "\u1F81", "GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F82".toLocaleLowerCase(), "\u1F82", "GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F83".toLocaleLowerCase(), "\u1F83", "GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F84".toLocaleLowerCase(), "\u1F84", "GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F85".toLocaleLowerCase(), "\u1F85", "GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F86".toLocaleLowerCase(), "\u1F86", "GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F87".toLocaleLowerCase(), "\u1F87", "GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F88".toLocaleLowerCase(), "\u1F80", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F89".toLocaleLowerCase(), "\u1F81", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8A".toLocaleLowerCase(), "\u1F82", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8B".toLocaleLowerCase(), "\u1F83", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8C".toLocaleLowerCase(), "\u1F84", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8D".toLocaleLowerCase(), "\u1F85", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8E".toLocaleLowerCase(), "\u1F86", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8F".toLocaleLowerCase(), "\u1F87", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1F90".toLocaleLowerCase(), "\u1F90", "GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F91".toLocaleLowerCase(), "\u1F91", "GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F92".toLocaleLowerCase(), "\u1F92", "GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F93".toLocaleLowerCase(), "\u1F93", "GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F94".toLocaleLowerCase(), "\u1F94", "GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F95".toLocaleLowerCase(), "\u1F95", "GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F96".toLocaleLowerCase(), "\u1F96", "GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F97".toLocaleLowerCase(), "\u1F97", "GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F98".toLocaleLowerCase(), "\u1F90", "GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F99".toLocaleLowerCase(), "\u1F91", "GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9A".toLocaleLowerCase(), "\u1F92", "GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9B".toLocaleLowerCase(), "\u1F93", "GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9C".toLocaleLowerCase(), "\u1F94", "GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9D".toLocaleLowerCase(), "\u1F95", "GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9E".toLocaleLowerCase(), "\u1F96", "GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9F".toLocaleLowerCase(), "\u1F97", "GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FA0".toLocaleLowerCase(), "\u1FA0", "GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA1".toLocaleLowerCase(), "\u1FA1", "GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA2".toLocaleLowerCase(), "\u1FA2", "GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA3".toLocaleLowerCase(), "\u1FA3", "GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA4".toLocaleLowerCase(), "\u1FA4", "GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA5".toLocaleLowerCase(), "\u1FA5", "GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA6".toLocaleLowerCase(), "\u1FA6", "GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA7".toLocaleLowerCase(), "\u1FA7", "GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FA8".toLocaleLowerCase(), "\u1FA0", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FA9".toLocaleLowerCase(), "\u1FA1", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAA".toLocaleLowerCase(), "\u1FA2", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAB".toLocaleLowerCase(), "\u1FA3", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAC".toLocaleLowerCase(), "\u1FA4", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAD".toLocaleLowerCase(), "\u1FA5", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAE".toLocaleLowerCase(), "\u1FA6", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAF".toLocaleLowerCase(), "\u1FA7", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FB3".toLocaleLowerCase(), "\u1FB3", "GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FBC".toLocaleLowerCase(), "\u1FB3", "GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FC3".toLocaleLowerCase(), "\u1FC3", "GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FCC".toLocaleLowerCase(), "\u1FC3", "GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FF3".toLocaleLowerCase(), "\u1FF3", "GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FFC".toLocaleLowerCase(), "\u1FF3", "GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI"); + +assert.sameValue("\u1FB2".toLocaleLowerCase(), "\u1FB2", "GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FB4".toLocaleLowerCase(), "\u1FB4", "GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC2".toLocaleLowerCase(), "\u1FC2", "GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC4".toLocaleLowerCase(), "\u1FC4", "GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF2".toLocaleLowerCase(), "\u1FF2", "GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF4".toLocaleLowerCase(), "\u1FF4", "GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FB7".toLocaleLowerCase(), "\u1FB7", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC7".toLocaleLowerCase(), "\u1FC7", "GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF7".toLocaleLowerCase(), "\u1FF7", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/special_casing_conditional.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/special_casing_conditional.js new file mode 100644 index 0000000000..eaa101eeb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/special_casing_conditional.js @@ -0,0 +1,103 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Check if String.prototype.toLocaleLowerCase supports conditional mappings defined in SpecialCasings +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +es5id: 15.5.4.17 +es6id: 21.1.3.20 +---*/ + +// SpecialCasing.txt, conditional, language-insensitive mappings. + +// <code>; <lower>; <title>; <upper>; (<condition_list>;)? # <comment> +// 03A3; 03C2; 03A3; 03A3; Final_Sigma; # GREEK CAPITAL LETTER SIGMA +// 03A3; 03C3; 03A3; 03A3; # GREEK CAPITAL LETTER SIGMA + +// Final_Sigma is defined in Unicode 5.1, 3.13 Default Case Algorithms. + +assert.sameValue( + "\u03A3".toLocaleLowerCase(), + "\u03C3", + "Single GREEK CAPITAL LETTER SIGMA" +); + +// Sigma preceded by Cased and zero or more Case_Ignorable. +assert.sameValue( + "A\u03A3".toLocaleLowerCase(), + "a\u03C2", + "Sigma preceded by LATIN CAPITAL LETTER A" +); +assert.sameValue( + "\uD835\uDCA2\u03A3".toLocaleLowerCase(), + "\uD835\uDCA2\u03C2", + "Sigma preceded by MATHEMATICAL SCRIPT CAPITAL G (D835 DCA2 = 1D4A2)" +); +assert.sameValue( + "A.\u03A3".toLocaleLowerCase(), + "a.\u03C2", + "Sigma preceded by FULL STOP" +); +assert.sameValue( + "A\u00AD\u03A3".toLocaleLowerCase(), + "a\u00AD\u03C2", + "Sigma preceded by SOFT HYPHEN (00AD)" +); +assert.sameValue( + "A\uD834\uDE42\u03A3".toLocaleLowerCase(), + "a\uD834\uDE42\u03C2", + "Sigma preceded by COMBINING GREEK MUSICAL TRISEME (D834 DE42 = 1D242)" +); +assert.sameValue( + "\u0345\u03A3".toLocaleLowerCase(), + "\u0345\u03C3", + "Sigma preceded by COMBINING GREEK YPOGEGRAMMENI (0345)" +); +assert.sameValue( + "\u0391\u0345\u03A3".toLocaleLowerCase(), + "\u03B1\u0345\u03C2", + "Sigma preceded by GREEK CAPITAL LETTER ALPHA (0391), COMBINING GREEK YPOGEGRAMMENI (0345)" +); + +// Sigma not followed by zero or more Case_Ignorable and then Cased. +assert.sameValue( + "A\u03A3B".toLocaleLowerCase(), + "a\u03C3b", + "Sigma followed by LATIN CAPITAL LETTER B" +); +assert.sameValue( + "A\u03A3\uD835\uDCA2".toLocaleLowerCase(), + "a\u03C3\uD835\uDCA2", + "Sigma followed by MATHEMATICAL SCRIPT CAPITAL G (D835 DCA2 = 1D4A2)" +); +assert.sameValue( + "A\u03A3.b".toLocaleLowerCase(), + "a\u03C3.b", + "Sigma followed by FULL STOP" +); +assert.sameValue( + "A\u03A3\u00ADB".toLocaleLowerCase(), + "a\u03C3\u00ADb", + "Sigma followed by SOFT HYPHEN (00AD)" +); +assert.sameValue( + "A\u03A3\uD834\uDE42B".toLocaleLowerCase(), + "a\u03C3\uD834\uDE42b", + "Sigma followed by COMBINING GREEK MUSICAL TRISEME (D834 DE42 = 1D242)" +); +assert.sameValue( + "A\u03A3\u0345".toLocaleLowerCase(), + "a\u03C2\u0345", + "Sigma followed by COMBINING GREEK YPOGEGRAMMENI (0345)" +); +assert.sameValue( + "A\u03A3\u0345\u0391".toLocaleLowerCase(), + "a\u03C3\u0345\u03B1", + "Sigma followed by COMBINING GREEK YPOGEGRAMMENI (0345), GREEK CAPITAL LETTER ALPHA (0391)" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/supplementary_plane.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/supplementary_plane.js new file mode 100644 index 0000000000..0c5be957a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/supplementary_plane.js @@ -0,0 +1,66 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: String.prototype.toLocaleLowerCase() iterates over code points +info: | + 21.1.3.20 String.prototype.toLocaleLowerCase() + ... + This function interprets a String value as a sequence of UTF-16 encoded + code points, as described in 6.1.4. + + This function works exactly the same as toLowerCase [...]. + + 21.1.3.20 String.prototype.toLowerCase ( ) + + ... + 4. Let cpList be a List containing in order the code points as defined in + 6.1.4 of S, starting at the first element of S. + 5. For each code point c in cpList, if the Unicode Character Database + provides a language insensitive lower case equivalent of c then replace + c in cpList with that equivalent code point(s). +es6id: 21.1.3.20 +---*/ + +assert.sameValue("\uD801\uDC00".toLocaleLowerCase(), "\uD801\uDC28", "DESERET CAPITAL LETTER LONG I"); +assert.sameValue("\uD801\uDC01".toLocaleLowerCase(), "\uD801\uDC29", "DESERET CAPITAL LETTER LONG E"); +assert.sameValue("\uD801\uDC02".toLocaleLowerCase(), "\uD801\uDC2A", "DESERET CAPITAL LETTER LONG A"); +assert.sameValue("\uD801\uDC03".toLocaleLowerCase(), "\uD801\uDC2B", "DESERET CAPITAL LETTER LONG AH"); +assert.sameValue("\uD801\uDC04".toLocaleLowerCase(), "\uD801\uDC2C", "DESERET CAPITAL LETTER LONG O"); +assert.sameValue("\uD801\uDC05".toLocaleLowerCase(), "\uD801\uDC2D", "DESERET CAPITAL LETTER LONG OO"); +assert.sameValue("\uD801\uDC06".toLocaleLowerCase(), "\uD801\uDC2E", "DESERET CAPITAL LETTER SHORT I"); +assert.sameValue("\uD801\uDC07".toLocaleLowerCase(), "\uD801\uDC2F", "DESERET CAPITAL LETTER SHORT E"); +assert.sameValue("\uD801\uDC08".toLocaleLowerCase(), "\uD801\uDC30", "DESERET CAPITAL LETTER SHORT A"); +assert.sameValue("\uD801\uDC09".toLocaleLowerCase(), "\uD801\uDC31", "DESERET CAPITAL LETTER SHORT AH"); +assert.sameValue("\uD801\uDC0A".toLocaleLowerCase(), "\uD801\uDC32", "DESERET CAPITAL LETTER SHORT O"); +assert.sameValue("\uD801\uDC0B".toLocaleLowerCase(), "\uD801\uDC33", "DESERET CAPITAL LETTER SHORT OO"); +assert.sameValue("\uD801\uDC0C".toLocaleLowerCase(), "\uD801\uDC34", "DESERET CAPITAL LETTER AY"); +assert.sameValue("\uD801\uDC0D".toLocaleLowerCase(), "\uD801\uDC35", "DESERET CAPITAL LETTER OW"); +assert.sameValue("\uD801\uDC0E".toLocaleLowerCase(), "\uD801\uDC36", "DESERET CAPITAL LETTER WU"); +assert.sameValue("\uD801\uDC0F".toLocaleLowerCase(), "\uD801\uDC37", "DESERET CAPITAL LETTER YEE"); +assert.sameValue("\uD801\uDC10".toLocaleLowerCase(), "\uD801\uDC38", "DESERET CAPITAL LETTER H"); +assert.sameValue("\uD801\uDC11".toLocaleLowerCase(), "\uD801\uDC39", "DESERET CAPITAL LETTER PEE"); +assert.sameValue("\uD801\uDC12".toLocaleLowerCase(), "\uD801\uDC3A", "DESERET CAPITAL LETTER BEE"); +assert.sameValue("\uD801\uDC13".toLocaleLowerCase(), "\uD801\uDC3B", "DESERET CAPITAL LETTER TEE"); +assert.sameValue("\uD801\uDC14".toLocaleLowerCase(), "\uD801\uDC3C", "DESERET CAPITAL LETTER DEE"); +assert.sameValue("\uD801\uDC15".toLocaleLowerCase(), "\uD801\uDC3D", "DESERET CAPITAL LETTER CHEE"); +assert.sameValue("\uD801\uDC16".toLocaleLowerCase(), "\uD801\uDC3E", "DESERET CAPITAL LETTER JEE"); +assert.sameValue("\uD801\uDC17".toLocaleLowerCase(), "\uD801\uDC3F", "DESERET CAPITAL LETTER KAY"); +assert.sameValue("\uD801\uDC18".toLocaleLowerCase(), "\uD801\uDC40", "DESERET CAPITAL LETTER GAY"); +assert.sameValue("\uD801\uDC19".toLocaleLowerCase(), "\uD801\uDC41", "DESERET CAPITAL LETTER EF"); +assert.sameValue("\uD801\uDC1A".toLocaleLowerCase(), "\uD801\uDC42", "DESERET CAPITAL LETTER VEE"); +assert.sameValue("\uD801\uDC1B".toLocaleLowerCase(), "\uD801\uDC43", "DESERET CAPITAL LETTER ETH"); +assert.sameValue("\uD801\uDC1C".toLocaleLowerCase(), "\uD801\uDC44", "DESERET CAPITAL LETTER THEE"); +assert.sameValue("\uD801\uDC1D".toLocaleLowerCase(), "\uD801\uDC45", "DESERET CAPITAL LETTER ES"); +assert.sameValue("\uD801\uDC1E".toLocaleLowerCase(), "\uD801\uDC46", "DESERET CAPITAL LETTER ZEE"); +assert.sameValue("\uD801\uDC1F".toLocaleLowerCase(), "\uD801\uDC47", "DESERET CAPITAL LETTER ESH"); +assert.sameValue("\uD801\uDC20".toLocaleLowerCase(), "\uD801\uDC48", "DESERET CAPITAL LETTER ZHEE"); +assert.sameValue("\uD801\uDC21".toLocaleLowerCase(), "\uD801\uDC49", "DESERET CAPITAL LETTER ER"); +assert.sameValue("\uD801\uDC22".toLocaleLowerCase(), "\uD801\uDC4A", "DESERET CAPITAL LETTER EL"); +assert.sameValue("\uD801\uDC23".toLocaleLowerCase(), "\uD801\uDC4B", "DESERET CAPITAL LETTER EM"); +assert.sameValue("\uD801\uDC24".toLocaleLowerCase(), "\uD801\uDC4C", "DESERET CAPITAL LETTER EN"); +assert.sameValue("\uD801\uDC25".toLocaleLowerCase(), "\uD801\uDC4D", "DESERET CAPITAL LETTER ENG"); +assert.sameValue("\uD801\uDC26".toLocaleLowerCase(), "\uD801\uDC4E", "DESERET CAPITAL LETTER OI"); +assert.sameValue("\uD801\uDC27".toLocaleLowerCase(), "\uD801\uDC4F", "DESERET CAPITAL LETTER EW"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..9998f32056 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleLowerCase/this-value-not-obj-coercible.js @@ -0,0 +1,28 @@ +// 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.tolocalelowercase +description: The "this" value must be object-coercible +info: | + This function works exactly the same as toLowerCase except that its result is + intended to yield the correct result for the host environment's current + locale, rather than a locale-independent result. + + 21.1.3.24 String.prototype.toLowerCase + + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toLocaleLowerCase = String.prototype.toLocaleLowerCase; + +assert.sameValue(typeof toLocaleLowerCase, 'function'); + +assert.throws(TypeError, function() { + toLocaleLowerCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toLocaleLowerCase.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A10.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A10.js new file mode 100644 index 0000000000..07ac6f90b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A10.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.toLocaleUpperCase.length property has the attribute + ReadOnly +es5id: 15.5.4.19_A10 +description: > + Checking if varying the String.prototype.toLocaleUpperCase.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toLocaleUpperCase.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.toLocaleUpperCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLocaleUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.toLocaleUpperCase.length; + +verifyNotWritable(String.prototype.toLocaleUpperCase, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLocaleUpperCase.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.toLocaleUpperCase.length; String.prototype.toLocaleUpperCase.length = function(){return "shifted";}; String.prototype.toLocaleUpperCase.length === __obj. Actual: ' + String.prototype.toLocaleUpperCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A11.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A11.js new file mode 100644 index 0000000000..24681ed604 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A11.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 length property of the toLocaleUpperCase method is 0 +es5id: 15.5.4.19_A11 +description: Checking String.prototype.toLocaleUpperCase.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toLocaleUpperCase.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.toLocaleUpperCase.hasOwnProperty("length") return true. Actual: ' + String.prototype.toLocaleUpperCase.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLocaleUpperCase.length !== 0) { + throw new Test262Error('#2: String.prototype.toLocaleUpperCase.length === 0. Actual: ' + String.prototype.toLocaleUpperCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T1.js new file mode 100644 index 0000000000..dfdae2894e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T1 +description: Arguments is true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toLocaleUpperCase() !== "TRUE") { + throw new Test262Error('#1: __instance = new Object(true); __instance.toLocaleUpperCase = String.prototype.toLocaleUpperCase; __instance.toLocaleUpperCase() === "TRUE". Actual: ' + __instance.toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T10.js new file mode 100644 index 0000000000..1548daa7ea --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T10.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.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T10 +description: > + Call toLocaleUpperCase() function of object with overrode toString + function +---*/ + +var __obj = { + toString: function() { + return "\u0041b"; + } +} +__obj.toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toLocaleUpperCase() !== "AB") { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041b";}}; __obj.toLocaleUpperCase = String.prototype.toLocaleUpperCase; __obj.toLocaleUpperCase() ==="AB". Actual: ' + __obj.toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T11.js new file mode 100644 index 0000000000..19d8a43eca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T11.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.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T11 +description: > + Override toString function, toString throw exception, then call + toLocaleUpperCase() function for this object +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +} +__obj.toLocaleUpperCase = String.prototype.toLocaleUpperCase; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toLocaleUpperCase(); + throw new Test262Error('#1: "var x = __obj.toLocaleUpperCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T12.js new file mode 100644 index 0000000000..250b208e21 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T12.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.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T12 +description: > + Override toString and valueOf functions, valueOf throw exception, + then call toLocaleUpperCase() function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +} +__obj.toLocaleUpperCase = String.prototype.toLocaleUpperCase; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toLocaleUpperCase(); + throw new Test262Error('#1: "var x = __obj.toLocaleUpperCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T13.js new file mode 100644 index 0000000000..ab19cf326a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T13.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: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T13 +description: > + Override toString and valueOf functions, then call + toLocaleUpperCase() function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +} +__obj.toLocaleUpperCase = String.prototype.toLocaleUpperCase; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toLocaleUpperCase() !== "1") { + throw new Test262Error('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLocaleUpperCase = String.prototype.toLocaleUpperCase; __obj.toLocaleUpperCase() ==="1". Actual: ' + __obj.toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.toLocaleUpperCase().length !== 1) { + throw new Test262Error('#2: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLocaleUpperCase = String.prototype.toLocaleUpperCase; __obj.toLocaleUpperCase().length === 1. Actual: ' + __obj.toLocaleUpperCase().length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T14.js new file mode 100644 index 0000000000..c76d70bd29 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T14.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T14 +description: Call toLocaleUpperCase() function for RegExp object +---*/ + +var __reg = new RegExp("abc"); +__reg.toLocaleUpperCase = String.prototype.toLocaleUpperCase; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__reg.toLocaleUpperCase() !== "/ABC/") { + throw new Test262Error('#1: var __reg = new RegExp("abc"); __reg.toLocaleUpperCase = String.prototype.toLocaleUpperCase; __reg.toLocaleUpperCase() === "/ABC/". Actual: ' + __reg.toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T2.js new file mode 100644 index 0000000000..3fe8267677 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T2 +description: Instance is Boolean object +---*/ + +var __instance = new Boolean; + +__instance.toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toLocaleUpperCase() !== "FALSE") { + throw new Test262Error('#1: __instance = new Boolean; __instance.toLocaleUpperCase = String.prototype.toLocaleUpperCase; __instance.toLocaleUpperCase() === "FALSE". Actual: ' + __instance.toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T3.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T3.js new file mode 100644 index 0000000000..23b5df7c2e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T3.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T3 +description: Checking by using eval +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (eval("\"bj\"").toLocaleUpperCase() !== "BJ") { + throw new Test262Error('#1: eval("\\"bj\\"").toLocaleUpperCase() === "BJ". Actual: ' + eval("\"bj\"").toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T4.js new file mode 100644 index 0000000000..6afd8033f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T4.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.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T4 +description: > + Call toLocaleUpperCase() function without arguments of string and + from empty string +---*/ + +var __lowerCase = "".toLocaleUpperCase(); +var __expected = ""; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__lowerCase.length !== __expected.length) { + throw new Test262Error('#1: __lowerCase = "".toLocaleUpperCase(); __expected = ""; __lowerCase.length === __expected.length. Actual: ' + __lowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__lowerCase.index !== __expected.index) { + throw new Test262Error('#2: __lowerCase = "".toLocaleUpperCase(); __expected = ""; __lowerCase.index === __expected.index. Actual: ' + __lowerCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__lowerCase.input !== __expected.input) { + throw new Test262Error('#3: __lowerCase = "".toLocaleUpperCase(); __expected = ""; __lowerCase.input === __expected.input. Actual: ' + __lowerCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__lowerCase[0] !== __expected[0]) { + throw new Test262Error('#4: __lowerCase = "".toLocaleUpperCase(); __lowerCase[0]===' + __expected[0] + '. Actual: ' + __lowerCase[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T5.js new file mode 100644 index 0000000000..bc0b5822ca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T5 +description: Call toLocaleUpperCase() function of function call +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" match(null) evaluates to match("null") +if (function() { + return "GnulLuNa" + }().toLocaleUpperCase() !== "GNULLUNA") { + throw new Test262Error('#1: function(){return "GnulLuNa"}().toLocaleUpperCase() === "GNULLUNA". Actual: ' + function() { + return "GnulLuNa" + }().toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T6.js new file mode 100644 index 0000000000..d72635a568 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T6 +description: Call toLocaleUpperCase() function of Number.NEGATIVE_INFINITY +---*/ + +Number.prototype.toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((Number.NEGATIVE_INFINITY).toLocaleUpperCase() !== "-INFINITY") { + throw new Test262Error('#1: Number.prototype.toLocaleUpperCase = String.prototype.toLocaleUpperCase; (Number.NEGATIVE_INFINITY).toLocaleUpperCase() === "-INFINITY". Actual: ' + (Number.NEGATIVE_INFINITY).toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T7.js new file mode 100644 index 0000000000..87420328a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T7 +description: Call toLocaleUpperCase() function of NaN +---*/ + +Number.prototype.toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (NaN.toLocaleUpperCase() !== "NAN") { + throw new Test262Error('#1: Number.prototype.toLocaleUpperCase = String.prototype.toLocaleUpperCase; NaN.toLocaleUpperCase()=== "NAN". Actual: ' + NaN.toLocaleUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T8.js new file mode 100644 index 0000000000..ce1d49011f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T8.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.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T8 +description: Call toLocaleUpperCase() function of Infinity +---*/ + +Number.prototype.toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +if (Infinity.toLocaleUpperCase() !== "INFINITY") { + throw new Test262Error('#1: Number.prototype.toLocaleUpperCase = String.prototype.toLocaleUpperCase; Infinity.toLocaleUpperCase()=== "INFINITY". Actual: ' + Infinity.toLocaleUpperCase()); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T9.js new file mode 100644 index 0000000000..644e10bd04 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A1_T9.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase() +es5id: 15.5.4.19_A1_T9 +description: Call toLocaleUpperCase() function of string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +var __lowerCase = new String(__obj).toLocaleUpperCase(); + +var __expected = "UNDEFINED"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__lowerCase.length !== __expected.length) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleUpperCase(); __expected ="UNDEFINED"; __lowerCase.length === __expected.length. Actual: ' + __lowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__lowerCase.index !== __expected.index) { + throw new Test262Error('#2: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleUpperCase(); __expected ="UNDEFINED"; __lowerCase.index === __expected.index. Actual: ' + __lowerCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__lowerCase.input !== __expected.input) { + throw new Test262Error('#3: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleUpperCase(); __expected ="UNDEFINED"; __lowerCase.input === __expected.input. Actual: ' + __lowerCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__lowerCase[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLocaleUpperCase(); __expected ="UNDEFINED"; __lowerCase[' + index + ']===' + __expected[index] + '. Actual: ' + __lowerCase[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A2_T1.js new file mode 100644 index 0000000000..5ddf56ba2a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A2_T1.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.toLocaleUpperCase() return a string, but not a String + object +es5id: 15.5.4.19_A2_T1 +description: Checking returned result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("Hello, WoRlD!".toLocaleUpperCase() !== "HELLO, WORLD!") { + throw new Test262Error('#1: "Hello, WoRlD!".toLocaleUpperCase() === "HELLO, WORLD!". Actual: ' + ("Hello, WoRlD!".toLocaleUpperCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if ("Hello, WoRlD!".toLocaleUpperCase() !== String("HELLO, WORLD!")) { + throw new Test262Error('#2: "Hello, WoRlD!".toLocaleUpperCase() === String("HELLO, WORLD!"). Actual: ' + ("Hello, WoRlD!".toLocaleUpperCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if ("Hello, WoRlD!".toLocaleUpperCase() === new String("HELLO, WORLD!")) { + throw new Test262Error('#3: "Hello, WoRlD!".toLocaleUpperCase() !== new String("HELLO, WORLD!"'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A6.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A6.js new file mode 100644 index 0000000000..d2ad63105b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase has not prototype property +es5id: 15.5.4.19_A6 +description: Checking String.prototype.toLocaleUpperCase.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.toLocaleUpperCase.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.toLocaleUpperCase.prototype === undefined. Actual: ' + String.prototype.toLocaleUpperCase.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A7.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A7.js new file mode 100644 index 0000000000..fbde6f1043 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A7.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLocaleUpperCase can't be used as constructor +es5id: 15.5.4.19_A7 +description: > + Checking if creating the String.prototype.toLocaleUpperCase object + fails +---*/ + +var __FACTORY = String.prototype.toLocaleUpperCase; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: __FACTORY = String.prototype.toLocaleUpperCase; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.1: var __instance = new __FACTORY; Object has no construct lead a TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A8.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A8.js new file mode 100644 index 0000000000..43939e080b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A8.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: | + The String.prototype.toLocaleUpperCase.length property has the attribute + DontEnum +es5id: 15.5.4.19_A8 +description: > + Checking if enumerating the + String.prototype.toLocaleUpperCase.length property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toLocaleUpperCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toLocaleUpperCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLocaleUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.toLocaleUpperCase.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.toLocaleUpperCase.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.toLocaleUpperCase) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.toLocaleUpperCase){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A9.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A9.js new file mode 100644 index 0000000000..b411014e54 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/S15.5.4.19_A9.js @@ -0,0 +1,38 @@ +// 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.toLocaleUpperCase.length property does not have the + attribute DontDelete +es5id: 15.5.4.19_A9 +description: > + Checking if deleting the String.prototype.toLocaleUpperCase.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toLocaleUpperCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toLocaleUpperCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLocaleUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.toLocaleUpperCase.length) { + throw new Test262Error('#1: delete String.prototype.toLocaleUpperCase.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLocaleUpperCase.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.toLocaleUpperCase.length; String.prototype.toLocaleUpperCase.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.toLocaleUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/browser.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/name.js new file mode 100644 index 0000000000..e20dd69220 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/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.21 +description: > + String.prototype.toLocaleUpperCase.name is "toLocaleUpperCase". +info: | + String.prototype.toLocaleUpperCase ( [ reserved1 [ , reserved2 ] ] ) + + 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.toLocaleUpperCase.name, "toLocaleUpperCase"); + +verifyNotEnumerable(String.prototype.toLocaleUpperCase, "name"); +verifyNotWritable(String.prototype.toLocaleUpperCase, "name"); +verifyConfigurable(String.prototype.toLocaleUpperCase, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/not-a-constructor.js new file mode 100644 index 0000000000..2dbfcb12e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/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.toLocaleUpperCase 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.toLocaleUpperCase), + false, + 'isConstructor(String.prototype.toLocaleUpperCase) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.toLocaleUpperCase(); +}, '`new String.prototype.toLocaleUpperCase()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/shell.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/special_casing.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/special_casing.js new file mode 100644 index 0000000000..16edb26757 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/special_casing.js @@ -0,0 +1,137 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Check if String.prototype.toLocaleUpperCase supports mappings defined in SpecialCasings +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +es5id: 15.5.4.19 +es6id: 21.1.3.21 +---*/ + +// SpecialCasing.txt, except for conditional mappings. + +assert.sameValue("\u00DF".toLocaleUpperCase(), "\u0053\u0053", "LATIN SMALL LETTER SHARP S"); + +assert.sameValue("\u0130".toLocaleUpperCase(), "\u0130", "LATIN CAPITAL LETTER I WITH DOT ABOVE"); + +assert.sameValue("\uFB00".toLocaleUpperCase(), "\u0046\u0046", "LATIN SMALL LIGATURE FF"); +assert.sameValue("\uFB01".toLocaleUpperCase(), "\u0046\u0049", "LATIN SMALL LIGATURE FI"); +assert.sameValue("\uFB02".toLocaleUpperCase(), "\u0046\u004C", "LATIN SMALL LIGATURE FL"); +assert.sameValue("\uFB03".toLocaleUpperCase(), "\u0046\u0046\u0049", "LATIN SMALL LIGATURE FFI"); +assert.sameValue("\uFB04".toLocaleUpperCase(), "\u0046\u0046\u004C", "LATIN SMALL LIGATURE FFL"); +assert.sameValue("\uFB05".toLocaleUpperCase(), "\u0053\u0054", "LATIN SMALL LIGATURE LONG S T"); +assert.sameValue("\uFB06".toLocaleUpperCase(), "\u0053\u0054", "LATIN SMALL LIGATURE ST"); + +assert.sameValue("\u0587".toLocaleUpperCase(), "\u0535\u0552", "ARMENIAN SMALL LIGATURE ECH YIWN"); +assert.sameValue("\uFB13".toLocaleUpperCase(), "\u0544\u0546", "ARMENIAN SMALL LIGATURE MEN NOW"); +assert.sameValue("\uFB14".toLocaleUpperCase(), "\u0544\u0535", "ARMENIAN SMALL LIGATURE MEN ECH"); +assert.sameValue("\uFB15".toLocaleUpperCase(), "\u0544\u053B", "ARMENIAN SMALL LIGATURE MEN INI"); +assert.sameValue("\uFB16".toLocaleUpperCase(), "\u054E\u0546", "ARMENIAN SMALL LIGATURE VEW NOW"); +assert.sameValue("\uFB17".toLocaleUpperCase(), "\u0544\u053D", "ARMENIAN SMALL LIGATURE MEN XEH"); + +assert.sameValue("\u0149".toLocaleUpperCase(), "\u02BC\u004E", "LATIN SMALL LETTER N PRECEDED BY APOSTROPHE"); + +assert.sameValue("\u0390".toLocaleUpperCase(), "\u0399\u0308\u0301", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS"); +assert.sameValue("\u03B0".toLocaleUpperCase(), "\u03A5\u0308\u0301", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS"); + +assert.sameValue("\u01F0".toLocaleUpperCase(), "\u004A\u030C", "LATIN SMALL LETTER J WITH CARON"); +assert.sameValue("\u1E96".toLocaleUpperCase(), "\u0048\u0331", "LATIN SMALL LETTER H WITH LINE BELOW"); +assert.sameValue("\u1E97".toLocaleUpperCase(), "\u0054\u0308", "LATIN SMALL LETTER T WITH DIAERESIS"); +assert.sameValue("\u1E98".toLocaleUpperCase(), "\u0057\u030A", "LATIN SMALL LETTER W WITH RING ABOVE"); +assert.sameValue("\u1E99".toLocaleUpperCase(), "\u0059\u030A", "LATIN SMALL LETTER Y WITH RING ABOVE"); +assert.sameValue("\u1E9A".toLocaleUpperCase(), "\u0041\u02BE", "LATIN SMALL LETTER A WITH RIGHT HALF RING"); + +assert.sameValue("\u1F50".toLocaleUpperCase(), "\u03A5\u0313", "GREEK SMALL LETTER UPSILON WITH PSILI"); +assert.sameValue("\u1F52".toLocaleUpperCase(), "\u03A5\u0313\u0300", "GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA"); +assert.sameValue("\u1F54".toLocaleUpperCase(), "\u03A5\u0313\u0301", "GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA"); +assert.sameValue("\u1F56".toLocaleUpperCase(), "\u03A5\u0313\u0342", "GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI"); +assert.sameValue("\u1FB6".toLocaleUpperCase(), "\u0391\u0342", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI"); +assert.sameValue("\u1FC6".toLocaleUpperCase(), "\u0397\u0342", "GREEK SMALL LETTER ETA WITH PERISPOMENI"); +assert.sameValue("\u1FD2".toLocaleUpperCase(), "\u0399\u0308\u0300", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FD3".toLocaleUpperCase(), "\u0399\u0308\u0301", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FD6".toLocaleUpperCase(), "\u0399\u0342", "GREEK SMALL LETTER IOTA WITH PERISPOMENI"); +assert.sameValue("\u1FD7".toLocaleUpperCase(), "\u0399\u0308\u0342", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FE2".toLocaleUpperCase(), "\u03A5\u0308\u0300", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FE3".toLocaleUpperCase(), "\u03A5\u0308\u0301", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FE4".toLocaleUpperCase(), "\u03A1\u0313", "GREEK SMALL LETTER RHO WITH PSILI"); +assert.sameValue("\u1FE6".toLocaleUpperCase(), "\u03A5\u0342", "GREEK SMALL LETTER UPSILON WITH PERISPOMENI"); +assert.sameValue("\u1FE7".toLocaleUpperCase(), "\u03A5\u0308\u0342", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FF6".toLocaleUpperCase(), "\u03A9\u0342", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI"); + +assert.sameValue("\u1F80".toLocaleUpperCase(), "\u1F08\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F81".toLocaleUpperCase(), "\u1F09\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F82".toLocaleUpperCase(), "\u1F0A\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F83".toLocaleUpperCase(), "\u1F0B\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F84".toLocaleUpperCase(), "\u1F0C\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F85".toLocaleUpperCase(), "\u1F0D\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F86".toLocaleUpperCase(), "\u1F0E\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F87".toLocaleUpperCase(), "\u1F0F\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F88".toLocaleUpperCase(), "\u1F08\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F89".toLocaleUpperCase(), "\u1F09\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8A".toLocaleUpperCase(), "\u1F0A\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8B".toLocaleUpperCase(), "\u1F0B\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8C".toLocaleUpperCase(), "\u1F0C\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8D".toLocaleUpperCase(), "\u1F0D\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8E".toLocaleUpperCase(), "\u1F0E\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8F".toLocaleUpperCase(), "\u1F0F\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1F90".toLocaleUpperCase(), "\u1F28\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F91".toLocaleUpperCase(), "\u1F29\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F92".toLocaleUpperCase(), "\u1F2A\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F93".toLocaleUpperCase(), "\u1F2B\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F94".toLocaleUpperCase(), "\u1F2C\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F95".toLocaleUpperCase(), "\u1F2D\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F96".toLocaleUpperCase(), "\u1F2E\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F97".toLocaleUpperCase(), "\u1F2F\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F98".toLocaleUpperCase(), "\u1F28\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F99".toLocaleUpperCase(), "\u1F29\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9A".toLocaleUpperCase(), "\u1F2A\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9B".toLocaleUpperCase(), "\u1F2B\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9C".toLocaleUpperCase(), "\u1F2C\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9D".toLocaleUpperCase(), "\u1F2D\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9E".toLocaleUpperCase(), "\u1F2E\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9F".toLocaleUpperCase(), "\u1F2F\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FA0".toLocaleUpperCase(), "\u1F68\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA1".toLocaleUpperCase(), "\u1F69\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA2".toLocaleUpperCase(), "\u1F6A\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA3".toLocaleUpperCase(), "\u1F6B\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA4".toLocaleUpperCase(), "\u1F6C\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA5".toLocaleUpperCase(), "\u1F6D\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA6".toLocaleUpperCase(), "\u1F6E\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA7".toLocaleUpperCase(), "\u1F6F\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FA8".toLocaleUpperCase(), "\u1F68\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FA9".toLocaleUpperCase(), "\u1F69\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAA".toLocaleUpperCase(), "\u1F6A\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAB".toLocaleUpperCase(), "\u1F6B\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAC".toLocaleUpperCase(), "\u1F6C\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAD".toLocaleUpperCase(), "\u1F6D\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAE".toLocaleUpperCase(), "\u1F6E\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAF".toLocaleUpperCase(), "\u1F6F\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FB3".toLocaleUpperCase(), "\u0391\u0399", "GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FBC".toLocaleUpperCase(), "\u0391\u0399", "GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FC3".toLocaleUpperCase(), "\u0397\u0399", "GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FCC".toLocaleUpperCase(), "\u0397\u0399", "GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FF3".toLocaleUpperCase(), "\u03A9\u0399", "GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FFC".toLocaleUpperCase(), "\u03A9\u0399", "GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI"); + +assert.sameValue("\u1FB2".toLocaleUpperCase(), "\u1FBA\u0399", "GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FB4".toLocaleUpperCase(), "\u0386\u0399", "GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC2".toLocaleUpperCase(), "\u1FCA\u0399", "GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC4".toLocaleUpperCase(), "\u0389\u0399", "GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF2".toLocaleUpperCase(), "\u1FFA\u0399", "GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF4".toLocaleUpperCase(), "\u038F\u0399", "GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FB7".toLocaleUpperCase(), "\u0391\u0342\u0399", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC7".toLocaleUpperCase(), "\u0397\u0342\u0399", "GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF7".toLocaleUpperCase(), "\u03A9\u0342\u0399", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/supplementary_plane.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/supplementary_plane.js new file mode 100644 index 0000000000..1d1b40ff81 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/supplementary_plane.js @@ -0,0 +1,72 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: String.prototype.toLocaleUpperCase() iterates over code points +info: | + 21.1.3.21 String.prototype.toLocaleUpperCase() + ... + This function interprets a String value as a sequence of UTF-16 encoded + code points, as described in 6.1.4. + + This function works exactly the same as toUpperCase [...]. + + 21.1.3.24 String.prototype.toUpperCase ( ) + + This function behaves in exactly the same way as String.prototype.toLowerCase, + except that code points are mapped to their uppercase equivalents as specified + in the Unicode Character Database. + + 21.1.3.22 String.prototype.toLowerCase ( ) + + ... + 4. Let cpList be a List containing in order the code points as defined in + 6.1.4 of S, starting at the first element of S. + 5. For each code point c in cpList, if the Unicode Character Database + provides a language insensitive lower case equivalent of c then replace + c in cpList with that equivalent code point(s). +es6id: 21.1.3.21 +---*/ + +assert.sameValue("\uD801\uDC28".toLocaleUpperCase(), "\uD801\uDC00", "DESERET SMALL LETTER LONG I"); +assert.sameValue("\uD801\uDC29".toLocaleUpperCase(), "\uD801\uDC01", "DESERET SMALL LETTER LONG E"); +assert.sameValue("\uD801\uDC2A".toLocaleUpperCase(), "\uD801\uDC02", "DESERET SMALL LETTER LONG A"); +assert.sameValue("\uD801\uDC2B".toLocaleUpperCase(), "\uD801\uDC03", "DESERET SMALL LETTER LONG AH"); +assert.sameValue("\uD801\uDC2C".toLocaleUpperCase(), "\uD801\uDC04", "DESERET SMALL LETTER LONG O"); +assert.sameValue("\uD801\uDC2D".toLocaleUpperCase(), "\uD801\uDC05", "DESERET SMALL LETTER LONG OO"); +assert.sameValue("\uD801\uDC2E".toLocaleUpperCase(), "\uD801\uDC06", "DESERET SMALL LETTER SHORT I"); +assert.sameValue("\uD801\uDC2F".toLocaleUpperCase(), "\uD801\uDC07", "DESERET SMALL LETTER SHORT E"); +assert.sameValue("\uD801\uDC30".toLocaleUpperCase(), "\uD801\uDC08", "DESERET SMALL LETTER SHORT A"); +assert.sameValue("\uD801\uDC31".toLocaleUpperCase(), "\uD801\uDC09", "DESERET SMALL LETTER SHORT AH"); +assert.sameValue("\uD801\uDC32".toLocaleUpperCase(), "\uD801\uDC0A", "DESERET SMALL LETTER SHORT O"); +assert.sameValue("\uD801\uDC33".toLocaleUpperCase(), "\uD801\uDC0B", "DESERET SMALL LETTER SHORT OO"); +assert.sameValue("\uD801\uDC34".toLocaleUpperCase(), "\uD801\uDC0C", "DESERET SMALL LETTER AY"); +assert.sameValue("\uD801\uDC35".toLocaleUpperCase(), "\uD801\uDC0D", "DESERET SMALL LETTER OW"); +assert.sameValue("\uD801\uDC36".toLocaleUpperCase(), "\uD801\uDC0E", "DESERET SMALL LETTER WU"); +assert.sameValue("\uD801\uDC37".toLocaleUpperCase(), "\uD801\uDC0F", "DESERET SMALL LETTER YEE"); +assert.sameValue("\uD801\uDC38".toLocaleUpperCase(), "\uD801\uDC10", "DESERET SMALL LETTER H"); +assert.sameValue("\uD801\uDC39".toLocaleUpperCase(), "\uD801\uDC11", "DESERET SMALL LETTER PEE"); +assert.sameValue("\uD801\uDC3A".toLocaleUpperCase(), "\uD801\uDC12", "DESERET SMALL LETTER BEE"); +assert.sameValue("\uD801\uDC3B".toLocaleUpperCase(), "\uD801\uDC13", "DESERET SMALL LETTER TEE"); +assert.sameValue("\uD801\uDC3C".toLocaleUpperCase(), "\uD801\uDC14", "DESERET SMALL LETTER DEE"); +assert.sameValue("\uD801\uDC3D".toLocaleUpperCase(), "\uD801\uDC15", "DESERET SMALL LETTER CHEE"); +assert.sameValue("\uD801\uDC3E".toLocaleUpperCase(), "\uD801\uDC16", "DESERET SMALL LETTER JEE"); +assert.sameValue("\uD801\uDC3F".toLocaleUpperCase(), "\uD801\uDC17", "DESERET SMALL LETTER KAY"); +assert.sameValue("\uD801\uDC40".toLocaleUpperCase(), "\uD801\uDC18", "DESERET SMALL LETTER GAY"); +assert.sameValue("\uD801\uDC41".toLocaleUpperCase(), "\uD801\uDC19", "DESERET SMALL LETTER EF"); +assert.sameValue("\uD801\uDC42".toLocaleUpperCase(), "\uD801\uDC1A", "DESERET SMALL LETTER VEE"); +assert.sameValue("\uD801\uDC43".toLocaleUpperCase(), "\uD801\uDC1B", "DESERET SMALL LETTER ETH"); +assert.sameValue("\uD801\uDC44".toLocaleUpperCase(), "\uD801\uDC1C", "DESERET SMALL LETTER THEE"); +assert.sameValue("\uD801\uDC45".toLocaleUpperCase(), "\uD801\uDC1D", "DESERET SMALL LETTER ES"); +assert.sameValue("\uD801\uDC46".toLocaleUpperCase(), "\uD801\uDC1E", "DESERET SMALL LETTER ZEE"); +assert.sameValue("\uD801\uDC47".toLocaleUpperCase(), "\uD801\uDC1F", "DESERET SMALL LETTER ESH"); +assert.sameValue("\uD801\uDC48".toLocaleUpperCase(), "\uD801\uDC20", "DESERET SMALL LETTER ZHEE"); +assert.sameValue("\uD801\uDC49".toLocaleUpperCase(), "\uD801\uDC21", "DESERET SMALL LETTER ER"); +assert.sameValue("\uD801\uDC4A".toLocaleUpperCase(), "\uD801\uDC22", "DESERET SMALL LETTER EL"); +assert.sameValue("\uD801\uDC4B".toLocaleUpperCase(), "\uD801\uDC23", "DESERET SMALL LETTER EM"); +assert.sameValue("\uD801\uDC4C".toLocaleUpperCase(), "\uD801\uDC24", "DESERET SMALL LETTER EN"); +assert.sameValue("\uD801\uDC4D".toLocaleUpperCase(), "\uD801\uDC25", "DESERET SMALL LETTER ENG"); +assert.sameValue("\uD801\uDC4E".toLocaleUpperCase(), "\uD801\uDC26", "DESERET SMALL LETTER OI"); +assert.sameValue("\uD801\uDC4F".toLocaleUpperCase(), "\uD801\uDC27", "DESERET SMALL LETTER EW"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..f3e2977792 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLocaleUpperCase/this-value-not-obj-coercible.js @@ -0,0 +1,34 @@ +// 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.tolocaleuppercase +description: The "this" value must be object-coercible +info: | + This function works exactly the same as toUpperCase except that its result is + intended to yield the correct result for the host environment's current + locale, rather than a locale-independent result. + + 21.1.3.26 String.prototype.toUpperCase + + This function behaves in exactly the same way as + String.prototype.toLowerCase, except that code points are mapped to their + uppercase equivalents as specified in the Unicode Character Database. + + 21.1.3.24 String.prototype.toLowerCase + + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toLocaleUpperCase = String.prototype.toLocaleUpperCase; + +assert.sameValue(typeof toLocaleUpperCase, 'function'); + +assert.throws(TypeError, function() { + toLocaleUpperCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toLocaleUpperCase.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/Final_Sigma_U180E.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/Final_Sigma_U180E.js new file mode 100644 index 0000000000..961b6abf84 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/Final_Sigma_U180E.js @@ -0,0 +1,62 @@ +// Copyright (C) 2016 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tolowercase +description: > + Check if String.prototype.toLowerCase supports conditional mappings defined in SpecialCasings, + test Final_Sigma context with Mongolian Vowel Separator +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +features: [u180e] +---*/ + +// SpecialCasing.txt, conditional, language-insensitive mappings. + +// <code>; <lower>; <title>; <upper>; (<condition_list>;)? # <comment> +// 03A3; 03C2; 03A3; 03A3; Final_Sigma; # GREEK CAPITAL LETTER SIGMA +// 03A3; 03C3; 03A3; 03A3; # GREEK CAPITAL LETTER SIGMA + +// Final_Sigma is defined in Unicode 8.0, 3.13 Default Case Algorithms +// General_Category of Mongolian Vowel Separator is Cf (Format), characters in Cf are Case_Ignorable. + + +// Sigma preceded by Mongolian Vowel Separator. +assert.sameValue( + "A\u180E\u03A3".toLowerCase(), + "a\u180E\u03C2", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR" +); +assert.sameValue( + "A\u180E\u03A3B".toLowerCase(), + "a\u180E\u03C3b", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR, followed by LATIN CAPITAL LETTER B" +); + +// Sigma followed by Mongolian Vowel Separator. +assert.sameValue( + "A\u03A3\u180E".toLowerCase(), + "a\u03C2\u180E", + "Sigma preceded by LATIN CAPITAL LETTER A, followed by MONGOLIAN VOWEL SEPARATOR" +); +assert.sameValue( + "A\u03A3\u180EB".toLowerCase(), + "a\u03C3\u180Eb", + "Sigma preceded by LATIN CAPITAL LETTER A, followed by MONGOLIAN VOWEL SEPARATOR, LATIN CAPITAL LETTER B" +); + +// Sigma preceded and followed by Mongolian Vowel Separator. +assert.sameValue( + "A\u180E\u03A3\u180E".toLowerCase(), + "a\u180E\u03C2\u180E", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR" +); +assert.sameValue( + "A\u180E\u03A3\u180EB".toLowerCase(), + "a\u180E\u03C3\u180Eb", + "Sigma preceded by LATIN CAPITAL LETTER A, MONGOLIAN VOWEL SEPARATOR, followed by MONGOLIAN VOWEL SEPARATOR, LATIN CAPITAL LETTER B" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A10.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A10.js new file mode 100644 index 0000000000..6fab668dcf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A10.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.toLowerCase.length property has the attribute + ReadOnly +es5id: 15.5.4.16_A10 +description: > + Checking if varying the String.prototype.toLowerCase.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toLowerCase.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.toLowerCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.toLowerCase.length; + +verifyNotWritable(String.prototype.toLowerCase, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLowerCase.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.toLowerCase.length; String.prototype.toLowerCase.length = function(){return "shifted";}; String.prototype.toLowerCase.length === __obj. Actual: ' + String.prototype.toLowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A11.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A11.js new file mode 100644 index 0000000000..04cde91c2f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A11.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 length property of the toLowerCase method is 0 +es5id: 15.5.4.16_A11 +description: Checking String.prototype.toLowerCase.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toLowerCase.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.toLowerCase.hasOwnProperty("length") return true. Actual: ' + String.prototype.toLowerCase.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLowerCase.length !== 0) { + throw new Test262Error('#2: String.prototype.toLowerCase.length === 0. Actual: ' + String.prototype.toLowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T1.js new file mode 100644 index 0000000000..2d6b0f4315 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T1 +description: Arguments is true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toLowerCase() !== "true") { + throw new Test262Error('#1: __instance = new Object(true); __instance.toLowerCase = String.prototype.toLowerCase; __instance.toLowerCase() === "true". Actual: ' + __instance.toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T10.js new file mode 100644 index 0000000000..1139c29567 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T10.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.toLowerCase() +es5id: 15.5.4.16_A1_T10 +description: > + Call toLowerCase() function of object with overrode toString + function +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +__obj.toLowerCase = String.prototype.toLowerCase; + + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toLowerCase() !== "ab") { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041B";}}; __obj.toLowerCase = String.prototype.toLowerCase; __obj.toLowerCase() ==="ab". Actual: ' + __obj.toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T11.js new file mode 100644 index 0000000000..e39bfca7df --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T11.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.toLowerCase() +es5id: 15.5.4.16_A1_T11 +description: > + Override toString function, toString throw exception, then call + toLowerCase() function for this object +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +} +__obj.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toLowerCase(); + throw new Test262Error('#1: "var x = __obj.toLowerCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T12.js new file mode 100644 index 0000000000..355844e014 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T12.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.toLowerCase() +es5id: 15.5.4.16_A1_T12 +description: > + Override toString and valueOf functions, valueOf throw exception, + then call toLowerCase() function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +} +__obj.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toLowerCase(); + throw new Test262Error('#1: "var x = __obj.toLowerCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T13.js new file mode 100644 index 0000000000..950d1d1875 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T13.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T13 +description: > + Override toString and valueOf functions, then call toLowerCase() + function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +} +__obj.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toLowerCase() !== "1") { + throw new Test262Error('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLowerCase = String.prototype.toLowerCase; __obj.toLowerCase() ==="1". Actual: ' + __obj.toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.toLowerCase().length !== 1) { + throw new Test262Error('#2: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toLowerCase = String.prototype.toLowerCase; __obj.toLowerCase().length === 1. Actual: ' + __obj.toLowerCase().length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T14.js new file mode 100644 index 0000000000..d981fff7fd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T14.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.toLowerCase() +es5id: 15.5.4.16_A1_T14 +description: Call toLowerCase() function for RegExp object +---*/ + +var __reg = new RegExp("ABC"); +__reg.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__reg.toLowerCase() !== "/abc/") { + throw new Test262Error('#1: var __reg = new RegExp("ABC"); __reg.toLowerCase = String.prototype.toLowerCase; __reg.toLowerCase() === "/abc/". Actual: ' + __reg.toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T2.js new file mode 100644 index 0000000000..8167201dec --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T2 +description: Instance is Boolean object +---*/ + +var __instance = new Boolean; + +__instance.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toLowerCase() !== "false") { + throw new Test262Error('#1: __instance = new Boolean; __instance.toLowerCase = String.prototype.toLowerCase; __instance.toLowerCase() === "false". Actual: ' + __instance.toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T3.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T3.js new file mode 100644 index 0000000000..b3c7a58a65 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T3.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T3 +description: Checking by using eval +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (eval("\"BJ\"").toLowerCase() !== "bj") { + throw new Test262Error('#1: eval("\\"BJ\\"").toLowerCase() === "bj". Actual: ' + eval("\"BJ\"").toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T4.js new file mode 100644 index 0000000000..339dec7f60 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T4.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.toLowerCase() +es5id: 15.5.4.16_A1_T4 +description: > + Call toLowerCase() function without arguments of string and from + empty string +---*/ + +var __lowerCase = "".toLowerCase(); + +var __expected = ""; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__lowerCase.length !== __expected.length) { + throw new Test262Error('#1: __lowerCase = "".toLowerCase(); __expected = ""; __lowerCase.length === __expected.length. Actual: ' + __lowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__lowerCase.index !== __expected.index) { + throw new Test262Error('#2: __lowerCase = "".toLowerCase(); __expected = ""; __lowerCase.index === __expected.index. Actual: ' + __lowerCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__lowerCase.input !== __expected.input) { + throw new Test262Error('#3: __lowerCase = "".toLowerCase(); __expected = ""; __lowerCase.input === __expected.input. Actual: ' + __lowerCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__lowerCase[0] !== __expected[0]) { + throw new Test262Error('#4: __lowerCase = "".toLowerCase(); __expected = ""; __lowerCase[0]===' + __expected[0] + '. Actual: ' + __lowerCase[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T5.js new file mode 100644 index 0000000000..66c5e84851 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T5 +description: Call toLowerCase() function for function call +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" match(null) evaluates to match("null") +if (function() { + return "GnulLuNa" + }().toLowerCase() !== "gnulluna") { + throw new Test262Error('#1: function(){return "GnulLuNa"}().toLowerCase() === "gnulluna". Actual: ' + function() { + return "GnulLuNa" + }().toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T6.js new file mode 100644 index 0000000000..0447844c40 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T6 +description: Call toLowerCase() function of Number.NEGATIVE_INFINITY +---*/ + +Number.prototype.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((Number.NEGATIVE_INFINITY).toLowerCase() !== "-infinity") { + throw new Test262Error('#1: Number.prototype.toLowerCase = String.prototype.toLowerCase; (Number.NEGATIVE_INFINITY).toLowerCase() === "-infinity". Actual: ' + (Number.NEGATIVE_INFINITY).toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T7.js new file mode 100644 index 0000000000..239740c605 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T7 +description: Call toLowerCase() function of NaN +---*/ + +Number.prototype.toLowerCase = String.prototype.toLowerCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (NaN.toLowerCase() !== "nan") { + throw new Test262Error('#1: Number.prototype.toLowerCase = String.prototype.toLowerCase; NaN.toLowerCase()=== "nan". Actual: ' + NaN.toLowerCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T8.js new file mode 100644 index 0000000000..7ab6dfe263 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T8.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.toLowerCase() +es5id: 15.5.4.16_A1_T8 +description: Call toLowerCase() function of Infinity +---*/ + +Number.prototype.toLowerCase = String.prototype.toLowerCase; + +if (Infinity.toLowerCase() !== "infinity") { + throw new Test262Error('#1: Number.prototype.toLowerCase = String.prototype.toLowerCase; Infinity.toLowerCase()=== "infinity". Actual: ' + Infinity.toLowerCase()); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T9.js new file mode 100644 index 0000000000..088479f931 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A1_T9.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase() +es5id: 15.5.4.16_A1_T9 +description: Call toLowerCase() function of string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +var __lowerCase = new String(__obj).toLowerCase(); + +var __expected = "undefined"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__lowerCase.length !== __expected.length) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLowerCase(); __expected ="undefined"; __lowerCase.length === __expected.length. Actual: ' + __lowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__lowerCase.index !== __expected.index) { + throw new Test262Error('#2: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLowerCase(); __expected ="undefined"; __lowerCase.index === __expected.index. Actual: ' + __lowerCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__lowerCase.input !== __expected.input) { + throw new Test262Error('#3: __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLowerCase(); __expected ="undefined"; __lowerCase.input === __expected.input. Actual: ' + __lowerCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__lowerCase[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {valueOf:function(){}, toString:void 0}; __lowerCase = new String(__obj).toLowerCase(); __expected ="undefined"; __lowerCase[' + index + ']===' + __expected[index] + '. Actual: ' + __lowerCase[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A2_T1.js new file mode 100644 index 0000000000..3985b12c0d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A2_T1.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.toLowerCase() return a string, but not a String object +es5id: 15.5.4.16_A2_T1 +description: Checking returned result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("Hello, WoRlD!".toLowerCase() !== "hello, world!") { + throw new Test262Error('#1: "Hello, WoRlD!".toLowerCase() === "hello, world!". Actual: ' + ("Hello, WoRlD!".toLowerCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if ("Hello, WoRlD!".toLowerCase() !== String("hello, world!")) { + throw new Test262Error('#2: "Hello, WoRlD!".toLowerCase() === String("hello, world!"). Actual: ' + ("Hello, WoRlD!".toLowerCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if ("Hello, WoRlD!".toLowerCase() === new String("hello, world!")) { + throw new Test262Error('#3: "Hello, WoRlD!".toLowerCase() !== new String("hello, world!")'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A6.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A6.js new file mode 100644 index 0000000000..00240423bf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toLowerCase has not prototype property +es5id: 15.5.4.16_A6 +description: Checking String.prototype.toLowerCase.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.toLowerCase.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.toLowerCase.prototype === undefined. Actual: ' + String.prototype.toLowerCase.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A7.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A7.js new file mode 100644 index 0000000000..398c46d58c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A7.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.toLowerCase can't be used as constructor +es5id: 15.5.4.16_A7 +description: Checking if creating the String.prototype.toLowerCase object fails +---*/ + +var __FACTORY = String.prototype.toLowerCase; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: var __FACTORY = String.prototype.toLowerCase; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.1: var __FACTORY = String.prototype.toLowerCase; "__instance = new __FACTORY" throws a TypeError. Actual: ' + (e)); + } +}; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A8.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A8.js new file mode 100644 index 0000000000..2de059b88b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A8.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: | + The String.prototype.toLowerCase.length property has the attribute + DontEnum +es5id: 15.5.4.16_A8 +description: > + Checking if enumerating the String.prototype.toLowerCase.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toLowerCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toLowerCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.toLowerCase.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.toLowerCase.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.toLowerCase) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.toLowerCase){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A9.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A9.js new file mode 100644 index 0000000000..ef8e3382e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/S15.5.4.16_A9.js @@ -0,0 +1,38 @@ +// 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.toLowerCase.length property does not have the + attribute DontDelete +es5id: 15.5.4.16_A9 +description: > + Checking if deleting the String.prototype.toLowerCase.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toLowerCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toLowerCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.toLowerCase.length) { + throw new Test262Error('#1: delete String.prototype.toLowerCase.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toLowerCase.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.toLowerCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/browser.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/name.js new file mode 100644 index 0000000000..48f9222ed5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/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.22 +description: > + String.prototype.toLowerCase.name is "toLowerCase". +info: | + String.prototype.toLowerCase ( ) + + 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.toLowerCase.name, "toLowerCase"); + +verifyNotEnumerable(String.prototype.toLowerCase, "name"); +verifyNotWritable(String.prototype.toLowerCase, "name"); +verifyConfigurable(String.prototype.toLowerCase, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/not-a-constructor.js new file mode 100644 index 0000000000..e9d92daf54 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/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.toLowerCase 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.toLowerCase), + false, + 'isConstructor(String.prototype.toLowerCase) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.toLowerCase(); +}, '`new String.prototype.toLowerCase()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/shell.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/special_casing.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/special_casing.js new file mode 100644 index 0000000000..7d0cf1ff16 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/special_casing.js @@ -0,0 +1,137 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Check if String.prototype.toLowerCase supports mappings defined in SpecialCasings +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +es5id: 15.5.4.16 +es6id: 21.1.3.22 +---*/ + +// SpecialCasing.txt, except for conditional mappings. + +assert.sameValue("\u00DF".toLowerCase(), "\u00DF", "LATIN SMALL LETTER SHARP S"); + +assert.sameValue("\u0130".toLowerCase(), "\u0069\u0307", "LATIN CAPITAL LETTER I WITH DOT ABOVE"); + +assert.sameValue("\uFB00".toLowerCase(), "\uFB00", "LATIN SMALL LIGATURE FF"); +assert.sameValue("\uFB01".toLowerCase(), "\uFB01", "LATIN SMALL LIGATURE FI"); +assert.sameValue("\uFB02".toLowerCase(), "\uFB02", "LATIN SMALL LIGATURE FL"); +assert.sameValue("\uFB03".toLowerCase(), "\uFB03", "LATIN SMALL LIGATURE FFI"); +assert.sameValue("\uFB04".toLowerCase(), "\uFB04", "LATIN SMALL LIGATURE FFL"); +assert.sameValue("\uFB05".toLowerCase(), "\uFB05", "LATIN SMALL LIGATURE LONG S T"); +assert.sameValue("\uFB06".toLowerCase(), "\uFB06", "LATIN SMALL LIGATURE ST"); + +assert.sameValue("\u0587".toLowerCase(), "\u0587", "ARMENIAN SMALL LIGATURE ECH YIWN"); +assert.sameValue("\uFB13".toLowerCase(), "\uFB13", "ARMENIAN SMALL LIGATURE MEN NOW"); +assert.sameValue("\uFB14".toLowerCase(), "\uFB14", "ARMENIAN SMALL LIGATURE MEN ECH"); +assert.sameValue("\uFB15".toLowerCase(), "\uFB15", "ARMENIAN SMALL LIGATURE MEN INI"); +assert.sameValue("\uFB16".toLowerCase(), "\uFB16", "ARMENIAN SMALL LIGATURE VEW NOW"); +assert.sameValue("\uFB17".toLowerCase(), "\uFB17", "ARMENIAN SMALL LIGATURE MEN XEH"); + +assert.sameValue("\u0149".toLowerCase(), "\u0149", "LATIN SMALL LETTER N PRECEDED BY APOSTROPHE"); + +assert.sameValue("\u0390".toLowerCase(), "\u0390", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS"); +assert.sameValue("\u03B0".toLowerCase(), "\u03B0", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS"); + +assert.sameValue("\u01F0".toLowerCase(), "\u01F0", "LATIN SMALL LETTER J WITH CARON"); +assert.sameValue("\u1E96".toLowerCase(), "\u1E96", "LATIN SMALL LETTER H WITH LINE BELOW"); +assert.sameValue("\u1E97".toLowerCase(), "\u1E97", "LATIN SMALL LETTER T WITH DIAERESIS"); +assert.sameValue("\u1E98".toLowerCase(), "\u1E98", "LATIN SMALL LETTER W WITH RING ABOVE"); +assert.sameValue("\u1E99".toLowerCase(), "\u1E99", "LATIN SMALL LETTER Y WITH RING ABOVE"); +assert.sameValue("\u1E9A".toLowerCase(), "\u1E9A", "LATIN SMALL LETTER A WITH RIGHT HALF RING"); + +assert.sameValue("\u1F50".toLowerCase(), "\u1F50", "GREEK SMALL LETTER UPSILON WITH PSILI"); +assert.sameValue("\u1F52".toLowerCase(), "\u1F52", "GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA"); +assert.sameValue("\u1F54".toLowerCase(), "\u1F54", "GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA"); +assert.sameValue("\u1F56".toLowerCase(), "\u1F56", "GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI"); +assert.sameValue("\u1FB6".toLowerCase(), "\u1FB6", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI"); +assert.sameValue("\u1FC6".toLowerCase(), "\u1FC6", "GREEK SMALL LETTER ETA WITH PERISPOMENI"); +assert.sameValue("\u1FD2".toLowerCase(), "\u1FD2", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FD3".toLowerCase(), "\u1FD3", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FD6".toLowerCase(), "\u1FD6", "GREEK SMALL LETTER IOTA WITH PERISPOMENI"); +assert.sameValue("\u1FD7".toLowerCase(), "\u1FD7", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FE2".toLowerCase(), "\u1FE2", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FE3".toLowerCase(), "\u1FE3", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FE4".toLowerCase(), "\u1FE4", "GREEK SMALL LETTER RHO WITH PSILI"); +assert.sameValue("\u1FE6".toLowerCase(), "\u1FE6", "GREEK SMALL LETTER UPSILON WITH PERISPOMENI"); +assert.sameValue("\u1FE7".toLowerCase(), "\u1FE7", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FF6".toLowerCase(), "\u1FF6", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI"); + +assert.sameValue("\u1F80".toLowerCase(), "\u1F80", "GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F81".toLowerCase(), "\u1F81", "GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F82".toLowerCase(), "\u1F82", "GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F83".toLowerCase(), "\u1F83", "GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F84".toLowerCase(), "\u1F84", "GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F85".toLowerCase(), "\u1F85", "GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F86".toLowerCase(), "\u1F86", "GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F87".toLowerCase(), "\u1F87", "GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F88".toLowerCase(), "\u1F80", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F89".toLowerCase(), "\u1F81", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8A".toLowerCase(), "\u1F82", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8B".toLowerCase(), "\u1F83", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8C".toLowerCase(), "\u1F84", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8D".toLowerCase(), "\u1F85", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8E".toLowerCase(), "\u1F86", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8F".toLowerCase(), "\u1F87", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1F90".toLowerCase(), "\u1F90", "GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F91".toLowerCase(), "\u1F91", "GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F92".toLowerCase(), "\u1F92", "GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F93".toLowerCase(), "\u1F93", "GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F94".toLowerCase(), "\u1F94", "GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F95".toLowerCase(), "\u1F95", "GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F96".toLowerCase(), "\u1F96", "GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F97".toLowerCase(), "\u1F97", "GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F98".toLowerCase(), "\u1F90", "GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F99".toLowerCase(), "\u1F91", "GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9A".toLowerCase(), "\u1F92", "GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9B".toLowerCase(), "\u1F93", "GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9C".toLowerCase(), "\u1F94", "GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9D".toLowerCase(), "\u1F95", "GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9E".toLowerCase(), "\u1F96", "GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9F".toLowerCase(), "\u1F97", "GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FA0".toLowerCase(), "\u1FA0", "GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA1".toLowerCase(), "\u1FA1", "GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA2".toLowerCase(), "\u1FA2", "GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA3".toLowerCase(), "\u1FA3", "GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA4".toLowerCase(), "\u1FA4", "GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA5".toLowerCase(), "\u1FA5", "GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA6".toLowerCase(), "\u1FA6", "GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA7".toLowerCase(), "\u1FA7", "GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FA8".toLowerCase(), "\u1FA0", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FA9".toLowerCase(), "\u1FA1", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAA".toLowerCase(), "\u1FA2", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAB".toLowerCase(), "\u1FA3", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAC".toLowerCase(), "\u1FA4", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAD".toLowerCase(), "\u1FA5", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAE".toLowerCase(), "\u1FA6", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAF".toLowerCase(), "\u1FA7", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FB3".toLowerCase(), "\u1FB3", "GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FBC".toLowerCase(), "\u1FB3", "GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FC3".toLowerCase(), "\u1FC3", "GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FCC".toLowerCase(), "\u1FC3", "GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FF3".toLowerCase(), "\u1FF3", "GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FFC".toLowerCase(), "\u1FF3", "GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI"); + +assert.sameValue("\u1FB2".toLowerCase(), "\u1FB2", "GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FB4".toLowerCase(), "\u1FB4", "GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC2".toLowerCase(), "\u1FC2", "GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC4".toLowerCase(), "\u1FC4", "GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF2".toLowerCase(), "\u1FF2", "GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF4".toLowerCase(), "\u1FF4", "GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FB7".toLowerCase(), "\u1FB7", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC7".toLowerCase(), "\u1FC7", "GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF7".toLowerCase(), "\u1FF7", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/special_casing_conditional.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/special_casing_conditional.js new file mode 100644 index 0000000000..8356bbe54e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/special_casing_conditional.js @@ -0,0 +1,103 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Check if String.prototype.toLowerCase supports conditional mappings defined in SpecialCasings +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +es5id: 15.5.4.16 +es6id: 21.1.3.22 +---*/ + +// SpecialCasing.txt, conditional, language-insensitive mappings. + +// <code>; <lower>; <title>; <upper>; (<condition_list>;)? # <comment> +// 03A3; 03C2; 03A3; 03A3; Final_Sigma; # GREEK CAPITAL LETTER SIGMA +// 03A3; 03C3; 03A3; 03A3; # GREEK CAPITAL LETTER SIGMA + +// Final_Sigma is defined in Unicode 5.1, 3.13 Default Case Algorithms. + +assert.sameValue( + "\u03A3".toLowerCase(), + "\u03C3", + "Single GREEK CAPITAL LETTER SIGMA" +); + +// Sigma preceded by Cased and zero or more Case_Ignorable. +assert.sameValue( + "A\u03A3".toLowerCase(), + "a\u03C2", + "Sigma preceded by LATIN CAPITAL LETTER A" +); +assert.sameValue( + "\uD835\uDCA2\u03A3".toLowerCase(), + "\uD835\uDCA2\u03C2", + "Sigma preceded by MATHEMATICAL SCRIPT CAPITAL G (D835 DCA2 = 1D4A2)" +); +assert.sameValue( + "A.\u03A3".toLowerCase(), + "a.\u03C2", + "Sigma preceded by FULL STOP" +); +assert.sameValue( + "A\u00AD\u03A3".toLowerCase(), + "a\u00AD\u03C2", + "Sigma preceded by SOFT HYPHEN (00AD)" +); +assert.sameValue( + "A\uD834\uDE42\u03A3".toLowerCase(), + "a\uD834\uDE42\u03C2", + "Sigma preceded by COMBINING GREEK MUSICAL TRISEME (D834 DE42 = 1D242)" +); +assert.sameValue( + "\u0345\u03A3".toLowerCase(), + "\u0345\u03C3", + "Sigma preceded by COMBINING GREEK YPOGEGRAMMENI (0345)" +); +assert.sameValue( + "\u0391\u0345\u03A3".toLowerCase(), + "\u03B1\u0345\u03C2", + "Sigma preceded by GREEK CAPITAL LETTER ALPHA (0391), COMBINING GREEK YPOGEGRAMMENI (0345)" +); + +// Sigma not followed by zero or more Case_Ignorable and then Cased. +assert.sameValue( + "A\u03A3B".toLowerCase(), + "a\u03C3b", + "Sigma followed by LATIN CAPITAL LETTER B" +); +assert.sameValue( + "A\u03A3\uD835\uDCA2".toLowerCase(), + "a\u03C3\uD835\uDCA2", + "Sigma followed by MATHEMATICAL SCRIPT CAPITAL G (D835 DCA2 = 1D4A2)" +); +assert.sameValue( + "A\u03A3.b".toLowerCase(), + "a\u03C3.b", + "Sigma followed by FULL STOP" +); +assert.sameValue( + "A\u03A3\u00ADB".toLowerCase(), + "a\u03C3\u00ADb", + "Sigma followed by SOFT HYPHEN (00AD)" +); +assert.sameValue( + "A\u03A3\uD834\uDE42B".toLowerCase(), + "a\u03C3\uD834\uDE42b", + "Sigma followed by COMBINING GREEK MUSICAL TRISEME (D834 DE42 = 1D242)" +); +assert.sameValue( + "A\u03A3\u0345".toLowerCase(), + "a\u03C2\u0345", + "Sigma followed by COMBINING GREEK YPOGEGRAMMENI (0345)" +); +assert.sameValue( + "A\u03A3\u0345\u0391".toLowerCase(), + "a\u03C3\u0345\u03B1", + "Sigma followed by COMBINING GREEK YPOGEGRAMMENI (0345), GREEK CAPITAL LETTER ALPHA (0391)" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/supplementary_plane.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/supplementary_plane.js new file mode 100644 index 0000000000..f1d7ece31f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/supplementary_plane.js @@ -0,0 +1,59 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: String.prototype.toLowerCase() iterates over code points +info: | + 21.1.3.22 String.prototype.toLowerCase ( ) + + ... + 4. Let cpList be a List containing in order the code points as defined in + 6.1.4 of S, starting at the first element of S. + 5. For each code point c in cpList, if the Unicode Character Database + provides a language insensitive lower case equivalent of c then replace + c in cpList with that equivalent code point(s). +es6id: 21.1.3.22 +---*/ + +assert.sameValue("\uD801\uDC00".toLowerCase(), "\uD801\uDC28", "DESERET CAPITAL LETTER LONG I"); +assert.sameValue("\uD801\uDC01".toLowerCase(), "\uD801\uDC29", "DESERET CAPITAL LETTER LONG E"); +assert.sameValue("\uD801\uDC02".toLowerCase(), "\uD801\uDC2A", "DESERET CAPITAL LETTER LONG A"); +assert.sameValue("\uD801\uDC03".toLowerCase(), "\uD801\uDC2B", "DESERET CAPITAL LETTER LONG AH"); +assert.sameValue("\uD801\uDC04".toLowerCase(), "\uD801\uDC2C", "DESERET CAPITAL LETTER LONG O"); +assert.sameValue("\uD801\uDC05".toLowerCase(), "\uD801\uDC2D", "DESERET CAPITAL LETTER LONG OO"); +assert.sameValue("\uD801\uDC06".toLowerCase(), "\uD801\uDC2E", "DESERET CAPITAL LETTER SHORT I"); +assert.sameValue("\uD801\uDC07".toLowerCase(), "\uD801\uDC2F", "DESERET CAPITAL LETTER SHORT E"); +assert.sameValue("\uD801\uDC08".toLowerCase(), "\uD801\uDC30", "DESERET CAPITAL LETTER SHORT A"); +assert.sameValue("\uD801\uDC09".toLowerCase(), "\uD801\uDC31", "DESERET CAPITAL LETTER SHORT AH"); +assert.sameValue("\uD801\uDC0A".toLowerCase(), "\uD801\uDC32", "DESERET CAPITAL LETTER SHORT O"); +assert.sameValue("\uD801\uDC0B".toLowerCase(), "\uD801\uDC33", "DESERET CAPITAL LETTER SHORT OO"); +assert.sameValue("\uD801\uDC0C".toLowerCase(), "\uD801\uDC34", "DESERET CAPITAL LETTER AY"); +assert.sameValue("\uD801\uDC0D".toLowerCase(), "\uD801\uDC35", "DESERET CAPITAL LETTER OW"); +assert.sameValue("\uD801\uDC0E".toLowerCase(), "\uD801\uDC36", "DESERET CAPITAL LETTER WU"); +assert.sameValue("\uD801\uDC0F".toLowerCase(), "\uD801\uDC37", "DESERET CAPITAL LETTER YEE"); +assert.sameValue("\uD801\uDC10".toLowerCase(), "\uD801\uDC38", "DESERET CAPITAL LETTER H"); +assert.sameValue("\uD801\uDC11".toLowerCase(), "\uD801\uDC39", "DESERET CAPITAL LETTER PEE"); +assert.sameValue("\uD801\uDC12".toLowerCase(), "\uD801\uDC3A", "DESERET CAPITAL LETTER BEE"); +assert.sameValue("\uD801\uDC13".toLowerCase(), "\uD801\uDC3B", "DESERET CAPITAL LETTER TEE"); +assert.sameValue("\uD801\uDC14".toLowerCase(), "\uD801\uDC3C", "DESERET CAPITAL LETTER DEE"); +assert.sameValue("\uD801\uDC15".toLowerCase(), "\uD801\uDC3D", "DESERET CAPITAL LETTER CHEE"); +assert.sameValue("\uD801\uDC16".toLowerCase(), "\uD801\uDC3E", "DESERET CAPITAL LETTER JEE"); +assert.sameValue("\uD801\uDC17".toLowerCase(), "\uD801\uDC3F", "DESERET CAPITAL LETTER KAY"); +assert.sameValue("\uD801\uDC18".toLowerCase(), "\uD801\uDC40", "DESERET CAPITAL LETTER GAY"); +assert.sameValue("\uD801\uDC19".toLowerCase(), "\uD801\uDC41", "DESERET CAPITAL LETTER EF"); +assert.sameValue("\uD801\uDC1A".toLowerCase(), "\uD801\uDC42", "DESERET CAPITAL LETTER VEE"); +assert.sameValue("\uD801\uDC1B".toLowerCase(), "\uD801\uDC43", "DESERET CAPITAL LETTER ETH"); +assert.sameValue("\uD801\uDC1C".toLowerCase(), "\uD801\uDC44", "DESERET CAPITAL LETTER THEE"); +assert.sameValue("\uD801\uDC1D".toLowerCase(), "\uD801\uDC45", "DESERET CAPITAL LETTER ES"); +assert.sameValue("\uD801\uDC1E".toLowerCase(), "\uD801\uDC46", "DESERET CAPITAL LETTER ZEE"); +assert.sameValue("\uD801\uDC1F".toLowerCase(), "\uD801\uDC47", "DESERET CAPITAL LETTER ESH"); +assert.sameValue("\uD801\uDC20".toLowerCase(), "\uD801\uDC48", "DESERET CAPITAL LETTER ZHEE"); +assert.sameValue("\uD801\uDC21".toLowerCase(), "\uD801\uDC49", "DESERET CAPITAL LETTER ER"); +assert.sameValue("\uD801\uDC22".toLowerCase(), "\uD801\uDC4A", "DESERET CAPITAL LETTER EL"); +assert.sameValue("\uD801\uDC23".toLowerCase(), "\uD801\uDC4B", "DESERET CAPITAL LETTER EM"); +assert.sameValue("\uD801\uDC24".toLowerCase(), "\uD801\uDC4C", "DESERET CAPITAL LETTER EN"); +assert.sameValue("\uD801\uDC25".toLowerCase(), "\uD801\uDC4D", "DESERET CAPITAL LETTER ENG"); +assert.sameValue("\uD801\uDC26".toLowerCase(), "\uD801\uDC4E", "DESERET CAPITAL LETTER OI"); +assert.sameValue("\uD801\uDC27".toLowerCase(), "\uD801\uDC4F", "DESERET CAPITAL LETTER EW"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toLowerCase/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..454eb79544 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toLowerCase/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.tolowercase +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toLowerCase = String.prototype.toLowerCase; + +assert.sameValue(typeof toLowerCase, 'function'); + +assert.throws(TypeError, function() { + toLowerCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toLowerCase.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/browser.js b/js/src/tests/test262/built-ins/String/prototype/toString/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/length.js b/js/src/tests/test262/built-ins/String/prototype/toString/length.js new file mode 100644 index 0000000000..ba4b6fa655 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/length.js @@ -0,0 +1,29 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tostring +description: > + String.prototype.toString.length is 0. +info: | + ECMAScript Standard Built-in Objects + ... + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + ... + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype.toString, 'length', { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/name.js b/js/src/tests/test262/built-ins/String/prototype/toString/name.js new file mode 100644 index 0000000000..bd3891423d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tostring +description: > + String.prototype.toString.name is "toString". +info: | + String.prototype.toString ( ) + + 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] +---*/ + +verifyProperty(String.prototype.toString, 'name', { + value: 'toString', + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/non-generic-realm.js b/js/src/tests/test262/built-ins/String/prototype/toString/non-generic-realm.js new file mode 100644 index 0000000000..4f27e3528e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/non-generic-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tostring +description: > + Throws a TypeError if called on neither String primitive nor String object + (honoring the Realm of the current execution context) +info: | + String.prototype.toString ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + [...] + 3. Throw a TypeError exception. +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var otherToString = other.String.prototype.toString; + +assert.throws(other.TypeError, function() { + otherToString.call(true); +}); + +assert.throws(other.TypeError, function() { + otherToString.call(0); +}); + +assert.throws(other.TypeError, function() { + otherToString.call(null); +}); + +assert.throws(other.TypeError, function() { + otherToString.call(); +}); + +assert.throws(other.TypeError, function() { + otherToString.call(Symbol('desc')); +}); + +assert.throws(other.TypeError, function() { + otherToString.call({ + valueOf: function() { + return 'str'; + }, + }); +}); + +assert.throws(other.TypeError, function() { + otherToString.call([1]); +}); + +assert.throws(other.TypeError, function() { + 'str'.concat({toString: otherToString}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/non-generic.js b/js/src/tests/test262/built-ins/String/prototype/toString/non-generic.js new file mode 100644 index 0000000000..1a78132963 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/non-generic.js @@ -0,0 +1,57 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tostring +description: > + Throws a TypeError if called on neither String primitive nor String object +info: | + String.prototype.toString ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + [...] + 3. Throw a TypeError exception. +---*/ + +var toString = String.prototype.toString; + +assert.throws(TypeError, function() { + toString.call(false); +}); + +assert.throws(TypeError, function() { + toString.call(1); +}); + +assert.throws(TypeError, function() { + toString.call(null); +}); + +assert.throws(TypeError, function() { + toString.call(); +}); + +assert.throws(TypeError, function() { + toString.call(Symbol('desc')); +}); + +assert.throws(TypeError, function() { + toString.call({ + toString: function() { + return 'str'; + }, + }); +}); + +assert.throws(TypeError, function() { + toString.call(['s', 't', 'r']); +}); + +assert.throws(TypeError, function() { + ''.concat({toString: toString}); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toString/not-a-constructor.js new file mode 100644 index 0000000000..59cdfc18e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/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.toString 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.toString), + false, + 'isConstructor(String.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.toString(); +}, '`new String.prototype.toString()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/shell.js b/js/src/tests/test262/built-ins/String/prototype/toString/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/string-object.js b/js/src/tests/test262/built-ins/String/prototype/toString/string-object.js new file mode 100644 index 0000000000..834a4f41b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/string-object.js @@ -0,0 +1,28 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tostring +description: > + If called on a String object, returns [[StringData]] slot +info: | + String.prototype.toString ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + [...] + 2. If Type(value) is Object and value has a [[StringData]] internal slot, then + a. Let s be value.[[StringData]]. + b. Assert: Type(s) is String. + c. Return s. +---*/ + +var toString = String.prototype.toString; + +assert.sameValue(Object('str').toString(), 'str'); +assert.sameValue(toString.call(new String('')), ''); +assert.sameValue('a'.concat(Object('b')), 'ab'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toString/string-primitive.js b/js/src/tests/test262/built-ins/String/prototype/toString/string-primitive.js new file mode 100644 index 0000000000..18ce6eb295 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toString/string-primitive.js @@ -0,0 +1,23 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.tostring +description: > + If called on String primitive, returns it +info: | + String.prototype.toString ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + 1. If Type(value) is String, return value. +---*/ + +var toString = String.prototype.toString; + +assert.sameValue(''.toString(), ''); +assert.sameValue(toString.call('str'), 'str'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A10.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A10.js new file mode 100644 index 0000000000..4924ada0a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A10.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.toUpperCase.length property has the attribute + ReadOnly +es5id: 15.5.4.18_A10 +description: > + Checking if varying the String.prototype.toUpperCase.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toUpperCase.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.toUpperCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.toUpperCase.length; + +verifyNotWritable(String.prototype.toUpperCase, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toUpperCase.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.toUpperCase.length; String.prototype.toUpperCase.length = function(){return "shifted";}; String.prototype.toUpperCase.length === __obj. Actual: ' + String.prototype.toUpperCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A11.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A11.js new file mode 100644 index 0000000000..4dfabc024d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A11.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 length property of the toUpperCase method is 0 +es5id: 15.5.4.18_A11 +description: Checking String.prototype.toUpperCase.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.toUpperCase.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.toUpperCase.hasOwnProperty("length") return true. Actual: ' + String.prototype.toUpperCase.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toUpperCase.length !== 0) { + throw new Test262Error('#2: String.prototype.toUpperCase.length === 0. Actual: ' + String.prototype.toUpperCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T1.js new file mode 100644 index 0000000000..6d4f92ae0f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T1 +description: Arguments is true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.toUpperCase = String.prototype.toUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toUpperCase() !== "TRUE") { + throw new Test262Error('#1: __instance = new Object(true); __instance.toUpperCase = String.prototype.toUpperCase; __instance.toUpperCase() === "TRUE". Actual: ' + __instance.toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T10.js new file mode 100644 index 0000000000..d978fb60b2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T10.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.toUpperCase() +es5id: 15.5.4.18_A1_T10 +description: > + Call toUpperCase() function of object with overrode toString + function +---*/ + +var __obj = { + toString: function() { + return "\u0041b"; + } +} +__obj.toUpperCase = String.prototype.toUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toUpperCase() !== "AB") { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041b";}}; __obj.toUpperCase = String.prototype.toUpperCase; __obj.toUpperCase() ==="AB". Actual: ' + __obj.toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T11.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T11.js new file mode 100644 index 0000000000..055b0d632e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T11.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.toUpperCase() +es5id: 15.5.4.18_A1_T11 +description: > + Override toString function, toString throw exception, then call + toUpperCase() function for this object +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +} +__obj.toUpperCase = String.prototype.toUpperCase; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toUpperCase(); + throw new Test262Error('#1: "var x = __obj.toUpperCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T12.js new file mode 100644 index 0000000000..71d08bb170 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T12.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.toUpperCase() +es5id: 15.5.4.18_A1_T12 +description: > + Override toString and valueOf functions, valueOf throw exception, + then call toUpperCase() function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +} +__obj.toUpperCase = String.prototype.toUpperCase; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __obj.toUpperCase(); + throw new Test262Error('#1: "var x = __obj.toUpperCase()" lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T13.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T13.js new file mode 100644 index 0000000000..233416cc02 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T13.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T13 +description: > + Override toString and valueOf functions, then call toUpperCase() + function for this object +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + return 1; + } +} +__obj.toUpperCase = String.prototype.toUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__obj.toUpperCase() !== "1") { + throw new Test262Error('#1: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toUpperCase = String.prototype.toUpperCase; __obj.toUpperCase() ==="1". Actual: ' + __obj.toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__obj.toUpperCase().length !== 1) { + throw new Test262Error('#2: var __obj = {toString:function(){return {};},valueOf:function(){return 1;}}; __obj.toUpperCase = String.prototype.toUpperCase; __obj.toUpperCase().length === 1. Actual: ' + __obj.toUpperCase().length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T14.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T14.js new file mode 100644 index 0000000000..51048d5ba2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T14.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T14 +description: Call toUpperCase() function of RegExp object +---*/ + +var __reg = new RegExp("abc"); +__reg.toUpperCase = String.prototype.toUpperCase; +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__reg.toUpperCase() !== "/ABC/") { + throw new Test262Error('#1: var __reg = new RegExp("abc"); __reg.toUpperCase = String.prototype.toUpperCase; __reg.toUpperCase() === "/ABC/". Actual: ' + __reg.toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T2.js new file mode 100644 index 0000000000..e1ab874b41 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T2.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T2 +description: Instance is Boolean object +---*/ + +var __instance = new Boolean; + +__instance.toUpperCase = String.prototype.toUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.toUpperCase() !== "FALSE") { + throw new Test262Error('#1: __instance = new Boolean; __instance.toUpperCase = String.prototype.toUpperCase; __instance.toUpperCase() === "FALSE". Actual: ' + __instance.toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T3.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T3.js new file mode 100644 index 0000000000..0b4ed555f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T3.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T3 +description: Checking by using eval +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (eval("\"bj\"").toUpperCase() !== "BJ") { + throw new Test262Error('#1: eval("\\"bj\\"").toUpperCase() === "BJ". Actual: ' + eval("\"bj\"").toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T4.js new file mode 100644 index 0000000000..1de632e61d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T4.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.toUpperCase() +es5id: 15.5.4.18_A1_T4 +description: > + Call toUpperCase() function without arguments of string and from + empty string +---*/ + +var __lowerCase = "".toUpperCase(); + +var __expected = ""; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__lowerCase.length !== __expected.length) { + throw new Test262Error('#1: __lowerCase = "".toUpperCase(); __expected = ""; __lowerCase.length === __expected.length. Actual: ' + __lowerCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__lowerCase.index !== __expected.index) { + throw new Test262Error('#2: __lowerCase = "".toUpperCase(); __expected = ""; __lowerCase.index === __expected.index. Actual: ' + __lowerCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__lowerCase.input !== __expected.input) { + throw new Test262Error('#3: __lowerCase = "".toUpperCase(); __expected = ""; __lowerCase.input === __expected.input. Actual: ' + __lowerCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +if (__lowerCase[0] !== __expected[0]) { + throw new Test262Error('#4: __lowerCase = "".toUpperCase(); __expected = ""; __lowerCase[0]===' + __expected[0] + '. Actual: ' + __lowerCase[0]); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T5.js new file mode 100644 index 0000000000..0e9e30fcb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T5.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T5 +description: Call toUpperCase() function of function call +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" match(null) evaluates to match("null") +if (function() { + return "GnulLuNa" + }().toUpperCase() !== "GNULLUNA") { + throw new Test262Error('#1: function(){return "GnulLuNa"}().toUpperCase() === "GNULLUNA". Actual: ' + function() { + return "GnulLuNa" + }().toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T6.js new file mode 100644 index 0000000000..9dd923681c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T6.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T6 +description: Call toUpperCase() function of Number.NEGATIVE_INFINITY +---*/ + +Number.prototype.toUpperCase = String.prototype.toUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ((Number.NEGATIVE_INFINITY).toUpperCase() !== "-INFINITY") { + throw new Test262Error('#1: Number.prototype.toUpperCase = String.prototype.toUpperCase; (Number.NEGATIVE_INFINITY).toUpperCase() === "-INFINITY". Actual: ' + (Number.NEGATIVE_INFINITY).toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T7.js new file mode 100644 index 0000000000..c7cf124363 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T7.js @@ -0,0 +1,20 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T7 +description: Call toUpperCase() function of NaN +---*/ + +Number.prototype.toUpperCase = String.prototype.toUpperCase; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (NaN.toUpperCase() !== "NAN") { + throw new Test262Error('#1: Number.prototype.toUpperCase = String.prototype.toUpperCase; NaN.toUpperCase()=== "NAN". Actual: ' + NaN.toUpperCase()); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T8.js new file mode 100644 index 0000000000..5ad34efd9c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T8.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.toUpperCase() +es5id: 15.5.4.18_A1_T8 +description: Call toUpperCase() function of Infinity; +---*/ + +Number.prototype.toUpperCase = String.prototype.toUpperCase; + +if (Infinity.toUpperCase() !== "INFINITY") { + throw new Test262Error('#1: Number.prototype.toUpperCase = String.prototype.toUpperCase; Infinity.toUpperCase()=== "INFINITY". Actual: ' + Infinity.toUpperCase()); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T9.js new file mode 100644 index 0000000000..be7e1feb12 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A1_T9.js @@ -0,0 +1,53 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase() +es5id: 15.5.4.18_A1_T9 +description: Call toUpperCase() function of string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +var __upperCase = new String(__obj).toUpperCase(); + +var __expected = "UNDEFINED"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__upperCase.length !== __expected.length) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; __upperCase = new String(__obj).toUpperCase(); __expected ="UNDEFINED"; __upperCase.length === __expected.length. Actual: ' + __upperCase.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__upperCase.index !== __expected.index) { + throw new Test262Error('#2: __obj = {valueOf:function(){}, toString:void 0}; __upperCase = new String(__obj).toUpperCase(); __expected ="UNDEFINED"; __upperCase.index === __expected.index. Actual: ' + __upperCase.index); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if (__upperCase.input !== __expected.input) { + throw new Test262Error('#3: __obj = {valueOf:function(){}, toString:void 0}; __upperCase = new String(__obj).toUpperCase(); __expected ="UNDEFINED"; __upperCase.input === __expected.input. Actual: ' + __upperCase.input); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#4 +for (var index = 0; index < __expected.length; index++) { + if (__upperCase[index] !== __expected[index]) { + throw new Test262Error('#4.' + index + ': __obj = {valueOf:function(){}, toString:void 0}; __upperCase = new String(__obj).toUpperCase(); __expected ="UNDEFINED"; __upperCase[' + index + ']===' + __expected[index] + '. Actual: ' + __upperCase[index]); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A2_T1.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A2_T1.js new file mode 100644 index 0000000000..3bc31c16c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A2_T1.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.toUpperCase() return a string, but not a String object +es5id: 15.5.4.18_A2_T1 +description: Checking returned result +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("Hello, WoRlD!".toUpperCase() !== "HELLO, WORLD!") { + throw new Test262Error('#1: "Hello, WoRlD!".toUpperCase() === "HELLO, WORLD!". Actual: ' + ("Hello, WoRlD!".toUpperCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if ("Hello, WoRlD!".toUpperCase() !== String("HELLO, WORLD!")) { + throw new Test262Error('#2: "Hello, WoRlD!".toUpperCase() === String("HELLO, WORLD!"). Actual: ' + ("Hello, WoRlD!".toUpperCase())); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#3 +if ("Hello, WoRlD!".toUpperCase() === new String("HELLO, WORLD!")) { + throw new Test262Error('#3: "Hello, WoRlD!".toUpperCase() !== new String("HELLO, WORLD!")'); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A6.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A6.js new file mode 100644 index 0000000000..d10a0c5625 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.toUpperCase has not prototype property +es5id: 15.5.4.18_A6 +description: Checking String.prototype.toUpperCase.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.toUpperCase.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.toUpperCase.prototype === undefined. Actual: ' + String.prototype.toUpperCase.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A7.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A7.js new file mode 100644 index 0000000000..b4f007741f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A7.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.toUpperCase can't be used as constructor +es5id: 15.5.4.18_A7 +description: Checking if creating the String.prototype.toUpperCase object fails +---*/ + +var __FACTORY = String.prototype.toUpperCase; + +try { + var __instance = new __FACTORY; + throw new Test262Error('#1: var __FACTORY = String.prototype.toUpperCase; "__instance = new __FACTORY" lead to throwing exception'); +} catch (e) { + if ((e instanceof TypeError) !== true) { + throw new Test262Error('#1.1: var __FACTORY = String.prototype.toUpperCase; "__instance = new __FACTORY" throw a TypeError. Actual: ' + (e)); + } +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A8.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A8.js new file mode 100644 index 0000000000..a44f896dc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A8.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: | + The String.prototype.toUpperCase.length property has the attribute + DontEnum +es5id: 15.5.4.18_A8 +description: > + Checking if enumerating the String.prototype.toUpperCase.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toUpperCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toUpperCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.toUpperCase.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.toUpperCase.propertyIsEnumerable(\'length\') return false'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.toUpperCase) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.toUpperCase){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A9.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A9.js new file mode 100644 index 0000000000..1da084fcf5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/S15.5.4.18_A9.js @@ -0,0 +1,38 @@ +// 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.toUpperCase.length property does not have the + attribute DontDelete +es5id: 15.5.4.18_A9 +description: > + Checking if deleting the String.prototype.toUpperCase.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.toUpperCase.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.toUpperCase.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.toUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.toUpperCase.length) { + throw new Test262Error('#1: delete String.prototype.toUpperCase.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.toUpperCase.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.toUpperCase.length; String.prototype.toUpperCase.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.toUpperCase.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/browser.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/name.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/name.js new file mode 100644 index 0000000000..9e2922beb0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/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.24 +description: > + String.prototype.toUpperCase.name is "toUpperCase". +info: | + String.prototype.toUpperCase ( ) + + 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.toUpperCase.name, "toUpperCase"); + +verifyNotEnumerable(String.prototype.toUpperCase, "name"); +verifyNotWritable(String.prototype.toUpperCase, "name"); +verifyConfigurable(String.prototype.toUpperCase, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/not-a-constructor.js new file mode 100644 index 0000000000..4820c87b12 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/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.toUpperCase 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.toUpperCase), + false, + 'isConstructor(String.prototype.toUpperCase) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.toUpperCase(); +}, '`new String.prototype.toUpperCase()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/shell.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/special_casing.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/special_casing.js new file mode 100644 index 0000000000..520b6b33e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/special_casing.js @@ -0,0 +1,137 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Check if String.prototype.toUpperCase supports mappings defined in SpecialCasings +info: | + The result must be derived according to the locale-insensitive case mappings in the Unicode Character + Database (this explicitly includes not only the UnicodeData.txt file, but also all locale-insensitive + mappings in the SpecialCasings.txt file that accompanies it). +es5id: 15.5.4.18 +es6id: 21.1.3.24 +---*/ + +// SpecialCasing.txt, except for conditional mappings. + +assert.sameValue("\u00DF".toUpperCase(), "\u0053\u0053", "LATIN SMALL LETTER SHARP S"); + +assert.sameValue("\u0130".toUpperCase(), "\u0130", "LATIN CAPITAL LETTER I WITH DOT ABOVE"); + +assert.sameValue("\uFB00".toUpperCase(), "\u0046\u0046", "LATIN SMALL LIGATURE FF"); +assert.sameValue("\uFB01".toUpperCase(), "\u0046\u0049", "LATIN SMALL LIGATURE FI"); +assert.sameValue("\uFB02".toUpperCase(), "\u0046\u004C", "LATIN SMALL LIGATURE FL"); +assert.sameValue("\uFB03".toUpperCase(), "\u0046\u0046\u0049", "LATIN SMALL LIGATURE FFI"); +assert.sameValue("\uFB04".toUpperCase(), "\u0046\u0046\u004C", "LATIN SMALL LIGATURE FFL"); +assert.sameValue("\uFB05".toUpperCase(), "\u0053\u0054", "LATIN SMALL LIGATURE LONG S T"); +assert.sameValue("\uFB06".toUpperCase(), "\u0053\u0054", "LATIN SMALL LIGATURE ST"); + +assert.sameValue("\u0587".toUpperCase(), "\u0535\u0552", "ARMENIAN SMALL LIGATURE ECH YIWN"); +assert.sameValue("\uFB13".toUpperCase(), "\u0544\u0546", "ARMENIAN SMALL LIGATURE MEN NOW"); +assert.sameValue("\uFB14".toUpperCase(), "\u0544\u0535", "ARMENIAN SMALL LIGATURE MEN ECH"); +assert.sameValue("\uFB15".toUpperCase(), "\u0544\u053B", "ARMENIAN SMALL LIGATURE MEN INI"); +assert.sameValue("\uFB16".toUpperCase(), "\u054E\u0546", "ARMENIAN SMALL LIGATURE VEW NOW"); +assert.sameValue("\uFB17".toUpperCase(), "\u0544\u053D", "ARMENIAN SMALL LIGATURE MEN XEH"); + +assert.sameValue("\u0149".toUpperCase(), "\u02BC\u004E", "LATIN SMALL LETTER N PRECEDED BY APOSTROPHE"); + +assert.sameValue("\u0390".toUpperCase(), "\u0399\u0308\u0301", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS"); +assert.sameValue("\u03B0".toUpperCase(), "\u03A5\u0308\u0301", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS"); + +assert.sameValue("\u01F0".toUpperCase(), "\u004A\u030C", "LATIN SMALL LETTER J WITH CARON"); +assert.sameValue("\u1E96".toUpperCase(), "\u0048\u0331", "LATIN SMALL LETTER H WITH LINE BELOW"); +assert.sameValue("\u1E97".toUpperCase(), "\u0054\u0308", "LATIN SMALL LETTER T WITH DIAERESIS"); +assert.sameValue("\u1E98".toUpperCase(), "\u0057\u030A", "LATIN SMALL LETTER W WITH RING ABOVE"); +assert.sameValue("\u1E99".toUpperCase(), "\u0059\u030A", "LATIN SMALL LETTER Y WITH RING ABOVE"); +assert.sameValue("\u1E9A".toUpperCase(), "\u0041\u02BE", "LATIN SMALL LETTER A WITH RIGHT HALF RING"); + +assert.sameValue("\u1F50".toUpperCase(), "\u03A5\u0313", "GREEK SMALL LETTER UPSILON WITH PSILI"); +assert.sameValue("\u1F52".toUpperCase(), "\u03A5\u0313\u0300", "GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA"); +assert.sameValue("\u1F54".toUpperCase(), "\u03A5\u0313\u0301", "GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA"); +assert.sameValue("\u1F56".toUpperCase(), "\u03A5\u0313\u0342", "GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI"); +assert.sameValue("\u1FB6".toUpperCase(), "\u0391\u0342", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI"); +assert.sameValue("\u1FC6".toUpperCase(), "\u0397\u0342", "GREEK SMALL LETTER ETA WITH PERISPOMENI"); +assert.sameValue("\u1FD2".toUpperCase(), "\u0399\u0308\u0300", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FD3".toUpperCase(), "\u0399\u0308\u0301", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FD6".toUpperCase(), "\u0399\u0342", "GREEK SMALL LETTER IOTA WITH PERISPOMENI"); +assert.sameValue("\u1FD7".toUpperCase(), "\u0399\u0308\u0342", "GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FE2".toUpperCase(), "\u03A5\u0308\u0300", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA"); +assert.sameValue("\u1FE3".toUpperCase(), "\u03A5\u0308\u0301", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA"); +assert.sameValue("\u1FE4".toUpperCase(), "\u03A1\u0313", "GREEK SMALL LETTER RHO WITH PSILI"); +assert.sameValue("\u1FE6".toUpperCase(), "\u03A5\u0342", "GREEK SMALL LETTER UPSILON WITH PERISPOMENI"); +assert.sameValue("\u1FE7".toUpperCase(), "\u03A5\u0308\u0342", "GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI"); +assert.sameValue("\u1FF6".toUpperCase(), "\u03A9\u0342", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI"); + +assert.sameValue("\u1F80".toUpperCase(), "\u1F08\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F81".toUpperCase(), "\u1F09\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F82".toUpperCase(), "\u1F0A\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F83".toUpperCase(), "\u1F0B\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F84".toUpperCase(), "\u1F0C\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F85".toUpperCase(), "\u1F0D\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F86".toUpperCase(), "\u1F0E\u0399", "GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F87".toUpperCase(), "\u1F0F\u0399", "GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F88".toUpperCase(), "\u1F08\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F89".toUpperCase(), "\u1F09\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8A".toUpperCase(), "\u1F0A\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8B".toUpperCase(), "\u1F0B\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8C".toUpperCase(), "\u1F0C\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8D".toUpperCase(), "\u1F0D\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8E".toUpperCase(), "\u1F0E\u0399", "GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F8F".toUpperCase(), "\u1F0F\u0399", "GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1F90".toUpperCase(), "\u1F28\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F91".toUpperCase(), "\u1F29\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F92".toUpperCase(), "\u1F2A\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F93".toUpperCase(), "\u1F2B\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F94".toUpperCase(), "\u1F2C\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F95".toUpperCase(), "\u1F2D\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1F96".toUpperCase(), "\u1F2E\u0399", "GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1F97".toUpperCase(), "\u1F2F\u0399", "GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1F98".toUpperCase(), "\u1F28\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F99".toUpperCase(), "\u1F29\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9A".toUpperCase(), "\u1F2A\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9B".toUpperCase(), "\u1F2B\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9C".toUpperCase(), "\u1F2C\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9D".toUpperCase(), "\u1F2D\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9E".toUpperCase(), "\u1F2E\u0399", "GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1F9F".toUpperCase(), "\u1F2F\u0399", "GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FA0".toUpperCase(), "\u1F68\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA1".toUpperCase(), "\u1F69\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA2".toUpperCase(), "\u1F6A\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA3".toUpperCase(), "\u1F6B\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA4".toUpperCase(), "\u1F6C\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA5".toUpperCase(), "\u1F6D\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA6".toUpperCase(), "\u1F6E\u0399", "GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FA7".toUpperCase(), "\u1F6F\u0399", "GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FA8".toUpperCase(), "\u1F68\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FA9".toUpperCase(), "\u1F69\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAA".toUpperCase(), "\u1F6A\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAB".toUpperCase(), "\u1F6B\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAC".toUpperCase(), "\u1F6C\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAD".toUpperCase(), "\u1F6D\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAE".toUpperCase(), "\u1F6E\u0399", "GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI"); +assert.sameValue("\u1FAF".toUpperCase(), "\u1F6F\u0399", "GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI"); + +assert.sameValue("\u1FB3".toUpperCase(), "\u0391\u0399", "GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FBC".toUpperCase(), "\u0391\u0399", "GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FC3".toUpperCase(), "\u0397\u0399", "GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FCC".toUpperCase(), "\u0397\u0399", "GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI"); +assert.sameValue("\u1FF3".toUpperCase(), "\u03A9\u0399", "GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI"); +assert.sameValue("\u1FFC".toUpperCase(), "\u03A9\u0399", "GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI"); + +assert.sameValue("\u1FB2".toUpperCase(), "\u1FBA\u0399", "GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FB4".toUpperCase(), "\u0386\u0399", "GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC2".toUpperCase(), "\u1FCA\u0399", "GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC4".toUpperCase(), "\u0389\u0399", "GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF2".toUpperCase(), "\u1FFA\u0399", "GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF4".toUpperCase(), "\u038F\u0399", "GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI"); + +assert.sameValue("\u1FB7".toUpperCase(), "\u0391\u0342\u0399", "GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FC7".toUpperCase(), "\u0397\u0342\u0399", "GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI"); +assert.sameValue("\u1FF7".toUpperCase(), "\u03A9\u0342\u0399", "GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/supplementary_plane.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/supplementary_plane.js new file mode 100644 index 0000000000..97859bd79e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/supplementary_plane.js @@ -0,0 +1,65 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: String.prototype.toUpperCase() iterates over code points +info: | + 21.1.3.24 String.prototype.toUpperCase ( ) + + This function behaves in exactly the same way as String.prototype.toLowerCase, + except that code points are mapped to their uppercase equivalents as specified + in the Unicode Character Database. + + 21.1.3.22 String.prototype.toLowerCase ( ) + + ... + 4. Let cpList be a List containing in order the code points as defined in + 6.1.4 of S, starting at the first element of S. + 5. For each code point c in cpList, if the Unicode Character Database + provides a language insensitive lower case equivalent of c then replace + c in cpList with that equivalent code point(s). +es6id: 21.1.3.24 +---*/ + +assert.sameValue("\uD801\uDC28".toUpperCase(), "\uD801\uDC00", "DESERET SMALL LETTER LONG I"); +assert.sameValue("\uD801\uDC29".toUpperCase(), "\uD801\uDC01", "DESERET SMALL LETTER LONG E"); +assert.sameValue("\uD801\uDC2A".toUpperCase(), "\uD801\uDC02", "DESERET SMALL LETTER LONG A"); +assert.sameValue("\uD801\uDC2B".toUpperCase(), "\uD801\uDC03", "DESERET SMALL LETTER LONG AH"); +assert.sameValue("\uD801\uDC2C".toUpperCase(), "\uD801\uDC04", "DESERET SMALL LETTER LONG O"); +assert.sameValue("\uD801\uDC2D".toUpperCase(), "\uD801\uDC05", "DESERET SMALL LETTER LONG OO"); +assert.sameValue("\uD801\uDC2E".toUpperCase(), "\uD801\uDC06", "DESERET SMALL LETTER SHORT I"); +assert.sameValue("\uD801\uDC2F".toUpperCase(), "\uD801\uDC07", "DESERET SMALL LETTER SHORT E"); +assert.sameValue("\uD801\uDC30".toUpperCase(), "\uD801\uDC08", "DESERET SMALL LETTER SHORT A"); +assert.sameValue("\uD801\uDC31".toUpperCase(), "\uD801\uDC09", "DESERET SMALL LETTER SHORT AH"); +assert.sameValue("\uD801\uDC32".toUpperCase(), "\uD801\uDC0A", "DESERET SMALL LETTER SHORT O"); +assert.sameValue("\uD801\uDC33".toUpperCase(), "\uD801\uDC0B", "DESERET SMALL LETTER SHORT OO"); +assert.sameValue("\uD801\uDC34".toUpperCase(), "\uD801\uDC0C", "DESERET SMALL LETTER AY"); +assert.sameValue("\uD801\uDC35".toUpperCase(), "\uD801\uDC0D", "DESERET SMALL LETTER OW"); +assert.sameValue("\uD801\uDC36".toUpperCase(), "\uD801\uDC0E", "DESERET SMALL LETTER WU"); +assert.sameValue("\uD801\uDC37".toUpperCase(), "\uD801\uDC0F", "DESERET SMALL LETTER YEE"); +assert.sameValue("\uD801\uDC38".toUpperCase(), "\uD801\uDC10", "DESERET SMALL LETTER H"); +assert.sameValue("\uD801\uDC39".toUpperCase(), "\uD801\uDC11", "DESERET SMALL LETTER PEE"); +assert.sameValue("\uD801\uDC3A".toUpperCase(), "\uD801\uDC12", "DESERET SMALL LETTER BEE"); +assert.sameValue("\uD801\uDC3B".toUpperCase(), "\uD801\uDC13", "DESERET SMALL LETTER TEE"); +assert.sameValue("\uD801\uDC3C".toUpperCase(), "\uD801\uDC14", "DESERET SMALL LETTER DEE"); +assert.sameValue("\uD801\uDC3D".toUpperCase(), "\uD801\uDC15", "DESERET SMALL LETTER CHEE"); +assert.sameValue("\uD801\uDC3E".toUpperCase(), "\uD801\uDC16", "DESERET SMALL LETTER JEE"); +assert.sameValue("\uD801\uDC3F".toUpperCase(), "\uD801\uDC17", "DESERET SMALL LETTER KAY"); +assert.sameValue("\uD801\uDC40".toUpperCase(), "\uD801\uDC18", "DESERET SMALL LETTER GAY"); +assert.sameValue("\uD801\uDC41".toUpperCase(), "\uD801\uDC19", "DESERET SMALL LETTER EF"); +assert.sameValue("\uD801\uDC42".toUpperCase(), "\uD801\uDC1A", "DESERET SMALL LETTER VEE"); +assert.sameValue("\uD801\uDC43".toUpperCase(), "\uD801\uDC1B", "DESERET SMALL LETTER ETH"); +assert.sameValue("\uD801\uDC44".toUpperCase(), "\uD801\uDC1C", "DESERET SMALL LETTER THEE"); +assert.sameValue("\uD801\uDC45".toUpperCase(), "\uD801\uDC1D", "DESERET SMALL LETTER ES"); +assert.sameValue("\uD801\uDC46".toUpperCase(), "\uD801\uDC1E", "DESERET SMALL LETTER ZEE"); +assert.sameValue("\uD801\uDC47".toUpperCase(), "\uD801\uDC1F", "DESERET SMALL LETTER ESH"); +assert.sameValue("\uD801\uDC48".toUpperCase(), "\uD801\uDC20", "DESERET SMALL LETTER ZHEE"); +assert.sameValue("\uD801\uDC49".toUpperCase(), "\uD801\uDC21", "DESERET SMALL LETTER ER"); +assert.sameValue("\uD801\uDC4A".toUpperCase(), "\uD801\uDC22", "DESERET SMALL LETTER EL"); +assert.sameValue("\uD801\uDC4B".toUpperCase(), "\uD801\uDC23", "DESERET SMALL LETTER EM"); +assert.sameValue("\uD801\uDC4C".toUpperCase(), "\uD801\uDC24", "DESERET SMALL LETTER EN"); +assert.sameValue("\uD801\uDC4D".toUpperCase(), "\uD801\uDC25", "DESERET SMALL LETTER ENG"); +assert.sameValue("\uD801\uDC4E".toUpperCase(), "\uD801\uDC26", "DESERET SMALL LETTER OI"); +assert.sameValue("\uD801\uDC4F".toUpperCase(), "\uD801\uDC27", "DESERET SMALL LETTER EW"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toUpperCase/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..3114095957 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toUpperCase/this-value-not-obj-coercible.js @@ -0,0 +1,28 @@ +// 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.touppercase +description: The "this" value must be object-coercible +info: | + This function behaves in exactly the same way as + String.prototype.toLowerCase, except that code points are mapped to their + uppercase equivalents as specified in the Unicode Character Database. + + 21.1.3.24 String.prototype.toLowerCase + + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var toUpperCase = String.prototype.toUpperCase; + +assert.sameValue(typeof toUpperCase, 'function'); + +assert.throws(TypeError, function() { + toUpperCase.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + toUpperCase.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/browser.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/length.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/length.js new file mode 100644 index 0000000000..8da16feb4e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/length.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.towellformed +description: > + String.prototype.toWellFormed.length value and descriptor. +info: | + String.prototype.toWellFormed( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.toWellFormed] +---*/ + +verifyProperty(String.prototype.toWellFormed, 'length', { + configurable: true, + enumerable: false, + writable: false, + value: 0 +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/name.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/name.js new file mode 100644 index 0000000000..f1befc1eea --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/name.js @@ -0,0 +1,24 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.towellformed +description: > + String.prototype.toWellFormed.name value and descriptor. +info: | + String.prototype.toWellFormed( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [String.prototype.toWellFormed] +---*/ + +verifyProperty(String.prototype.toWellFormed, 'name', { + enumerable: false, + writable: false, + configurable: true, + value: 'toWellFormed' +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/not-a-constructor.js new file mode 100644 index 0000000000..d8c64b85b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/not-a-constructor.js @@ -0,0 +1,35 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. 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.includes 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: [String.prototype.toWellFormed, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(String.prototype.toWellFormed), + false, + 'isConstructor(String.prototype.toWellFormed) must return false' +); + +assert.throws(TypeError, function () { + new String.prototype.toWellFormed(); +}, '`new String.prototype.toWellFormed()` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/prop-desc.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/prop-desc.js new file mode 100644 index 0000000000..c0217bd63f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/prop-desc.js @@ -0,0 +1,28 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.towellformed +description: > + Property type and descriptor. +info: | + String.prototype.toWellFormed( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [String.prototype.toWellFormed] +---*/ + +assert.sameValue( + typeof String.prototype.toWellFormed, + 'function', + 'The value of `typeof String.prototype.toWellFormed` is "function"' +); + +verifyProperty(String.prototype, 'toWellFormed', { + enumerable: false, + writable: true, + configurable: true +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js new file mode 100644 index 0000000000..7053c7cc42 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/return-abrupt-from-this.js @@ -0,0 +1,25 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.towellformed +description: > + Return abrupt from RequireObjectCoercible(this value). +info: | + String.prototype.toWellFormed( ) + + 1. Let O be ? RequireObjectCoercible(this value). + +features: [String.prototype.toWellFormed] +---*/ +assert.sameValue(typeof String.prototype.toWellFormed, 'function'); + +assert.throws(TypeError, function () { + String.prototype.toWellFormed.call(undefined); +}, '`String.prototype.toWellFormed.call(undefined)` throws TypeError'); + +assert.throws(TypeError, function () { + String.prototype.toWellFormed.call(null); +}, '`String.prototype.toWellFormed.call(null)` throws TypeError'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/returns-well-formed-string.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/returns-well-formed-string.js new file mode 100644 index 0000000000..df77f0c598 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/returns-well-formed-string.js @@ -0,0 +1,58 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.towellformed +description: > + The method should return a well-formed string. +info: | + String.prototype.toWellFormed ( ) + + 1. Let O be ? RequireObjectCoercible(this value). + 2. Let S be ? ToString(O). + 3. Let strLen be the length of S. + 4. Let k be 0. + 5. Let result be the empty String. + 6. Repeat, while k < strLen, + a. Let cp be CodePointAt(S, k). + b. If cp.[[IsUnpairedSurrogate]] is true, then + i. Set result to the string-concatenation of result and 0xFFFD (REPLACEMENT CHARACTER). + c. Else, + i. Set result to the string-concatenation of result and UTF16EncodeCodePoint(cp.[[CodePoint]]). + d. Set k to k + cp.[[CodeUnitCount]]. + 7. Return result. + +features: [String.prototype.toWellFormed] +---*/ +assert.sameValue(typeof String.prototype.toWellFormed, 'function'); + +var replacementChar = '\uFFFD'; +var leadingPoo = '\uD83D'; +var trailingPoo = '\uDCA9'; +var wholePoo = leadingPoo + trailingPoo; + +assert.sameValue( + ('a' + leadingPoo + 'c' + leadingPoo + 'e').toWellFormed(), + 'a' + replacementChar + 'c' + replacementChar + 'e', + 'lone leading surrogates are replaced with the expected replacement character' +); +assert.sameValue( + ('a' + trailingPoo + 'c' + trailingPoo + 'e').toWellFormed(), + 'a' + replacementChar + 'c' + replacementChar + 'e', + 'lone trailing surrogates are replaced with the expected replacement character' +); +assert.sameValue( + ('a' + trailingPoo + leadingPoo + 'd').toWellFormed(), + 'a' + replacementChar + replacementChar + 'd', + 'a wrong-ordered surrogate pair is replaced with two replacement characters' +) + +assert.sameValue('a💩c'.toWellFormed(), 'a💩c', 'a surrogate pair using a literal code point is already well-formed'); +assert.sameValue('a\uD83D\uDCA9c'.toWellFormed(), 'a\uD83D\uDCA9c', 'a surrogate pair formed by escape sequences is already well-formed'); +assert.sameValue(('a' + leadingPoo + trailingPoo + 'd').toWellFormed(), 'a' + wholePoo + 'd', 'a surrogate pair formed by concatenation is already well-formed'); +assert.sameValue(wholePoo.slice(0, 1).toWellFormed(), replacementChar, 'a surrogate pair sliced to the leading surrogate is replaced with the expected replacement character'); +assert.sameValue(wholePoo.slice(1).toWellFormed(), replacementChar, 'a surrogate pair sliced to the trailing surrogate is replaced with the expected replacement character'); +assert.sameValue('abc'.toWellFormed(), 'abc', 'a latin-1 string is already well-formed'); +assert.sameValue('a\u25A8c'.toWellFormed(), 'a\u25A8c', 'a string with a non-ASCII character is already well-formed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/shell.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/to-string-primitive.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/to-string-primitive.js new file mode 100644 index 0000000000..81584490b0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/to-string-primitive.js @@ -0,0 +1,35 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.towellformed +description: > + The method should coerce the receiver to a string. +info: | + String.prototype.toWellFormed ( ) + + 2. Let S be ? ToString(O). + … + +features: [String.prototype.toWellFormed] +---*/ + +const tests = [ + [true, "true", Boolean.prototype], + [1, "1", Number.prototype], + [1n, "1", BigInt.prototype], +]; + +for (const [v, expected, proto] of tests) { + proto.toString = function() { + throw new Test262Error(`should not call toString on the prototype for ${typeof v}`); + } + let result = String.prototype.toWellFormed.call(v); + delete proto.toString; + assert.sameValue(result, expected, `toWellFormed for ${typeof v}`); +} + +Symbol.prototype.toString = function() { throw new TypeError("should not call toString on the prototype for Symbol"); } +assert.throws(TypeError, () => String.prototype.toWellFormed.call(Symbol()), `Built-in result for Symbol`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/toWellFormed/to-string.js b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/to-string.js new file mode 100644 index 0000000000..200f9ccd16 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/toWellFormed/to-string.js @@ -0,0 +1,30 @@ +// |reftest| shell-option(--enable-well-formed-unicode-strings) skip-if(!String.prototype.toWellFormed||!xulRuntime.shell) -- String.prototype.toWellFormed is not enabled unconditionally, requires shell-options +// Copyright (C) 2022 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.towellformed +description: > + The method should coerce the receiver to a string. +info: | + String.prototype.toWellFormed ( ) + + 1. Let O be ? RequireObjectCoercible(this value). + 2. Let S be ? ToString(O). + … + +features: [String.prototype.toWellFormed] +---*/ + +var obj = { + toString: function () { + throw new Test262Error('calls ToString'); + } +}; + +assert.throws( + Test262Error, + function () { String.prototype.toWellFormed.call(obj); }, + 'coerces the receiver to a string' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-0-1.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-0-1.js new file mode 100644 index 0000000000..8356c795a6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-0-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-0-1 +description: String.prototype.trim must exist as a function +---*/ + +var f = String.prototype.trim; + +assert.sameValue(typeof(f), "function", 'typeof(f)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-0-2.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-0-2.js new file mode 100644 index 0000000000..79a711dae3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-0-2.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-0-2 +description: String.prototype.trim must exist as a function taking 0 parameters +---*/ + +assert.sameValue(String.prototype.trim.length, 0, 'String.prototype.trim.length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-1.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-1.js new file mode 100644 index 0000000000..a269a8c051 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-1 +description: String.prototype.trim throws TypeError when string is undefined +---*/ + + +assert.throws(TypeError, function() { + String.prototype.trim.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-2.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-2.js new file mode 100644 index 0000000000..9401c3c35d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-2 +description: String.prototype.trim throws TypeError when string is null +---*/ + + +assert.throws(TypeError, function() { + String.prototype.trim.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-3.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-3.js new file mode 100644 index 0000000000..e08c9a6c61 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-3.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-3 +description: String.prototype.trim works for primitive type boolean +---*/ + +assert.sameValue(String.prototype.trim.call(true), "true", 'String.prototype.trim.call(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-4.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-4.js new file mode 100644 index 0000000000..e19bb4eb48 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-4.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-4 +description: String.prototype.trim works for primitive type number +---*/ + +assert.sameValue(String.prototype.trim.call(0), "0", 'String.prototype.trim.call(0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-5.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-5.js new file mode 100644 index 0000000000..bace97dc52 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-5.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-5 +description: String.prototype.trim works for an Object +---*/ + +assert.sameValue(String.prototype.trim.call({}), "[object Object]", 'String.prototype.trim.call({})'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-6.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-6.js new file mode 100644 index 0000000000..8332f891bb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-6.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-6 +description: String.prototype.trim works for an String +---*/ + +assert.sameValue(String.prototype.trim.call(new String()), "", 'String.prototype.trim.call(new String())'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-7.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-7.js new file mode 100644 index 0000000000..a19bcb489c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-7.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-7 +description: String.prototype.trim works for a primitive string +---*/ + +assert.sameValue(String.prototype.trim.call("abc"), "abc", 'String.prototype.trim.call("abc")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-8.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-8.js new file mode 100644 index 0000000000..0db004bc69 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-8.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-8 +description: > + String.prototype.trim works for a primitive string (value is ' + abc') +---*/ + +var strObj = String(" abc"); + +assert.sameValue(strObj.trim(), "abc", 'strObj.trim()'); +assert.sameValue(strObj.toString(), " abc", 'strObj.toString()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-9.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-9.js new file mode 100644 index 0000000000..97e767d831 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-1-9.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-1-9 +description: > + String.prototype.trim works for a String object which value is + undefined +---*/ + +var strObj = new String(undefined); + +assert.sameValue(strObj.trim(), "undefined", 'strObj.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-1.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-1.js new file mode 100644 index 0000000000..64777d2f6c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-1 +description: > + String.prototype.trim - argument 'this' is a boolean whose value + is false +---*/ + +assert.sameValue(String.prototype.trim.call(false), "false", 'String.prototype.trim.call(false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-10.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-10.js new file mode 100644 index 0000000000..3a5a2abfe8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-10 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is +Infinity) +---*/ + +assert.sameValue(String.prototype.trim.call(+Infinity), "Infinity", 'String.prototype.trim.call(+Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-11.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-11.js new file mode 100644 index 0000000000..a9811bc1d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-11.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-11 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is -Infinity) +---*/ + +assert.sameValue(String.prototype.trim.call(-Infinity), "-Infinity", 'String.prototype.trim.call(-Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-12.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-12.js new file mode 100644 index 0000000000..ee58574fd2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-12.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-12 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1(following 20 zeros)) +---*/ + +assert.sameValue(String.prototype.trim.call(100000000000000000000), "100000000000000000000", 'String.prototype.trim.call(100000000000000000000)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-13.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-13.js new file mode 100644 index 0000000000..0eb7e26e30 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-13.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-13 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1(following 21 zeros)) +---*/ + +assert.sameValue(String.prototype.trim.call(1000000000000000000000), "1e+21", 'String.prototype.trim.call(1000000000000000000000)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-14.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-14.js new file mode 100644 index 0000000000..5566838564 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-14.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-14 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1(following 22 zeros)) +---*/ + +assert.sameValue(String.prototype.trim.call(10000000000000000000000), "1e+22", 'String.prototype.trim.call(10000000000000000000000)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-15.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-15.js new file mode 100644 index 0000000000..0a4e50bfa7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-15.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-15 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1e+20) +---*/ + +assert.sameValue(String.prototype.trim.call(1e+20), "100000000000000000000", 'String.prototype.trim.call(1e+20)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-16.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-16.js new file mode 100644 index 0000000000..cae3236cfb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-16.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-16 +description: > + String.prototype.trim - argument 'this' is a number that converts + to string (value is 1e+21) +---*/ + +assert.sameValue(String.prototype.trim.call(1e+21), "1e+21", 'String.prototype.trim.call(1e+21)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-17.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-17.js new file mode 100644 index 0000000000..7358155593 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-17.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-17 +description: > + String.prototype.trim - argument 'this' is a number that converts + to string (value is 1e+22) +---*/ + +assert.sameValue(String.prototype.trim.call(1e+22), "1e+22", 'String.prototype.trim.call(1e+22)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-18.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-18.js new file mode 100644 index 0000000000..bf2ce163b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-18.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-18 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 0.000001) +---*/ + +assert.sameValue(String.prototype.trim.call(0.000001), "0.000001", 'String.prototype.trim.call(0.000001)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-19.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-19.js new file mode 100644 index 0000000000..2017155aac --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-19.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-19 +description: > + String.prototype.trim - argument argument 'this' is a number that + converts to a string (value is 0.0000001) +---*/ + +assert.sameValue(String.prototype.trim.call(0.0000001), "1e-7", 'String.prototype.trim.call(0.0000001)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-2.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-2.js new file mode 100644 index 0000000000..0cabe22e0c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-2 +description: > + String.prototype.trim - argument 'this' is a boolean whose value + is true +---*/ + +assert.sameValue(String.prototype.trim.call(true), "true", 'String.prototype.trim.call(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-20.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-20.js new file mode 100644 index 0000000000..30a21e6d38 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-20.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-20 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 0.00000001) +---*/ + +assert.sameValue(String.prototype.trim.call(0.00000001), "1e-8", 'String.prototype.trim.call(0.00000001)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-21.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-21.js new file mode 100644 index 0000000000..73718c68a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-21.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-21 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1e-7) +---*/ + +assert.sameValue(String.prototype.trim.call(1e-7), "1e-7", 'String.prototype.trim.call(1e-7)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-22.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-22.js new file mode 100644 index 0000000000..dd0ae89b4f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-22.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-22 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1e-6) +---*/ + +assert.sameValue(String.prototype.trim.call(1e-6), "0.000001", 'String.prototype.trim.call(1e-6)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-23.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-23.js new file mode 100644 index 0000000000..39b6168d30 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-23.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-23 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1e-5) +---*/ + +assert.sameValue(String.prototype.trim.call(1e-5), "0.00001", 'String.prototype.trim.call(1e-5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-24.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-24.js new file mode 100644 index 0000000000..9f78f2a2ff --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-24.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-24 +description: > + String.prototype.trim - argument 'this' is an integer that + converts to a string (value is 123) +---*/ + +assert.sameValue(String.prototype.trim.call(123), "123", 'String.prototype.trim.call(123)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-25.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-25.js new file mode 100644 index 0000000000..510465a130 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-25.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-25 +description: > + String.prototype.trim - argument 'this' is a decimal that converts + to a string (value is 123.456) +---*/ + +assert.sameValue(String.prototype.trim.call(123.456), "123.456", 'String.prototype.trim.call(123.456)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-26.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-26.js new file mode 100644 index 0000000000..0260d57cc7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-26.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-26 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 1(following 20 zeros).123) +---*/ + +assert.sameValue(String.prototype.trim.call(100000000000000000000.123), "100000000000000000000", 'String.prototype.trim.call(100000000000000000000.123)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-27.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-27.js new file mode 100644 index 0000000000..812db57de4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-27.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-27 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 123.1234567) +---*/ + +assert.sameValue(String.prototype.trim.call(123.1234567), "123.1234567", 'String.prototype.trim.call(123.1234567)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-28.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-28.js new file mode 100644 index 0000000000..8c6c9c6566 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-28.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-28 +description: String.prototype.trim - argument 'this' is an empty string +---*/ + +assert.sameValue(String.prototype.trim.call(""), "", 'String.prototype.trim.call("")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-29.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-29.js new file mode 100644 index 0000000000..3618258ef1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-29.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-29 +description: > + String.prototype.trim - argument 'this' is a string(value is 'AB + \cd') +---*/ + +assert.sameValue(String.prototype.trim.call("AB\n\\cd"), "AB\n\\cd", 'String.prototype.trim.call("AB\n\\cd")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-3.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-3.js new file mode 100644 index 0000000000..1b345ee9cb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-3 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is NaN) +---*/ + +assert.sameValue(String.prototype.trim.call(NaN), "NaN", 'String.prototype.trim.call(NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-30.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-30.js new file mode 100644 index 0000000000..84c8a964ad --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-30.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-30 +description: > + String.prototype.trim - argument 'this' is a string(value is + 'undefined') +---*/ + +assert.sameValue(String.prototype.trim.call("undefined"), "undefined", 'String.prototype.trim.call("undefined")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-31.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-31.js new file mode 100644 index 0000000000..fded952e0c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-31.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-31 +description: > + String.prototype.trim - argument 'this' is a string(value is + 'null') +---*/ + +assert.sameValue(String.prototype.trim.call("null"), "null", 'String.prototype.trim.call("null")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-32.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-32.js new file mode 100644 index 0000000000..7d28522bc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-32.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-32 +description: > + String.prototype.trim - argument 'this' is a string(value is + '123#$%abc') +---*/ + +assert.sameValue(String.prototype.trim.call("123#$%abc"), "123#$%abc", 'String.prototype.trim.call("123#$%abc")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-33.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-33.js new file mode 100644 index 0000000000..7bee4339ef --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-33.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-33 +description: String.prototype.trim - argument 'this' is a string(value is '1') +---*/ + +assert.sameValue(String.prototype.trim.call("1"), "1", 'String.prototype.trim.call("1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-34.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-34.js new file mode 100644 index 0000000000..8807b094f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-34.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-34 +description: > + String.prototype.trim - 'this' is an array that converts to a + string +---*/ + +assert.sameValue(String.prototype.trim.call([1]), '1', 'String.prototype.trim.call([1])'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-35.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-35.js new file mode 100644 index 0000000000..fc932b8ae5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-35.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-35 +description: > + String.prototype.trim - 'this' is a String Object that converts to + a string +---*/ + +assert.sameValue(String.prototype.trim.call(new String("abc")), "abc", 'String.prototype.trim.call(new String("abc"))'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-36.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-36.js new file mode 100644 index 0000000000..641386bc94 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-36.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-36 +description: > + String.prototype.trim - 'this' is a Boolean Object that converts + to a string +---*/ + +assert.sameValue(String.prototype.trim.call(new Boolean(false)), "false", 'String.prototype.trim.call(new Boolean(false))'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-37.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-37.js new file mode 100644 index 0000000000..fa7814c61e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-37.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-37 +description: > + String.prototype.trim - 'this' is a Number Object that converts to + a string +---*/ + +assert.sameValue(String.prototype.trim.call(new Number(123)), "123", 'String.prototype.trim.call(new Number(123))'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-38.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-38.js new file mode 100644 index 0000000000..20b065ffd8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-38.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-38 +description: > + String.prototype.trim - 'this' is an object which has an own + toString method +---*/ + +var obj = { + toString: function() { + return "abc"; + } +}; + +assert.sameValue(String.prototype.trim.call(obj), "abc", 'String.prototype.trim.call(obj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-39.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-39.js new file mode 100644 index 0000000000..0b3cad4092 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-39.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-39 +description: > + String.prototype.trim - 'this' is an object which has an own + valueOf method +---*/ + +var obj = { + valueOf: function() { + return "abc"; + } +}; + +assert.sameValue(String.prototype.trim.call(obj), "[object Object]", 'String.prototype.trim.call(obj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-4.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-4.js new file mode 100644 index 0000000000..017891e177 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-4 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is 0) +---*/ + +assert.sameValue(String.prototype.trim.call(0), "0", 'String.prototype.trim.call(0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-40.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-40.js new file mode 100644 index 0000000000..87e4daa935 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-40.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-40 +description: > + String.prototype.trim - 'this' is an object that has an own + toString method that returns an object and valueOf method that + returns a primitive value +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return "abc"; + } +}; + +assert.sameValue(String.prototype.trim.call(obj), "abc", 'String.prototype.trim.call(obj)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-41.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-41.js new file mode 100644 index 0000000000..cf30a3e129 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-41.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-41 +description: > + String.prototype.trim - 'this' is an object which has an own + toString and valueOf method. +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + toString: function() { + toStringAccessed = true; + return "abc"; + }, + valueOf: function() { + valueOfAccessed = true; + return "cef"; + } +}; + +assert.sameValue(String.prototype.trim.call(obj), "abc", 'String.prototype.trim.call(obj)'); +assert.sameValue(valueOfAccessed, false, 'valueOfAccessed'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-42.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-42.js new file mode 100644 index 0000000000..fc63f81172 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-42.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-42 +description: > + String.prototype.trim - TypeError exception was thrown when + 'this' is an object that both toString and valueOf wouldn't return + primitive value. +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; +assert.throws(TypeError, function() { + String.prototype.trim.call(obj); +}); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-43.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-43.js new file mode 100644 index 0000000000..f579223fec --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-43.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-43 +description: > + String.prototype.trim - 'this' is an object with an own valueOf + and inherited toString methods with hint string, verify inherited + toString method will be called first +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + toString: function() { + toStringAccessed = true; + return "abc"; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.valueOf = function() { + valueOfAccessed = true; + return "efg"; +}; + +assert.sameValue(String.prototype.trim.call(child), "abc", 'String.prototype.trim.call(child)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert.sameValue(valueOfAccessed, false, 'valueOfAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-44.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-44.js new file mode 100644 index 0000000000..5b9a41b105 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-44.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-44 +description: > + String.prototype.trim - 'this' is a string that contains east + Asian characters (value is 'SD咕噜') +---*/ + +var str = "SD咕噜"; + +assert.sameValue(str.trim(), str, 'str.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-45.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-45.js new file mode 100644 index 0000000000..de56d44a01 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-45.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-45 +description: > + String.prototype.trim - 'this' is a string that contains white + space, character, number, object and null characters +---*/ + +var str = "abc" + " " + 123 + " " + {} + " " + "\u0000"; +var str1 = " " + str + " "; + +assert.sameValue(str1.trim(), str, 'str1.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-46.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-46.js new file mode 100644 index 0000000000..9968dcf5da --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-46.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-46 +description: > + String.prototype.trim - 'this' is a Function Object that converts + to a string +---*/ + +var funObj = function() { + return arguments; +}; + +assert.sameValue(typeof(String.prototype.trim.call(funObj)), "string", 'typeof(String.prototype.trim.call(funObj))'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-47.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-47.js new file mode 100644 index 0000000000..10b4243db4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-47.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-47 +description: > + String.prototype.trim - 'this' is a object Object that converts to + a string +---*/ + +assert.sameValue(String.prototype.trim.call({}), "[object Object]", 'String.prototype.trim.call({})'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-49.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-49.js new file mode 100644 index 0000000000..3da8e68673 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-49.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-49 +description: > + String.prototype.trim - 'this' is a RegExp Object that converts to + a string +---*/ + +var regObj = new RegExp(/test/); + +assert.sameValue(String.prototype.trim.call(regObj), "/test/", 'String.prototype.trim.call(regObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-5.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-5.js new file mode 100644 index 0000000000..3f6168a04a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-5.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-5 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is +0) +---*/ + +assert.sameValue(String.prototype.trim.call(+0), "0", 'String.prototype.trim.call(+0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-50.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-50.js new file mode 100644 index 0000000000..5ad23d1bf5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-50.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-50 +description: > + String.prototype.trim - 'this' is a Error Object that converts to + a string +---*/ + +var errObj = new Error("test"); + +assert.sameValue(String.prototype.trim.call(errObj), "Error: test", 'String.prototype.trim.call(errObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-51.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-51.js new file mode 100644 index 0000000000..f1786b34de --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-51.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-51 +description: > + String.prototype.trim - 'this' is a Arguments Object that converts + to a string +---*/ + +var argObj = function() { + return arguments; +}(1, 2, true); + +assert.sameValue(String.prototype.trim.call(argObj), "[object Arguments]", 'String.prototype.trim.call(argObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-6.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-6.js new file mode 100644 index 0000000000..6df39e44d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-6.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-6 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is -0) +---*/ + +assert.sameValue(String.prototype.trim.call(-0), "0", 'String.prototype.trim.call(-0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-7.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-7.js new file mode 100644 index 0000000000..522738214a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-7.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-7 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is positive number) +---*/ + +assert.sameValue(String.prototype.trim.call(30), "30", 'String.prototype.trim.call(30)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-8.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-8.js new file mode 100644 index 0000000000..4b07be308c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-8 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is negative number) +---*/ + +assert.sameValue(String.prototype.trim.call(-20), "-20", 'String.prototype.trim.call(-20)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-9.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-9.js new file mode 100644 index 0000000000..7d9216a6f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-2-9.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-2-9 +description: > + String.prototype.trim - argument 'this' is a number that converts + to a string (value is Infinity) +---*/ + +assert.sameValue(String.prototype.trim.call(Infinity), "Infinity", 'String.prototype.trim.call(Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-1.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-1.js new file mode 100644 index 0000000000..96b06c6b9f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-1 +description: String.prototype.trim - 'S' is a string with all LineTerminator +---*/ + +var lineTerminatorsStr = "\u000A\u000D\u2028\u2029"; + +assert.sameValue(lineTerminatorsStr.trim(), "", 'lineTerminatorsStr.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-10.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-10.js new file mode 100644 index 0000000000..5970916ea4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-10 +description: > + String.prototype.trim - 'S' is a string with null character + ('\u0000') +---*/ + +assert.sameValue("\u0000".trim(), "\u0000", '"\u0000".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-11.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-11.js new file mode 100644 index 0000000000..cf2050d7d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-11.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-11 +description: > + String.prototype.trim - 'S' is a string that starts with null + character +---*/ + +assert.sameValue("\0\u0000abc".trim(), "\0\u0000abc", '"\0\u0000abc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-12.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-12.js new file mode 100644 index 0000000000..e878c14c5d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-12.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-12 +description: > + String.prototype.trim - 'S' is a string that ends with null + character +---*/ + +assert.sameValue("abc\0\u0000".trim(), "abc\0\u0000", '"abc\0\u0000".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-13.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-13.js new file mode 100644 index 0000000000..73a64e0e4c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-13.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-13 +description: > + String.prototype.trim - 'S' is a string that starts with null + character and ends with null character +---*/ + +assert.sameValue("\0\u0000abc\0\u0000".trim(), "\0\u0000abc\0\u0000", '"\0\u0000abc\0\u0000".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-14.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-14.js new file mode 100644 index 0000000000..220415d464 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-14.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-14 +description: > + String.prototype.trim - 'S' is a string that has null character in + the middle +---*/ + +assert.sameValue("a\0\u0000bc".trim(), "a\0\u0000bc", '"a\0\u0000bc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-2.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-2.js new file mode 100644 index 0000000000..9181e9a575 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-2 +description: String.prototype.trim - 'S' is a string with all WhiteSpace +---*/ + +var whiteSpacesStr = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"; + +assert.sameValue(whiteSpacesStr.trim(), "", 'whiteSpacesStr.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-3.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-3.js new file mode 100644 index 0000000000..bdcd6d317a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-3.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-3 +description: > + String.prototype.trim - 'S' is a string with all union of + WhiteSpace and LineTerminator +---*/ + +var lineTerminatorsStr = "\u000A\u000D\u2028\u2029"; +var whiteSpacesStr = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"; +var str = whiteSpacesStr + lineTerminatorsStr; + +assert.sameValue(str.trim(), "", 'str.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-4.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-4.js new file mode 100644 index 0000000000..429e6fce11 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-4.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-4 +description: > + String.prototype.trim - 'S' is a string start with union of all + LineTerminator and all WhiteSpace +---*/ + +var lineTerminatorsStr = "\u000A\u000D\u2028\u2029"; +var whiteSpacesStr = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"; +var str = whiteSpacesStr + lineTerminatorsStr + "abc"; + +assert.sameValue(str.trim(), "abc", 'str.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-5.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-5.js new file mode 100644 index 0000000000..f917b2f2b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-5.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-5 +description: > + String.prototype.trim - 'S' is a string end with union of all + LineTerminator and all WhiteSpace +---*/ + +var lineTerminatorsStr = "\u000A\u000D\u2028\u2029"; +var whiteSpacesStr = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"; +var str = "abc" + whiteSpacesStr + lineTerminatorsStr; + +assert.sameValue(str.trim(), "abc", 'str.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-6.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-6.js new file mode 100644 index 0000000000..5f0852d44b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-6.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-6 +description: > + String.prototype.trim - 'S' is a string start with union of all + LineTerminator and all WhiteSpace and end with union of all + LineTerminator and all WhiteSpace +---*/ + +var lineTerminatorsStr = "\u000A\u000D\u2028\u2029"; +var whiteSpacesStr = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"; +var str = whiteSpacesStr + lineTerminatorsStr + "abc" + whiteSpacesStr + lineTerminatorsStr; + +assert.sameValue(str.trim(), "abc", 'str.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-7.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-7.js new file mode 100644 index 0000000000..f506b8f2ff --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-7.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-7 +description: > + String.prototype.trim - 'S' is a string that union of + LineTerminator and WhiteSpace in the middle +---*/ + +var lineTerminatorsStr = "\u000A\u000D\u2028\u2029"; +var whiteSpacesStr = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF"; +var str = "ab" + whiteSpacesStr + lineTerminatorsStr + "cd"; + +assert.sameValue(str.trim(), str, 'str.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-8.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-8.js new file mode 100644 index 0000000000..a715128193 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-8.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-8 +description: String.prototype.trim - 'S' is a string with all null character +---*/ + +assert.sameValue("\0\u0000".trim(), "\0\u0000", '"\0\u0000".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-9.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-9.js new file mode 100644 index 0000000000..b05f48d1bb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-3-9.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-3-9 +description: String.prototype.trim - 'S' is a string with null character ('\0') +---*/ + +assert.sameValue("\0".trim(), "\0", '"\0".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-1.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-1.js new file mode 100644 index 0000000000..668a8a067a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-1.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-1 +description: > + String.prototype.trim handles multiline string with whitepace and + lineterminators +---*/ + +var s = "\u0009a b\ +c \u0009" + + + +assert.sameValue(s.trim(), "a bc", 's.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-10.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-10.js new file mode 100644 index 0000000000..027aa59396 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-10 +description: > + String.prototype.trim handles whitepace and lineterminators + (\uFEFFabc) +---*/ + +assert.sameValue("\uFEFFabc".trim(), "abc", '"\uFEFFabc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-11.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-11.js new file mode 100644 index 0000000000..c2f29c86bc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-11.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-11 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u0009) +---*/ + +assert.sameValue("abc\u0009".trim(), "abc", '"abc\u0009".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-12.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-12.js new file mode 100644 index 0000000000..e9ab5a6938 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-12.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-12 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u000B) +---*/ + +assert.sameValue("abc\u000B".trim(), "abc", '"abc\u000B".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-13.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-13.js new file mode 100644 index 0000000000..f386d46fdf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-13.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-13 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u000C) +---*/ + +assert.sameValue("abc\u000C".trim(), "abc", '"abc\u000C".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-14.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-14.js new file mode 100644 index 0000000000..2844170718 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-14.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-14 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u0020) +---*/ + +assert.sameValue("abc\u0020".trim(), "abc", '"abc\u0020".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-16.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-16.js new file mode 100644 index 0000000000..79d9e91c92 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-16.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-16 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u00A0) +---*/ + +assert.sameValue("abc\u00A0".trim(), "abc", '"abc\u00A0".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-18.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-18.js new file mode 100644 index 0000000000..92c21f5d75 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-18.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-18 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\uFEFF) +---*/ + +assert.sameValue("abc\uFEFF".trim(), "abc", '"abc\uFEFF".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-19.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-19.js new file mode 100644 index 0000000000..03dd00e641 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-19.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-19 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u0009abc\u0009) +---*/ + +assert.sameValue("\u0009abc\u0009".trim(), "abc", '"\u0009abc\u0009".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-2.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-2.js new file mode 100644 index 0000000000..8015077a77 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-2 +description: > + String.prototype.trim handles whitepace and lineterminators ( + \u0009abc \u0009) +---*/ + +assert.sameValue(" \u0009abc \u0009".trim(), "abc", '" \u0009abc \u0009".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-20.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-20.js new file mode 100644 index 0000000000..9461d07d4f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-20.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-20 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Babc\u000B) +---*/ + +assert.sameValue("\u000Babc\u000B".trim(), "abc", '"\u000Babc\u000B".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-21.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-21.js new file mode 100644 index 0000000000..aee6aa7a50 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-21.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-21 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Cabc\u000C) +---*/ + +assert.sameValue("\u000Cabc\u000C".trim(), "abc", '"\u000Cabc\u000C".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-22.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-22.js new file mode 100644 index 0000000000..40e1e968ae --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-22.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-22 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u0020abc\u0020) +---*/ + +assert.sameValue("\u0020abc\u0020".trim(), "abc", '"\u0020abc\u0020".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-24.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-24.js new file mode 100644 index 0000000000..f750bdcc9d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-24.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-24 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u00A0abc\u00A0) +---*/ + +assert.sameValue("\u00A0abc\u00A0".trim(), "abc", '"\u00A0abc\u00A0".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-27.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-27.js new file mode 100644 index 0000000000..2f2d01333b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-27.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-27 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u0009\u0009) +---*/ + +assert.sameValue("\u0009\u0009".trim(), "", '"\u0009\u0009".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-28.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-28.js new file mode 100644 index 0000000000..0b6ad4bb65 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-28.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-28 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000B\u000B) +---*/ + +assert.sameValue("\u000B\u000B".trim(), "", '"\u000B\u000B".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-29.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-29.js new file mode 100644 index 0000000000..8931f72d35 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-29.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-29 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000C\u000C) +---*/ + +assert.sameValue("\u000C\u000C".trim(), "", '"\u000C\u000C".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-3.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-3.js new file mode 100644 index 0000000000..9bf4d59664 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-3 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u0009abc) +---*/ + +assert.sameValue("\u0009abc".trim(), "abc", '"\u0009abc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-30.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-30.js new file mode 100644 index 0000000000..19edd41756 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-30.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-30 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u0020\u0020) +---*/ + +assert.sameValue("\u0020\u0020".trim(), "", '"\u0020\u0020".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-32.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-32.js new file mode 100644 index 0000000000..655e95d819 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-32.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-32 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u00A0\u00A0) +---*/ + +assert.sameValue("\u00A0\u00A0".trim(), "", '"\u00A0\u00A0".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-34.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-34.js new file mode 100644 index 0000000000..4b6e1ec258 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-34.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-34 +description: > + String.prototype.trim handles whitepace and lineterminators + (\uFEFF\uFEFF) +---*/ + +assert.sameValue("\uFEFF\uFEFF".trim(), "", '"\uFEFF\uFEFF".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-35.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-35.js new file mode 100644 index 0000000000..c5c3b7dd75 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-35.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-35 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\u0009c) +---*/ + +assert.sameValue("ab\u0009c".trim(), "ab\u0009c", '"ab\u0009c".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-36.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-36.js new file mode 100644 index 0000000000..7fdc2f9185 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-36.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-36 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\u000Bc) +---*/ + +assert.sameValue("ab\u000Bc".trim(), "ab\u000Bc", '"ab\u000Bc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-37.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-37.js new file mode 100644 index 0000000000..dbee1c80e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-37.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-37 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\u000Cc) +---*/ + +assert.sameValue("ab\u000Cc".trim(), "ab\u000Cc", '"ab\u000Cc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-38.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-38.js new file mode 100644 index 0000000000..d0bf8d1f16 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-38.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-38 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\u0020c) +---*/ + +assert.sameValue("ab\u0020c".trim(), "ab\u0020c", '"ab\u0020c".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-39.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-39.js new file mode 100644 index 0000000000..c5942adbd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-39.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-39 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\u0085c) +---*/ + +assert.sameValue("ab\u0085c".trim(), "ab\u0085c", '"ab\u0085c".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-4.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-4.js new file mode 100644 index 0000000000..b835eb401d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-4 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Babc) +---*/ + +assert.sameValue("\u000Babc".trim(), "abc", '"\u000Babc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-40.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-40.js new file mode 100644 index 0000000000..12b8e7a386 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-40.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-40 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\u00A0c) +---*/ + +assert.sameValue("ab\u00A0c".trim(), "ab\u00A0c", '"ab\u00A0c".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-41.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-41.js new file mode 100644 index 0000000000..a94ad1fe0a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-41.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-41 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\u200Bc) +---*/ + +assert.sameValue("ab\u200Bc".trim(), "ab\u200Bc", '"ab\u200Bc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-42.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-42.js new file mode 100644 index 0000000000..9bbfeb1c18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-42.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-42 +description: > + String.prototype.trim handles whitepace and lineterminators + (ab\uFEFFc) +---*/ + +assert.sameValue("ab\uFEFFc".trim(), "ab\uFEFFc", '"ab\uFEFFc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-43.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-43.js new file mode 100644 index 0000000000..76c84b1026 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-43.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-43 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Aabc) +---*/ + +assert.sameValue("\u000Aabc".trim(), "abc", '"\u000Aabc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-44.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-44.js new file mode 100644 index 0000000000..9de5946f88 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-44.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-44 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Dabc) +---*/ + +assert.sameValue("\u000Dabc".trim(), "abc", '"\u000Dabc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-45.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-45.js new file mode 100644 index 0000000000..5a6a71d014 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-45.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-45 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u2028abc) +---*/ + +assert.sameValue("\u2028abc".trim(), "abc", '"\u2028abc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-46.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-46.js new file mode 100644 index 0000000000..3f7e429639 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-46.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-46 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u2029abc) +---*/ + +assert.sameValue("\u2029abc".trim(), "abc", '"\u2029abc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-47.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-47.js new file mode 100644 index 0000000000..ac61dd81a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-47.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-47 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u000A) +---*/ + +assert.sameValue("abc\u000A".trim(), "abc", '"abc\u000A".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-48.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-48.js new file mode 100644 index 0000000000..ea0524f95c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-48.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-48 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u000D) +---*/ + +assert.sameValue("abc\u000D".trim(), "abc", '"abc\u000D".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-49.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-49.js new file mode 100644 index 0000000000..cfacd63b85 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-49.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-49 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u2028) +---*/ + +assert.sameValue("abc\u2028".trim(), "abc", '"abc\u2028".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-5.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-5.js new file mode 100644 index 0000000000..6c349986d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-5.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-5 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Cabc) +---*/ + +assert.sameValue("\u000Cabc".trim(), "abc", '"\u000Cabc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-50.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-50.js new file mode 100644 index 0000000000..395c2e7f75 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-50.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-50 +description: > + String.prototype.trim handles whitepace and lineterminators + (abc\u2029) +---*/ + +assert.sameValue("abc\u2029".trim(), "abc", '"abc\u2029".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-51.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-51.js new file mode 100644 index 0000000000..e9af0ed887 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-51.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-51 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Aabc\u000A) +---*/ + +assert.sameValue("\u000Aabc\u000A".trim(), "abc", '"\u000Aabc\u000A".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-52.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-52.js new file mode 100644 index 0000000000..ab0db3c2e5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-52.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-52 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000Dabc\u000D) +---*/ + +assert.sameValue("\u000Dabc\u000D".trim(), "abc", '"\u000Dabc\u000D".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-53.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-53.js new file mode 100644 index 0000000000..45eef4e3e1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-53.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-53 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u2028abc\u2028) +---*/ + +assert.sameValue("\u2028abc\u2028".trim(), "abc", '"\u2028abc\u2028".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-54.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-54.js new file mode 100644 index 0000000000..ac47638692 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-54.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-54 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u2029abc\u2029) +---*/ + +assert.sameValue("\u2029abc\u2029".trim(), "abc", '"\u2029abc\u2029".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-55.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-55.js new file mode 100644 index 0000000000..6e128e63de --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-55.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-55 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000A\u000A) +---*/ + +assert.sameValue("\u000A\u000A".trim(), "", '"\u000A\u000A".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-56.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-56.js new file mode 100644 index 0000000000..b4295f8d1b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-56.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-56 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u000D\u000D) +---*/ + +assert.sameValue("\u000D\u000D".trim(), "", '"\u000D\u000D".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-57.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-57.js new file mode 100644 index 0000000000..9da86804f1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-57.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-57 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u2028\u2028) +---*/ + +assert.sameValue("\u2028\u2028".trim(), "", '"\u2028\u2028".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-58.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-58.js new file mode 100644 index 0000000000..3e89d9d961 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-58.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-58 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u2029\u2029) +---*/ + +assert.sameValue("\u2029\u2029".trim(), "", '"\u2029\u2029".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-59.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-59.js new file mode 100644 index 0000000000..b308590072 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-59.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-59 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u2029abc as a multiline string) +---*/ + +var s = "\u2029\ + abc"; + +assert.sameValue(s.trim(), "abc", 's.trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-6.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-6.js new file mode 100644 index 0000000000..19574a6ba8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-6.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-6 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u0020abc) +---*/ + +assert.sameValue("\u0020abc".trim(), "abc", '"\u0020abc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-60.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-60.js new file mode 100644 index 0000000000..836b10967c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-60.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-60 +description: > + String.prototype.trim handles whitepace and lineterminators + (string with just blanks) +---*/ + +assert.sameValue(" ".trim(), "", '" ".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-8.js b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-8.js new file mode 100644 index 0000000000..968ae6290e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/15.5.4.20-4-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 15.5.4.20-4-8 +description: > + String.prototype.trim handles whitepace and lineterminators + (\u00A0abc) +---*/ + +assert.sameValue("\u00A0abc".trim(), "abc", '"\u00A0abc".trim()'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/browser.js b/js/src/tests/test262/built-ins/String/prototype/trim/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/name.js b/js/src/tests/test262/built-ins/String/prototype/trim/name.js new file mode 100644 index 0000000000..3f983c303c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/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.25 +description: > + String.prototype.trim.name is "trim". +info: | + String.prototype.trim ( ) + + 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.trim.name, "trim"); + +verifyNotEnumerable(String.prototype.trim, "name"); +verifyNotWritable(String.prototype.trim, "name"); +verifyConfigurable(String.prototype.trim, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/trim/not-a-constructor.js new file mode 100644 index 0000000000..20118ff8fc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/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.trim 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.trim), + false, + 'isConstructor(String.prototype.trim) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.trim(); +}, '`new String.prototype.trim()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/shell.js b/js/src/tests/test262/built-ins/String/prototype/trim/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/trim/u180e.js b/js/src/tests/test262/built-ins/String/prototype/trim/u180e.js new file mode 100644 index 0000000000..8b26b5cbbd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trim/u180e.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 Mathias Bynens. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-white-space +description: > + U+180E is no longer a Unicode `Space_Separator` symbol as of Unicode v6.3.0. +info: | + String.prototype.trim ( ) + + 3. [...] The definition of white space is the union of |WhiteSpace| and + |LineTerminator|. +features: [u180e] +---*/ + +assert.sameValue("_\u180E".trim(), "_\u180E"); +assert.sameValue("\u180E".trim(), "\u180E"); +assert.sameValue("\u180E_".trim(), "\u180E_"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/browser.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/length.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/length.js new file mode 100644 index 0000000000..793721823e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + String.prototype.trimEnd.length is 0. +info: > + String.prototype.trimEnd ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [string-trimming, String.prototype.trimEnd] +---*/ + +verifyProperty(String.prototype.trimEnd, "length", { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/name.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/name.js new file mode 100644 index 0000000000..ad2c4d0d31 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + String.prototype.trimEnd.name is "trimEnd". +info: > + String.prototype.trimEnd ( ) + + 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] +features: [string-trimming, String.prototype.trimEnd] +---*/ + +verifyProperty(String.prototype.trimEnd, "name", { + value: "trimEnd", + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/not-a-constructor.js new file mode 100644 index 0000000000..0d8bea1970 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/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.trimEnd 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, string-trimming, String.prototype.trimEnd, arrow-function] +---*/ + +assert.sameValue( + isConstructor(String.prototype.trimEnd), + false, + 'isConstructor(String.prototype.trimEnd) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.trimEnd(); +}, '`new String.prototype.trimEnd()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/prop-desc.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/prop-desc.js new file mode 100644 index 0000000000..e0c43bc095 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 The Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + "trimEnd" property of String.prototype +info: > + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [string-trimming, String.prototype.trimEnd] +---*/ + +verifyProperty(String.prototype, "trimEnd", { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/shell.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-boolean.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-boolean.js new file mode 100644 index 0000000000..e4d99dc291 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-boolean.js @@ -0,0 +1,33 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: Behavior when "this" value is a boolean. +info: | + Runtime Semantics: TrimString ( string, where ) + 2. Let S be ? ToString(str). + + ToString ( argument ) + Argument Type: Boolean + Result: + If argument is true, return "true". + If argument is false, return "false". +features: [string-trimming, String.prototype.trimEnd] +---*/ + +var trimEnd = String.prototype.trimEnd + +assert.sameValue( + trimEnd.call(true), + 'true', + 'String.prototype.trimEnd.call(true)' +); + +assert.sameValue( + String.prototype.trimEnd.call(false), + 'false', + 'String.prototype.trimEnd.call(false)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-line-terminator.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-line-terminator.js new file mode 100644 index 0000000000..1e78fd4d51 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-line-terminator.js @@ -0,0 +1,32 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: TrimEnd removes all line terminators from the end of a string. +info: | + Runtime Symantics: TrimString ( string, where ) + ... + 4. Else if where is "end", let T be a String value that is a copy of S with + trailing white space removed. + ... + + The definition of white space is the union of WhiteSpace and LineTerminator. + +features: [string-trimming, String.prototype.trimEnd] +---*/ + +var trimEnd = String.prototype.trimEnd; + +// A string of all valid LineTerminator Unicode code points +var lt = '\u000A\u000D\u2028\u2029'; + +var str = lt + 'a' + lt + 'b' + lt; +var expected = lt + 'a' + lt + 'b'; + +assert.sameValue( + trimEnd.call(str), + expected +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..5ceea74ebf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-not-obj-coercible.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +features: [string-trimming, String.prototype.trimEnd] +---*/ + +var trimEnd = String.prototype.trimEnd; + +assert.sameValue(typeof trimEnd, 'function'); + +assert.throws(TypeError, function() { + trimEnd.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + trimEnd.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-number.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-number.js new file mode 100644 index 0000000000..8446048b56 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-number.js @@ -0,0 +1,49 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: Behavoir when "this" value is a number. +info: | + Runtime Semantics: TrimString ( string, where ) + 2. Let S be ? ToString(str). + + ToString ( argument ) + Argument Type: Number + Result: NumberToString(argument) +features: [string-trimming, String.prototype.trimEnd] +---*/ + +var trimEnd = String.prototype.trimEnd + +assert.sameValue( + trimEnd.call(NaN), + 'NaN', + 'String.prototype.trimEnd.call(NaN)' +); + +assert.sameValue( + trimEnd.call(Infinity), + 'Infinity', + 'String.prototype.trimEnd.call(Infinity)' +); + +assert.sameValue( + trimEnd.call(-0), + '0', + 'String.prototype.trimEnd.call(-0)' +); + +assert.sameValue( + trimEnd.call(1), + '1', + 'String.prototype.trimEnd.call(1)' +); + +assert.sameValue( + trimEnd.call(-1), + '-1', + 'String.prototype.trimEnd.call(-1)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-cannot-convert-to-primitive-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-cannot-convert-to-primitive-err.js new file mode 100644 index 0000000000..eb3e3a9dca --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-cannot-convert-to-primitive-err.js @@ -0,0 +1,63 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + This value is an object which cannot be converted to a primitive +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +assert.sameValue(typeof String.prototype.trimEnd, "function"); + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf: undefined, +}; + +// If trimEnd is called on an object with neither Symbol.toPrimitive, toString +// nor valueOf defined, then a TypeError exception should be thrown. +assert.throws( + TypeError, + function() { + String.prototype.trimEnd.call(thisVal); + } +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-call-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-call-err.js new file mode 100644 index 0000000000..a59c2cb84e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-call-err.js @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when getting Symbol.toPrimitive method +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + ... +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var thisVal = { + get [Symbol.toPrimitive]() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-meth-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-meth-err.js new file mode 100644 index 0000000000..7237a7f670 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-meth-err.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when Symbol.toPrimitive abrupt completes. +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ... +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: function() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-meth-priority.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-meth-priority.js new file mode 100644 index 0000000000..57f92112d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-meth-priority.js @@ -0,0 +1,82 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Priority of Symbol[toPrimitive] when converting object to string for trimming +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + ... +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + + +var toPrimitiveAccessed = 0; +var toStringAccessed = 0; +var valueOfAccessed = 0; +var thisVal = { + get [Symbol.toPrimitive]() { + toPrimitiveAccessed += 1; + return function() { + return '42 '; + }; + }, + get toString() { + toStringAccessed += 1; + return function() { + return ''; + }; + }, + get valueOf() { + valueOfAccessed += 1; + return function() { + return ''; + }; + }, +}; + +// Test that thisVal[Symbol.toPrimitive] has been called. + +var result = String.prototype.trimEnd.call(thisVal); + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal[Symbol.toPrimitive] expected to have been accessed.' +); +assert.sameValue( + result, + '42', + 'thisVal[Symbol.toPrimitive] expected to have been called.' +); + +// Test that thisVal.toString and thisVal.valueOf have not been accessedo + +assert.sameValue( + toStringAccessed, + 0, + 'thisVal.toString should not have been accessed.' +); +assert.sameValue( + valueOfAccessed, + 0, + 'thisVal.valueOf should not have been accessed.' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-returns-object-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-returns-object-err.js new file mode 100644 index 0000000000..7405357aec --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-toprimitive-returns-object-err.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when Symbol.toPrimitive returns an object +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If arguement is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + ... +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: function() { + return {}; + }, +}; + +assert.sameValue(typeof String.prototype.trimEnd, 'function'); +assert.throws(TypeError, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-call-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-call-err.js new file mode 100644 index 0000000000..9cff1caedf --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-call-err.js @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when getting toString method +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + get toString() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-meth-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-meth-err.js new file mode 100644 index 0000000000..3f19b7b84b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-meth-err.js @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when toString called and abrupt completes. +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: function() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-meth-priority.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-meth-priority.js new file mode 100644 index 0000000000..0a46f14354 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-meth-priority.js @@ -0,0 +1,99 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Priority of toString when converting object to string for trimming +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + ... +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var toPrimitiveAccessed = 0; +var toStringAccessed = 0; +var valueOfAccessed = 0; +var thisVal = { + get [Symbol.toPrimitive]() { + toPrimitiveAccessed += 1; + return undefined; + }, + get toString() { + toStringAccessed += 1; + return function() { + return '42 '; + }; + }, + get valueOf() { + valueOfAccessed += 1; + return function() { + return ''; + }; + }, +}; + +// Test that toString is called when Symbol.toPrimitive is undefined. + +var result = String.prototype.trimEnd.call(thisVal) + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal.toString expected to have been accessed.' +); +assert.sameValue( + result, + '42', + 'thisVal.toString expected to have been called.' +); + +// Test that thisVal[toPrimitive] has been accessed. + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal[Symbol.toPrimitive should have been accessed.' +); + +// Test that thisVal.valueOf has not been accessed. + +assert.sameValue( + valueOfAccessed, + 0, + 'thisVal.valueOf should not have been accessed.' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-returns-object-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-returns-object-err.js new file mode 100644 index 0000000000..1acf34e68d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-tostring-returns-object-err.js @@ -0,0 +1,59 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when toString called and returns an object +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: function() { + return {}; + }, +}; + +assert.sameValue(typeof String.prototype.trimEnd, 'function'); +assert.throws(TypeError, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-call-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-call-err.js new file mode 100644 index 0000000000..e9942b432b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-call-err.js @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when getting valueOf method +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + get valueOf() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-meth-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-meth-err.js new file mode 100644 index 0000000000..f143313869 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-meth-err.js @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when valueOf called and abrupt completes. +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf: function() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-meth-priority.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-meth-priority.js new file mode 100644 index 0000000000..45f4bc73c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-meth-priority.js @@ -0,0 +1,95 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Priority of valueOf when converting object to string for trimming +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + ... +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + +var toPrimitiveAccessed = 0; +var toStringAccessed = 0; +var valueOfAccessed = 0; +var thisVal = { + get [Symbol.toPrimitive]() { + toPrimitiveAccessed += 1; + return undefined; + }, + get toString() { + toStringAccessed += 1; + return undefined; + }, + get valueOf() { + valueOfAccessed += 1; + return function() { + return '42 '; + }; + }, +}; + +// Test that valueOf is called when Symbol.toPrimitive and toString are both +// undefined. + +var result = String.prototype.trimEnd.call(thisVal); + +assert.sameValue( + valueOfAccessed, + 1, + 'thisVal.toString expected to have been accessed.' +); +assert.sameValue( + result, + '42', + 'thisVal.valueOf expected to have been called.' +); + +// Test that thisVal[toPrimitive] and thisVal.toString has been accessed. + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal[Symbol.toPrimitive should have been accessed.' +); +assert.sameValue( + toStringAccessed, + 1, + 'thisVal[Symbol.toString should have been accessed.' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-returns-object-err.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-returns-object-err.js new file mode 100644 index 0000000000..00e4041850 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-object-valueof-returns-object-err.js @@ -0,0 +1,60 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: > + Abrupt completion when valueOf called and returns an object +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +features: [string-trimming, String.prototype.trimEnd, Symbol.toPrimitive] +---*/ + + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf: function() { + return {}; + }, +}; + +assert.sameValue(typeof String.prototype.trimEnd, 'function'); +assert.throws(TypeError, function() { + String.prototype.trimEnd.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-symbol-typeerror.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-symbol-typeerror.js new file mode 100644 index 0000000000..5150212023 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-symbol-typeerror.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: Type error when "this" value is a Symbol +info: | + Runtime Semantics: TrimString ( string, where ) + 2. Let S be ? ToString(str). + + ToString ( argument ) + Argument Type: Symbol + Result: Throw a TypeError exception +features: [string-trimming, String.prototype.trimEnd] +---*/ + +assert.sameValue(typeof String.prototype.trimEnd, "function"); + +var trimEnd = String.prototype.trimEnd; +var symbol = Symbol(); + +assert.throws( + TypeError, + function() { + trimEnd.call(symbol); + }, + 'String.prototype.trimEnd.call(Symbol())' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-whitespace.js b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-whitespace.js new file mode 100644 index 0000000000..27e8a832c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimEnd/this-value-whitespace.js @@ -0,0 +1,35 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimEnd +description: TrimEnd removes all whitespace from the end of a string. +info: | + Runtime Symantics: TrimString ( string, where ) + ... + 3. Else if where is "end", let T be a String value that is a copy of S with + trailing white space removed. + ... + + The definition of white space is the union of WhiteSpace and LineTerminator. + When determining whether a Unicode code point is in Unicode general category + “Zs”, code unit sequences are interpreted as UTF-16 encoded code point + sequences as specified in 6.1.4. + +features: [string-trimming, String.prototype.trimEnd] +---*/ + +var trimEnd = String.prototype.trimEnd; + +// A string of all valid WhiteSpace Unicode code points +var wspc = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + +var str = wspc + 'a' + wspc + 'b' + wspc; +var expected = wspc + 'a' + wspc + 'b'; + +assert.sameValue( + trimEnd.call(str), + expected +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/browser.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/length.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/length.js new file mode 100644 index 0000000000..3f0d76dfcc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + String.prototype.trimStart.length is 0. +info: > + String.prototype.trimStart ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [string-trimming, String.prototype.trimStart] +---*/ + +verifyProperty(String.prototype.trimStart, "length", { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/name.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/name.js new file mode 100644 index 0000000000..c75a9aa849 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/name.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + String.prototype.trimStart.name is "trimStart". +info: > + String.prototype.trimStart ( ) + + 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] +features: [string-trimming, String.prototype.trimStart] +---*/ + +verifyProperty(String.prototype.trimStart, "name", { + value: "trimStart", + enumerable: false, + writable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/not-a-constructor.js new file mode 100644 index 0000000000..fe6ba1ca22 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/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.trimStart 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, string-trimming, String.prototype.trimStart, arrow-function] +---*/ + +assert.sameValue( + isConstructor(String.prototype.trimStart), + false, + 'isConstructor(String.prototype.trimStart) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.trimStart(); +}, '`new String.prototype.trimStart()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/prop-desc.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/prop-desc.js new file mode 100644 index 0000000000..f005ff0351 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/prop-desc.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 The Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + "trimStart" property of String.prototype +info: > + 17 ECMAScript Standard Built-in Objects: + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [string-trimming, String.prototype.trimStart] +---*/ + +verifyProperty(String.prototype, "trimStart", { + enumerable: false, + writable: true, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/shell.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-boolean.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-boolean.js new file mode 100644 index 0000000000..3155491447 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-boolean.js @@ -0,0 +1,33 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: Behavior when "this" value is a boolean. +info: | + Runtime Semantics: TrimString ( string, where ) + 2. Let S be ? ToString(str). + + ToString ( argument ) + Argument Type: Boolean + Result: + If argument is true, return "true". + If argument is false, return "false". +features: [string-trimming, String.prototype.trimStart] +---*/ + +var trimStart = String.prototype.trimStart + +assert.sameValue( + trimStart.call(true), + 'true', + 'String.prototype.trimStart.call(true)' +); + +assert.sameValue( + String.prototype.trimStart.call(false), + 'false', + 'String.prototype.trimStart.call(false)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-line-terminator.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-line-terminator.js new file mode 100644 index 0000000000..03b30cf6c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-line-terminator.js @@ -0,0 +1,32 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: TrimStart removes all line terminators from the start of a string. +info: | + Runtime Symantics: TrimString ( string, where ) + ... + 4. If where is "start", let T be a String value that is a copy of S with + trailing white space removed. + ... + + The definition of white space is the union of WhiteSpace and LineTerminator. + +features: [string-trimming, String.prototype.trimStart] +---*/ + +var trimStart = String.prototype.trimStart; + +// A string of all valid LineTerminator Unicode code points +var lt = '\u000A\u000D\u2028\u2029'; + +var str = lt + 'a' + lt + 'b' + lt; +var expected = 'a' + lt + 'b' + lt; + +assert.sameValue( + trimStart.call(str), + expected +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..a4529c288a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-not-obj-coercible.js @@ -0,0 +1,24 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +features: [string-trimming, String.prototype.trimStart] +---*/ + +var trimStart = String.prototype.trimStart; + +assert.sameValue(typeof trimStart, 'function'); + +assert.throws(TypeError, function() { + trimStart.call(undefined); +}, 'undefined'); + +assert.throws(TypeError, function() { + trimStart.call(null); +}, 'null'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-number.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-number.js new file mode 100644 index 0000000000..c7cd5f4069 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-number.js @@ -0,0 +1,49 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: Behavoir when "this" value is a number. +info: | + Runtime Semantics: TrimString ( string, where ) + 2. Let S be ? ToString(str). + + ToString ( argument ) + Argument Type: Number + Result: NumberToString(argument) +features: [string-trimming, String.prototype.trimStart] +---*/ + +var trimStart = String.prototype.trimStart + +assert.sameValue( + trimStart.call(NaN), + 'NaN', + 'String.prototype.trimStart.call(NaN)' +); + +assert.sameValue( + trimStart.call(Infinity), + 'Infinity', + 'String.prototype.trimStart.call(Infinity)' +); + +assert.sameValue( + trimStart.call(-0), + '0', + 'String.prototype.trimStart.call(-0)' +); + +assert.sameValue( + trimStart.call(1), + '1', + 'String.prototype.trimStart.call(1)' +); + +assert.sameValue( + trimStart.call(-1), + '-1', + 'String.prototype.trimStart.call(-1)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-cannot-convert-to-primitive-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-cannot-convert-to-primitive-err.js new file mode 100644 index 0000000000..4d22cc7a5e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-cannot-convert-to-primitive-err.js @@ -0,0 +1,63 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + This value is an object which cannot be converted to a primitive +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +assert.sameValue(typeof String.prototype.trimStart, "function"); + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf: undefined, +}; + +// If trimStart is called on an object with neither Symbol.toPrimitive, toString +// nor valueOf defined, then a TypeError exception should be thrown. +assert.throws( + TypeError, + function() { + String.prototype.trimStart.call(thisVal); + } +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-call-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-call-err.js new file mode 100644 index 0000000000..643c261e54 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-call-err.js @@ -0,0 +1,36 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when getting Symbol.toPrimitive method +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + ... +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var thisVal = { + get [Symbol.toPrimitive]() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-meth-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-meth-err.js new file mode 100644 index 0000000000..f876d84ee5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-meth-err.js @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when Symbol.toPrimitive abrupt completes. +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ... +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: function() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-meth-priority.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-meth-priority.js new file mode 100644 index 0000000000..c21efdad18 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-meth-priority.js @@ -0,0 +1,82 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Priority of Symbol[toPrimitive] when converting object to string for trimming +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + ... +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + + +var toPrimitiveAccessed = 0; +var toStringAccessed = 0; +var valueOfAccessed = 0; +var thisVal = { + get [Symbol.toPrimitive]() { + toPrimitiveAccessed += 1; + return function() { + return ' 42'; + }; + }, + get toString() { + toStringAccessed += 1; + return function() { + return ''; + }; + }, + get valueOf() { + valueOfAccessed += 1; + return function() { + return ''; + }; + }, +}; + +// Test that thisVal[Symbol.toPrimitive] has been called. + +var result = String.prototype.trimStart.call(thisVal); + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal[Symbol.toPrimitive] expected to have been accessed.' +); +assert.sameValue( + result, + '42', + 'thisVal[Symbol.toPrimitive] expected to have been called.' +); + +// Test that thisVal.toString and thisVal.valueOf have not been accessedo + +assert.sameValue( + toStringAccessed, + 0, + 'thisVal.toString should not have been accessed.' +); +assert.sameValue( + valueOfAccessed, + 0, + 'thisVal.valueOf should not have been accessed.' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-returns-object-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-returns-object-err.js new file mode 100644 index 0000000000..383aab41f4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-toprimitive-returns-object-err.js @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when Symbol.toPrimitive returns an object +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If arguement is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive). + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + ... +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: function() { + return {}; + }, +}; + +assert.sameValue(typeof String.prototype.trimStart, 'function'); +assert.throws(TypeError, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-call-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-call-err.js new file mode 100644 index 0000000000..9328faecb3 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-call-err.js @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when getting toString method +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + get toString() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-meth-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-meth-err.js new file mode 100644 index 0000000000..eb57861be9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-meth-err.js @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when toString called and abrupt completes. +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: function() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-meth-priority.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-meth-priority.js new file mode 100644 index 0000000000..dda76b4a1f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-meth-priority.js @@ -0,0 +1,99 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Priority of toString when converting object to string for trimming +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + ... +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var toPrimitiveAccessed = 0; +var toStringAccessed = 0; +var valueOfAccessed = 0; +var thisVal = { + get [Symbol.toPrimitive]() { + toPrimitiveAccessed += 1; + return undefined; + }, + get toString() { + toStringAccessed += 1; + return function() { + return ' 42'; + }; + }, + get valueOf() { + valueOfAccessed += 1; + return function() { + return ''; + }; + }, +}; + +// Test that toString is called when Symbol.toPrimitive is undefined. + +var result = String.prototype.trimStart.call(thisVal) + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal.toString expected to have been accessed.' +); +assert.sameValue( + result, + '42', + 'thisVal.toString expected to have been called.' +); + +// Test that thisVal[toPrimitive] has been accessed. + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal[Symbol.toPrimitive should have been accessed.' +); + +// Test that thisVal.valueOf has not been accessed. + +assert.sameValue( + valueOfAccessed, + 0, + 'thisVal.valueOf should not have been accessed.' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-returns-object-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-returns-object-err.js new file mode 100644 index 0000000000..82c9165a52 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-tostring-returns-object-err.js @@ -0,0 +1,59 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when toString called and returns an object +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: function() { + return {}; + }, +}; + +assert.sameValue(typeof String.prototype.trimStart, 'function'); +assert.throws(TypeError, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-call-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-call-err.js new file mode 100644 index 0000000000..6b839b83df --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-call-err.js @@ -0,0 +1,54 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when getting valueOf method +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). +features: [string-trimming, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + get valueOf() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-err.js new file mode 100644 index 0000000000..075fb607a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-err.js @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when valueOf called and abrupt completes. +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf: function() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-priority.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-priority.js new file mode 100644 index 0000000000..682578f6e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-priority.js @@ -0,0 +1,95 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Priority of valueOf when converting object to string for trimming +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + ... +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + +var toPrimitiveAccessed = 0; +var toStringAccessed = 0; +var valueOfAccessed = 0; +var thisVal = { + get [Symbol.toPrimitive]() { + toPrimitiveAccessed += 1; + return undefined; + }, + get toString() { + toStringAccessed += 1; + return undefined; + }, + get valueOf() { + valueOfAccessed += 1; + return function() { + return ' 42'; + }; + }, +}; + +// Test that valueOf is called when Symbol.toPrimitive and toString are both +// undefined. + +var result = String.prototype.trimStart.call(thisVal); + +assert.sameValue( + valueOfAccessed, + 1, + 'thisVal.toString expected to have been accessed.' +); +assert.sameValue( + result, + '42', + 'thisVal.valueOf expected to have been called.' +); + +// Test that thisVal[toPrimitive] and thisVal.toString has been accessed. + +assert.sameValue( + toPrimitiveAccessed, + 1, + 'thisVal[Symbol.toPrimitive should have been accessed.' +); +assert.sameValue( + toStringAccessed, + 1, + 'thisVal[Symbol.toString should have been accessed.' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-returns-object-err.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-returns-object-err.js new file mode 100644 index 0000000000..9205faaddc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-object-valueof-returns-object-err.js @@ -0,0 +1,60 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: > + Abrupt completion when valueOf called and returns an object +info: | + Runtime Semantics: TrimString ( string, where ) + 1. Let str be ? RequireObjectCoercible(string). + 2. Let S be ? ToString(str). + ... + + ToString ( argument ) + If argument is Object: + 1. Let primValue be ? ToPrimitive(argument, hint String). + ... + + ToPrimitive ( input [, PreferredType ]) + ... + b. Else if PreferredType is hint String, let hint be "string". + ... + d. Let exoticToPrim be ? GetMethod(input, @@toPrimitive) + e. If exoticToPrim is not undefined, then + i. Let result be ? Call(exoticToPrim, input, « hint »). + ii. If Type(result) is not Object, return result. + iii. Throw a TypeError exception. + f. If hint is "default", set hint to "number". + g. Return ? OrdinaryToPrimitive(input, hint). + ... + + OrdinaryToPrimitive( O, hint ) + ... + 3. If hint is "string", then + a. Let methodNames be « "toString", "valueOf" ». + ... + 5. For each name in methodNames in List order, do + a. Let method be ? Get(O, name). + b. If IsCallable(method) is true, then + i. Let result be ? Call(method, O). + ii. If Type(result) is not Object, return result. + 6. Throw a TypeError exception. +features: [string-trimming, String.prototype.trimStart, Symbol.toPrimitive] +---*/ + + +var thisVal = { + [Symbol.toPrimitive]: undefined, + toString: undefined, + valueOf: function() { + return {}; + }, +}; + +assert.sameValue(typeof String.prototype.trimStart, 'function'); +assert.throws(TypeError, function() { + String.prototype.trimStart.call(thisVal); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js new file mode 100644 index 0000000000..95e3e3fa38 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: Type error when "this" value is a Symbol +info: | + Runtime Semantics: TrimString ( string, where ) + 2. Let S be ? ToString(str). + + ToString ( argument ) + Argument Type: Symbol + Result: Throw a TypeError exception +features: [string-trimming, String.prototype.trimStart] +---*/ + +assert.sameValue(typeof String.prototype.trimStart, "function"); + +var trimStart = String.prototype.trimStart; +var symbol = Symbol(); + +assert.throws( + TypeError, + function() { + trimStart.call(symbol); + }, + 'String.prototype.trimStart.call(Symbol())' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-whitespace.js b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-whitespace.js new file mode 100644 index 0000000000..2a83025d6c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/trimStart/this-value-whitespace.js @@ -0,0 +1,35 @@ +// Copyright (c) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.trimStart +description: TrimStart removes all whitespace from the start of a string. +info: | + Runtime Symantics: TrimString ( string, where ) + ... + 3. If where is "start", let T be a String value that is a copy of S with + trailing white space removed. + ... + + The definition of white space is the union of WhiteSpace and LineTerminator. + When determining whether a Unicode code point is in Unicode general category + “Zs”, code unit sequences are interpreted as UTF-16 encoded code point + sequences as specified in 6.1.4. + +features: [string-trimming, String.prototype.trimStart] +---*/ + +var trimStart = String.prototype.trimStart; + +// A string of all valid WhiteSpace Unicode code points +var wspc = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + +var str = wspc + 'a' + wspc + 'b' + wspc; +var expected = 'a' + wspc + 'b' + wspc; + +assert.sameValue( + trimStart.call(str), + expected +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/browser.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/length.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/length.js new file mode 100644 index 0000000000..9655e6500f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.valueof +description: > + String.prototype.valueOf.length is 0. +info: | + String.prototype.valueOf ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(String.prototype.valueOf, 'length', { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/name.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/name.js new file mode 100644 index 0000000000..e5ae351739 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.valueof +description: > + String.prototype.valueOf.name is "valueOf". +info: | + String.prototype.valueOf ( ) + + 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] +---*/ + +verifyProperty(String.prototype.valueOf, 'name', { + value: 'valueOf', + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/non-generic-realm.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/non-generic-realm.js new file mode 100644 index 0000000000..31caef4a3a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/non-generic-realm.js @@ -0,0 +1,60 @@ +// Copyright (C) 2019 Aleksey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.valueof +description: > + Throws a TypeError if called on neither String primitive nor String object + (honoring the Realm of the current execution context) +info: | + String.prototype.valueOf ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + [...] + 3. Throw a TypeError exception. +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var otherValueOf = other.String.prototype.valueOf; + +assert.throws(other.TypeError, function() { + otherValueOf.call(false); +}); + +assert.throws(other.TypeError, function() { + otherValueOf.call(-1); +}); + +assert.throws(other.TypeError, function() { + otherValueOf.call(null); +}); + +assert.throws(other.TypeError, function() { + otherValueOf.call(); +}); + +assert.throws(other.TypeError, function() { + otherValueOf.call(Symbol('desc')); +}); + +assert.throws(other.TypeError, function() { + otherValueOf.call({ + valueOf: function() { + return ''; + }, + }); +}); + +assert.throws(other.TypeError, function() { + otherValueOf.call([3]); +}); + +assert.throws(other.TypeError, function() { + '' + {valueOf: otherValueOf}; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/non-generic.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/non-generic.js new file mode 100644 index 0000000000..761655d04d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/non-generic.js @@ -0,0 +1,57 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.valueof +description: > + Throws a TypeError if called on neither String primitive nor String object +info: | + String.prototype.valueOf ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + [...] + 3. Throw a TypeError exception. +---*/ + +var valueOf = String.prototype.valueOf; + +assert.throws(TypeError, function() { + valueOf.call(true); +}); + +assert.throws(TypeError, function() { + valueOf.call(-0); +}); + +assert.throws(TypeError, function() { + valueOf.call(null); +}); + +assert.throws(TypeError, function() { + valueOf.call(); +}); + +assert.throws(TypeError, function() { + valueOf.call(Symbol('desc')); +}); + +assert.throws(TypeError, function() { + valueOf.call({ + toString: function() { + return 'str'; + }, + }); +}); + +assert.throws(TypeError, function() { + valueOf.call(['s', 't', 'r']); +}); + +assert.throws(TypeError, function() { + 'str' + {valueOf: valueOf}; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/not-a-constructor.js new file mode 100644 index 0000000000..81afa416d4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/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.valueOf 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.valueOf), + false, + 'isConstructor(String.prototype.valueOf) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.valueOf(); +}, '`new String.prototype.valueOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/shell.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/string-object.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/string-object.js new file mode 100644 index 0000000000..68ae989392 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/string-object.js @@ -0,0 +1,28 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.valueof +description: > + If called on a String object, returns [[StringData]] slot +info: | + String.prototype.valueOf ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + [...] + 2. If Type(value) is Object and value has a [[StringData]] internal slot, then + a. Let s be value.[[StringData]]. + b. Assert: Type(s) is String. + c. Return s. +---*/ + +var valueOf = String.prototype.valueOf; + +assert.sameValue(Object('').valueOf(), ''); +assert.sameValue(valueOf.call(new String('str')), 'str'); +assert.sameValue('a' + new String('b'), 'ab'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/valueOf/string-primitive.js b/js/src/tests/test262/built-ins/String/prototype/valueOf/string-primitive.js new file mode 100644 index 0000000000..8d951a9cfc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/valueOf/string-primitive.js @@ -0,0 +1,23 @@ +// Copyright (C) 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.valueof +description: > + If called on String primitive, returns it +info: | + String.prototype.valueOf ( ) + + 1. Return ? thisStringValue(this value). + + thisStringValue ( value ) + + 1. If Type(value) is String, return value. +---*/ + +var valueOf = String.prototype.valueOf; + +assert.sameValue('str'.valueOf(), 'str'); +assert.sameValue(valueOf.call(''), ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/browser.js b/js/src/tests/test262/built-ins/String/raw/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/browser.js diff --git a/js/src/tests/test262/built-ins/String/raw/length.js b/js/src/tests/test262/built-ins/String/raw/length.js new file mode 100644 index 0000000000..deb433fde5 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + String.raw.length value and property descriptor +info: | + String.raw ( template , ...substitutions ) + + The length property of the raw function is 1. +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.raw.length, 1, + 'The value of `String.raw.length` is `1`' +); + +verifyNotEnumerable(String.raw, 'length'); +verifyNotWritable(String.raw, 'length'); +verifyConfigurable(String.raw, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/name.js b/js/src/tests/test262/built-ins/String/raw/name.js new file mode 100644 index 0000000000..c7533e923b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/name.js @@ -0,0 +1,24 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + String.raw.name value and property descriptor +info: | + String.raw ( template , ...substitutions ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + String.raw.name, 'raw', + 'The value of `String.raw.name` is `"raw"`' +); + +verifyNotEnumerable(String.raw, 'name'); +verifyNotWritable(String.raw, 'name'); +verifyConfigurable(String.raw, 'name'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/nextkey-is-symbol-throws.js b/js/src/tests/test262/built-ins/String/raw/nextkey-is-symbol-throws.js new file mode 100644 index 0000000000..3a670b367e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/nextkey-is-symbol-throws.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Throws a TypeError if nextKey is Symbol +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + ... +features: [Symbol] +---*/ + +var obj = { + raw: { + length: 1, + '0': Symbol('') + } +}; + +assert.throws(TypeError, function() { + String.raw(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/not-a-constructor.js b/js/src/tests/test262/built-ins/String/raw/not-a-constructor.js new file mode 100644 index 0000000000..6beda7f32f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/not-a-constructor.js @@ -0,0 +1,31 @@ +// 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.raw 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.raw), false, 'isConstructor(String.raw) must return false'); + +assert.throws(TypeError, () => { + new String.raw({raw: []}, []); +}, '`new String.raw({raw: []}, [])` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/raw.js b/js/src/tests/test262/built-ins/String/raw/raw.js new file mode 100644 index 0000000000..c36ee8484a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/raw.js @@ -0,0 +1,19 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + String.raw property descriptor +info: | + String.raw ( template , ...substitutions ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(String, 'raw'); +verifyWritable(String, 'raw'); +verifyConfigurable(String, 'raw'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-from-empty-array-length.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-from-empty-array-length.js new file mode 100644 index 0000000000..7d286f958d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-from-empty-array-length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw an empty Array +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: [] +}); + +assert.sameValue(result, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-negative-infinity.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-negative-infinity.js new file mode 100644 index 0000000000..099e52e5d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-negative-infinity.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length is -Infinity +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: { + length: -Infinity + } +}); + +assert.sameValue(result, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-not-defined.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-not-defined.js new file mode 100644 index 0000000000..c3ebe55b92 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-not-defined.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length isn't defined. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: {} +}); + +assert.sameValue(result, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-undefined.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-undefined.js new file mode 100644 index 0000000000..1a4041535f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-undefined.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length isn't defined. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: { + length: undefined + } +}); + +assert.sameValue(result, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-NaN.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-NaN.js new file mode 100644 index 0000000000..e129f9e968 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-NaN.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length is NaN +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: { + length: NaN + } +}); + +assert.sameValue(result, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-boolean.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-boolean.js new file mode 100644 index 0000000000..9eb98d7f0f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-boolean.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length is false +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: { + length: false + } +}); + +assert.sameValue(result, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-null.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-null.js new file mode 100644 index 0000000000..e31a22b9bd --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-null.js @@ -0,0 +1,25 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length is null +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: { + length: null + } +}); + +assert.sameValue(result, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-number.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-number.js new file mode 100644 index 0000000000..14d3cfad11 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-number.js @@ -0,0 +1,45 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length is <= 0 +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: { + length: 0 + } +}); +assert.sameValue(result, '', 'result is an empty string when length == 0'); + +result = String.raw({ + raw: { + length: -1 + } +}); +assert.sameValue(result, '', 'result is an empty string when length == -1'); + +result = String.raw({ + raw: { + length: -0 + } +}); +assert.sameValue(result, '', 'result is an empty string when length == -0'); + +result = String.raw({ + raw: { + length: 0.32 + } +}); +assert.sameValue(result, '', 'result is an empty string when length == 0.32'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-string.js b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-string.js new file mode 100644 index 0000000000..c0190abb2f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-empty-string-if-length-is-zero-or-less-string.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns empty string if template.raw.length is <= 0 +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). + 9. If literalSegments ≤ 0, return the empty string. + ... +---*/ + +var result = String.raw({ + raw: { + length: '0' + } +}); +assert.sameValue(result, '', 'result is an empty string when length == "0"'); + +result = String.raw({ + raw: { + length: '-1' + } +}); +assert.sameValue(result, '', 'result is an empty string when length == "-1"'); + +result = String.raw({ + raw: { + length: '' + } +}); +assert.sameValue(result, '', 'result is an empty string when length == ""'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-the-string-value-from-template.js b/js/src/tests/test262/built-ins/String/raw/return-the-string-value-from-template.js new file mode 100644 index 0000000000..c8a8c5175c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-the-string-value-from-template.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns the string value. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + d. Append in order the code unit elements of nextSeg to the end of + stringElements. + e. If nextIndex + 1 = literalSegments, then + i. Return the String value whose code units are, in order, the elements in + the List stringElements. If stringElements has no elements, the empty + string is returned. + ... +---*/ + +assert.sameValue(String.raw`123\u0065`, '123\\u0065'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/return-the-string-value.js b/js/src/tests/test262/built-ins/String/raw/return-the-string-value.js new file mode 100644 index 0000000000..48ca631777 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/return-the-string-value.js @@ -0,0 +1,41 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns the string value without substitutions arguments and limited to the + given length. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + d. Append in order the code unit elements of nextSeg to the end of + stringElements. + e. If nextIndex + 1 = literalSegments, then + i. Return the String value whose code units are, in order, the elements in + the List stringElements. If stringElements has no elements, the empty + string is returned. + ... +---*/ + +var obj = { + raw: { + length: 5, + 0: '\u0065', + 1: '', + 2: null, + 3: undefined, + 4: 123, + 5: 'overpass the length' + } +}; + +assert.sameValue(String.raw(obj), 'enullundefined123'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-next-key-toString.js b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-next-key-toString.js new file mode 100644 index 0000000000..5d39385342 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-next-key-toString.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns abrupt from nextKey. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + ... +---*/ + +var obj = { + raw: { + length: 1, + '0': { + toString: function() { + throw new Test262Error(); + } + } + } +}; + +assert.throws(Test262Error, function() { + String.raw(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-next-key.js b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-next-key.js new file mode 100644 index 0000000000..e044e2c222 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-next-key.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns abrupt from nextKey. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + ... +---*/ + +var obj = { + raw: { + length: 2 + } +}; + +Object.defineProperty(obj.raw, '0', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); + +assert.throws(Test262Error, function() { + String.raw(obj); +}); + +delete obj.raw['0']; +obj.raw['0'] = 'a'; +Object.defineProperty(obj.raw, '1', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + String.raw(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-substitution-symbol.js b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-substitution-symbol.js new file mode 100644 index 0000000000..5c3590880e --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-substitution-symbol.js @@ -0,0 +1,45 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns the abrupt from ToString(substitutions[nextIndex]) using a Symbol + value. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + d. Append in order the code unit elements of nextSeg to the end of + stringElements. + e. If nextIndex + 1 = literalSegments, then + i. Return the String value whose code units are, in order, the elements in + the List stringElements. If stringElements has no elements, the empty + string is returned. + f. If nextIndex < numberOfSubstitutions, let next be substitutions[nextIndex]. + g. Else, let next be the empty String. + h. Let nextSub be ToString(next). + i. ReturnIfAbrupt(nextSub). + j. Append in order the code unit elements of nextSub to the end of stringElements. + k. Let nextIndex be nextIndex + 1. +features: [Symbol] +---*/ + +var template = { + raw: ['a', 'b', 'c'] +}; + +assert.throws(TypeError, function() { + String.raw(template, '', Symbol('')); +}); + +assert.throws(TypeError, function() { + String.raw(template, Symbol(''), ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-substitution.js b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-substitution.js new file mode 100644 index 0000000000..42c2ad7f90 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/returns-abrupt-from-substitution.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns the abrupt from ToString(substitutions[nextIndex]). +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + d. Append in order the code unit elements of nextSeg to the end of + stringElements. + e. If nextIndex + 1 = literalSegments, then + i. Return the String value whose code units are, in order, the elements in + the List stringElements. If stringElements has no elements, the empty + string is returned. + f. If nextIndex < numberOfSubstitutions, let next be substitutions[nextIndex]. + g. Else, let next be the empty String. + h. Let nextSub be ToString(next). + i. ReturnIfAbrupt(nextSub). + j. Append in order the code unit elements of nextSub to the end of stringElements. + k. Let nextIndex be nextIndex + 1. +---*/ + +var template = { + raw: ['a', 'b', 'c'] +}; +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + String.raw(template, '', obj); +}); + +assert.throws(Test262Error, function() { + String.raw(template, obj, ''); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/shell.js b/js/src/tests/test262/built-ins/String/raw/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/shell.js diff --git a/js/src/tests/test262/built-ins/String/raw/special-characters.js b/js/src/tests/test262/built-ins/String/raw/special-characters.js new file mode 100644 index 0000000000..c2c2696e5a --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/special-characters.js @@ -0,0 +1,23 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + When used as a tag function of a tagged template, `String.raw` should + return the "raw" representation of the template. +---*/ + +assert.sameValue( + String.raw`\u0065\`\r\r\n\n${'test'}check`, + '\\u0065\\`\\r\\r\\n\\ntestcheck', + 'Unicode escape sequences' +); +assert.sameValue( + String.raw`\
\
+\ +`, + '\\\n\\\n\\\n', + 'Literal characters' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/substitutions-are-appended-on-same-index.js b/js/src/tests/test262/built-ins/String/raw/substitutions-are-appended-on-same-index.js new file mode 100644 index 0000000000..96e8839422 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/substitutions-are-appended-on-same-index.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns the string value appending the substitutions on the same index order. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + d. Append in order the code unit elements of nextSeg to the end of + stringElements. + e. If nextIndex + 1 = literalSegments, then + i. Return the String value whose code units are, in order, the elements in + the List stringElements. If stringElements has no elements, the empty + string is returned. + f. If nextIndex < numberOfSubstitutions, let next be substitutions[nextIndex]. + g. Else, let next be the empty String. + h. Let nextSub be ToString(next). + i. ReturnIfAbrupt(nextSub). + j. Append in order the code unit elements of nextSub to the end of stringElements. + k. Let nextIndex be nextIndex + 1. +---*/ + +var template = { + raw: ['a', 'b', 'd', 'f'] +}; + +assert.sameValue(String.raw(template, '', 'c', 'e'), 'abcdef'); +assert.sameValue(String.raw(template, 1), 'a1bdf'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/substitutions-are-limited-to-template-raw-length.js b/js/src/tests/test262/built-ins/String/raw/substitutions-are-limited-to-template-raw-length.js new file mode 100644 index 0000000000..95e54cc048 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/substitutions-are-limited-to-template-raw-length.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Limit appended substitutions arguments to template.raw.length - 1. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + d. Append in order the code unit elements of nextSeg to the end of + stringElements. + e. If nextIndex + 1 = literalSegments, then + i. Return the String value whose code units are, in order, the elements in + the List stringElements. If stringElements has no elements, the empty + string is returned. + ... +---*/ + +var template = { + raw: ['a', 'c', 'e'] +}; +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +assert.sameValue(String.raw(template, 'b', 'd', obj), 'abcde'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/template-length-is-symbol-throws.js b/js/src/tests/test262/built-ins/String/raw/template-length-is-symbol-throws.js new file mode 100644 index 0000000000..eda07012cc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/template-length-is-symbol-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns abrupt completion from ToLength(template.raw.length). +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + 1. Let substitutions be a List consisting of all of the arguments passed to + this function, starting with the second argument. If fewer than two arguments + were passed, the List is empty. + 2. Let numberOfSubstitutions be the number of elements in substitutions. + 3. Let cooked be ToObject(template). + 4. ReturnIfAbrupt(cooked). + 5. Let raw be ToObject(Get(cooked, "raw")). + 6. ReturnIfAbrupt(raw). + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + String.raw({ + raw: { + length: Symbol(1) + } + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/template-length-throws.js b/js/src/tests/test262/built-ins/String/raw/template-length-throws.js new file mode 100644 index 0000000000..eed53e6406 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/template-length-throws.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns abrupt completion from ToObject(template.raw.length). +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + 1. Let substitutions be a List consisting of all of the arguments passed to + this function, starting with the second argument. If fewer than two arguments + were passed, the List is empty. + 2. Let numberOfSubstitutions be the number of elements in substitutions. + 3. Let cooked be ToObject(template). + 4. ReturnIfAbrupt(cooked). + 5. Let raw be ToObject(Get(cooked, "raw")). + 6. ReturnIfAbrupt(raw). + 7. Let literalSegments be ToLength(Get(raw, "length")). + 8. ReturnIfAbrupt(literalSegments). +---*/ + +var obj = { + raw: {} +}; +Object.defineProperty(obj.raw, 'length', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + String.raw(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/template-not-object-throws.js b/js/src/tests/test262/built-ins/String/raw/template-not-object-throws.js new file mode 100644 index 0000000000..7be8b829fb --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/template-not-object-throws.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. +/*--- +es6id: 21.1.2.4 +description: > + Returns abrupt completion from ToObject(template). +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + 1. Let substitutions be a List consisting of all of the arguments passed to + this function, starting with the second argument. If fewer than two arguments + were passed, the List is empty. + 2. Let numberOfSubstitutions be the number of elements in substitutions. + 3. Let cooked be ToObject(template). + 4. ReturnIfAbrupt(cooked). +---*/ + +assert.throws(TypeError, function() { + String.raw(null); +}); + +assert.throws(TypeError, function() { + String.raw(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/template-raw-not-object-throws.js b/js/src/tests/test262/built-ins/String/raw/template-raw-not-object-throws.js new file mode 100644 index 0000000000..9bb391d907 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/template-raw-not-object-throws.js @@ -0,0 +1,32 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns abrupt completion from ToObject(template.raw). +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + 1. Let substitutions be a List consisting of all of the arguments passed to + this function, starting with the second argument. If fewer than two arguments + were passed, the List is empty. + 2. Let numberOfSubstitutions be the number of elements in substitutions. + 3. Let cooked be ToObject(template). + 4. ReturnIfAbrupt(cooked). + 5. Let raw be ToObject(Get(cooked, "raw")). + 6. ReturnIfAbrupt(raw). +---*/ + +assert.throws(TypeError, function() { + String.raw({ + raw: undefined + }); +}); + +assert.throws(TypeError, function() { + String.raw({ + raw: null + }); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/template-raw-throws.js b/js/src/tests/test262/built-ins/String/raw/template-raw-throws.js new file mode 100644 index 0000000000..b53ad01b5b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/template-raw-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns abrupt completion from ToObject(template.raw). +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + 1. Let substitutions be a List consisting of all of the arguments passed to + this function, starting with the second argument. If fewer than two arguments + were passed, the List is empty. + 2. Let numberOfSubstitutions be the number of elements in substitutions. + 3. Let cooked be ToObject(template). + 4. ReturnIfAbrupt(cooked). + 5. Let raw be ToObject(Get(cooked, "raw")). + 6. ReturnIfAbrupt(raw). +---*/ + +var obj = {}; +Object.defineProperty(obj, 'raw', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + String.raw(obj); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/template-substitutions-are-appended-on-same-index.js b/js/src/tests/test262/built-ins/String/raw/template-substitutions-are-appended-on-same-index.js new file mode 100644 index 0000000000..d956f17d9f --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/template-substitutions-are-appended-on-same-index.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + Returns the string value appending from the same index order using String.raw + as a tag function. +info: | + 21.1.2.4 String.raw ( template , ...substitutions ) + + ... + 10. Let stringElements be a new List. + 11. Let nextIndex be 0. + 12. Repeat + a. Let nextKey be ToString(nextIndex). + b. Let nextSeg be ToString(Get(raw, nextKey)). + c. ReturnIfAbrupt(nextSeg). + d. Append in order the code unit elements of nextSeg to the end of + stringElements. + e. If nextIndex + 1 = literalSegments, then + i. Return the String value whose code units are, in order, the elements in + the List stringElements. If stringElements has no elements, the empty + string is returned. + f. If nextIndex < numberOfSubstitutions, let next be substitutions[nextIndex]. + g. Else, let next be the empty String. + h. Let nextSub be ToString(next). + i. ReturnIfAbrupt(nextSub). + j. Append in order the code unit elements of nextSub to the end of stringElements. + k. Let nextIndex be nextIndex + 1. +---*/ + +assert.sameValue(String.raw`1${2}3${4}5`, '12345'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/raw/zero-literal-segments.js b/js/src/tests/test262/built-ins/String/raw/zero-literal-segments.js new file mode 100644 index 0000000000..5960e26120 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/raw/zero-literal-segments.js @@ -0,0 +1,11 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.2.4 +description: > + If literalSegments ≤ 0, return the empty string. +---*/ + +assert.sameValue(String.raw``, ''); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/shell.js b/js/src/tests/test262/built-ins/String/shell.js new file mode 100644 index 0000000000..eda1477282 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/shell.js @@ -0,0 +1,24 @@ +// GENERATED, DO NOT EDIT +// file: isConstructor.js +// Copyright (C) 2017 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Test if a given function is a constructor function. +defines: [isConstructor] +features: [Reflect.construct] +---*/ + +function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + + try { + Reflect.construct(function(){}, [], f); + } catch (e) { + return false; + } + return true; +} diff --git a/js/src/tests/test262/built-ins/String/symbol-string-coercion.js b/js/src/tests/test262/built-ins/String/symbol-string-coercion.js new file mode 100644 index 0000000000..db77775d9d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/symbol-string-coercion.js @@ -0,0 +1,20 @@ +// 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-constructor +description: Symbol value may be coerced to a String +info: | + 1. If no arguments were passed to this function invocation, let s be "". + 2. Else, + a. If NewTarget is undefined and Type(value) is Symbol, return + SymbolDescriptiveString(value). +features: [Symbol] +---*/ + +assert.sameValue(String(Symbol('66')), 'Symbol(66)'); +assert.sameValue(String(Symbol()), 'Symbol()', 'implicit `undefined`'); +assert.sameValue( + String(Symbol(undefined)), 'Symbol()', 'explicit `undefined`' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/symbol-wrapping.js b/js/src/tests/test262/built-ins/String/symbol-wrapping.js new file mode 100644 index 0000000000..7385ebba9b --- /dev/null +++ b/js/src/tests/test262/built-ins/String/symbol-wrapping.js @@ -0,0 +1,21 @@ +// Copyright (C) 2013 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string-constructor +description: Symbol value may not be wrapped +info: | + 1. If no arguments were passed to this function invocation, let s be "". + 2. Else, + a. If NewTarget is undefined and Type(value) is Symbol, return + SymbolDescriptiveString(value). + b. Let s be ? ToString(value). +features: [Symbol] +---*/ + +var s = Symbol('66'); + +assert.throws(TypeError, function() { + new String(s); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/Symbol.toStringTag.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..aaf583e57e --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/Symbol.toStringTag.js @@ -0,0 +1,25 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.5.2.2 +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the string value "String + Iterator". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +features: [Symbol.iterator, Symbol.toStringTag] +includes: [propertyHelper.js] +---*/ + +var StringIteratorProto = Object.getPrototypeOf(''[Symbol.iterator]()); + +assert.sameValue(StringIteratorProto[Symbol.toStringTag], 'String Iterator'); + +verifyNotEnumerable(StringIteratorProto, Symbol.toStringTag); +verifyNotWritable(StringIteratorProto, Symbol.toStringTag); +verifyConfigurable(StringIteratorProto, Symbol.toStringTag); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/ancestry.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/ancestry.js new file mode 100644 index 0000000000..62b10215ae --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/ancestry.js @@ -0,0 +1,18 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.5.2 +description: > + The [[Prototype]] internal slot ofthe %StringIteratorPrototype% is the + %IteratorPrototype% intrinsic object (25.1.2). +features: [Symbol.iterator] +---*/ + +var strItrProto = Object.getPrototypeOf(''[Symbol.iterator]()); +var itrProto = Object.getPrototypeOf( + Object.getPrototypeOf([][Symbol.iterator]()) +); + +assert.sameValue(Object.getPrototypeOf(strItrProto), itrProto); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/browser.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/browser.js diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/browser.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/browser.js diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/length.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/length.js new file mode 100644 index 0000000000..6facc1101b --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/length.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 21.1.5.2.1 +description: > + %StringIteratorPrototype%.next.length is 0. +info: | + %StringIteratorPrototype%.next ( ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this + value is equal to the largest number of named arguments shown in the + subclause headings for the function description, including optional + parameters. However, rest parameters shown using the form “...name” + are not included in the default argument count. + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.iterator] +---*/ + +var StringIteratorProto = Object.getPrototypeOf(new String()[Symbol.iterator]()); + +assert.sameValue(StringIteratorProto.next.length, 0); + +verifyNotEnumerable(StringIteratorProto.next, "length"); +verifyNotWritable(StringIteratorProto.next, "length"); +verifyConfigurable(StringIteratorProto.next, "length"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/name.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/name.js new file mode 100644 index 0000000000..f990a85d2f --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/name.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 21.1.5.2.1 +description: > + %StringIteratorPrototype%.next.name is "next". +info: | + %StringIteratorPrototype%.next ( ) + + 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] +features: [Symbol.iterator] +---*/ + +var StringIteratorProto = Object.getPrototypeOf(new String()[Symbol.iterator]()); + +assert.sameValue(StringIteratorProto.next.name, "next"); + +verifyNotEnumerable(StringIteratorProto.next, "name"); +verifyNotWritable(StringIteratorProto.next, "name"); +verifyConfigurable(StringIteratorProto.next, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-iteration-surrogate-pairs.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-iteration-surrogate-pairs.js new file mode 100644 index 0000000000..07cd36feca --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-iteration-surrogate-pairs.js @@ -0,0 +1,86 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.5.2.1 +description: > + Iteration should respect UTF-16-encoded Unicode code points specified via + surrogate pairs. +features: [Symbol.iterator] +---*/ + +var lo = '\uD834'; +var hi = '\uDF06'; +var pair = lo + hi; +var string = 'a' + pair + 'b' + lo + pair + hi + lo; +var iterator = string[Symbol.iterator](); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 'a', 'First normal code point `value`'); +assert.sameValue(result.done, false, 'First normal code point `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, pair, 'Surrogate pair `value` (between normal code points)' +); +assert.sameValue( + result.done, false, 'Surrogate pair `done` flag (between normal code points)' +); + +result = iterator.next(); +assert.sameValue(result.value, 'b', 'Second normal code point `value`'); +assert.sameValue(result.done, false, 'Second normal code point `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, + lo, + 'Lone lower code point `value` (following normal code point)' +); +assert.sameValue( + result.done, + false, + 'Lone lower code point `done` flag (following normal code point)' +); + +result = iterator.next(); +assert.sameValue( + result.value, + pair, + 'Surrogate pair `value` (between lone lower- and upper- code points)' +); +assert.sameValue( + result.done, + false, + 'Surrogate pair `done` flag (between lone lower- and upper- code points)' +); + +result = iterator.next(); +assert.sameValue(result.value, hi, 'Lone upper code point `value`'); +assert.sameValue(result.done, false, 'Lone upper code point `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, + lo, + 'Lone lower code point `value` (following lone upper code point)' +); +assert.sameValue( + result.done, + false, + 'Lone lower code point `done` flag (following lone upper code point)' +); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-iteration.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-iteration.js new file mode 100644 index 0000000000..9b04368887 --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-iteration.js @@ -0,0 +1,38 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 21.1.5.2.1 +description: > + Iteration should visit each UTF-8 code point exactly once. +features: [Symbol.iterator] +---*/ + +var string = "abc"; +var iterator = string[Symbol.iterator](); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 'a', 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 'b', 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 'c', 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-missing-internal-slots.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-missing-internal-slots.js new file mode 100644 index 0000000000..888cde7aa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/next-missing-internal-slots.js @@ -0,0 +1,24 @@ +// Copyright (C) 2014 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-string-iterator-instances +description: > + If the `this` value does not have all of the internal slots of an String + Iterator Instance (21.1.5.3), throw a `TypeError` exception. +info: | + ... + If O does not have all of the internal slots of a String Iterator Instance (21.1.5.3), + throw a TypeError exception. + ... + +features: [Symbol.iterator] +---*/ + +var iterator = ''[Symbol.iterator](); +var object = Object.create(iterator); + +assert.throws(TypeError, function() { + object.next(); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/next/shell.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/next/shell.js diff --git a/js/src/tests/test262/built-ins/StringIteratorPrototype/shell.js b/js/src/tests/test262/built-ins/StringIteratorPrototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/StringIteratorPrototype/shell.js |