diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/String/prototype/slice | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/slice')
38 files changed, 947 insertions, 0 deletions
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); |