diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/substring')
46 files changed, 1148 insertions, 0 deletions
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); |