diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/lastIndexOf')
26 files changed, 723 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A10.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A10.js new file mode 100644 index 0000000000..b3d53f4bc6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A10.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The String.prototype.lastIndexOf.length property has the attribute + ReadOnly +es5id: 15.5.4.8_A10 +description: > + Checking if varying the String.prototype.lastIndexOf.length + property fails +includes: [propertyHelper.js] +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.lastIndexOf.hasOwnProperty('length'))) { + throw new Test262Error('#1: String.prototype.lastIndexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +var __obj = String.prototype.lastIndexOf.length; + +verifyNotWritable(String.prototype.lastIndexOf, "length", null, function() { + return "shifted"; +}); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.lastIndexOf.length !== __obj) { + throw new Test262Error('#2: __obj = String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length = function(){return "shifted";}; String.prototype.lastIndexOf.length === __obj. Actual: ' + String.prototype.lastIndexOf.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A11.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A11.js new file mode 100644 index 0000000000..c1805c8009 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A11.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: The length property of the lastIndexOf method is 1 +es5id: 15.5.4.8_A11 +description: Checking String.prototype.lastIndexOf.length +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!(String.prototype.lastIndexOf.hasOwnProperty("length"))) { + throw new Test262Error('#1: String.prototype.lastIndexOf.hasOwnProperty("length") return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty("length")); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.lastIndexOf.length !== 1) { + throw new Test262Error('#2: String.prototype.lastIndexOf.length === 1. Actual: ' + String.prototype.lastIndexOf.length); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T1.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T1.js new file mode 100644 index 0000000000..4251d7d213 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T1.js @@ -0,0 +1,22 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T1 +description: Arguments are false and true, and instance is object +---*/ + +var __instance = new Object(true); + +__instance.lastIndexOf = String.prototype.lastIndexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.lastIndexOf(true, false) !== 0) { + throw new Test262Error('#1: __instance = new Object(true); __instance.lastIndexOf = String.prototype.lastIndexOf; __instance.lastIndexOf(true, false) === 0. Actual: ' + __instance.lastIndexOf(true, false)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T10.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T10.js new file mode 100644 index 0000000000..fcf2b12f24 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T10.js @@ -0,0 +1,34 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T10 +description: > + Call lastIndexOf(searchString, position) function with object + arguments +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return NaN; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__str.lastIndexOf(__obj, __obj2) !== 7) { + throw new Test262Error('#1: var x; var __obj = {toString:function(){return "\u0041B";}}; var __obj2 = {valueOf:function(){return NaN;}}; var __str = "ABB\u0041BABAB";lastIndexOf(__obj, __obj2) === 7. Actual: ' + __str.lastIndexOf(__obj, __obj2)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T12.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T12.js new file mode 100644 index 0000000000..eff60d1894 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T12.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T12 +description: Argument is string, and instance is array of strings +---*/ + +var __instance = new Array('new', 'zoo', 'revue'); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.lastIndexOf('new') !== 0) { + throw new Test262Error('#1: __instance = new Array(\'new\',\'zoo\',\'revue\'); __instance.lastIndexOf(\'new\') === 0. Actual: ' + __instance.lastIndexOf('new')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (__instance.lastIndexOf('zoo') !== 1) { + throw new Test262Error('#2: __instance = new Array(\'new\',\'zoo\',\'revue\'); __instance.lastIndexOf(\'zoo\') === 1. Actual: ' + __instance.lastIndexOf('zoo')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T2.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T2.js new file mode 100644 index 0000000000..714bbaaa3c --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T2.js @@ -0,0 +1,28 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T2 +description: > + Arguments are boolean equation, function and null, and instance is + Boolean object +---*/ + +var __instance = new Boolean; + +__instance.lastIndexOf = String.prototype.lastIndexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (__instance.lastIndexOf("A" !== "\u0041", function() { + return 0; + }(), null) !== 0) { + throw new Test262Error('#1: __instance = new Boolean; __instance.lastIndexOf = String.prototype.lastIndexOf; __instance.lastIndexOf("A"!=="\\u0041", function(){return 0;}(),null) === 0. Actual: ' + __instance.lastIndexOf("A" !== "\u0041", function() { + return 0; + }(), null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T4.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T4.js new file mode 100644 index 0000000000..e89a5a0902 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T4.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T4 +description: > + Call lastIndexOf(searchString, position) function without + arguments of string +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString() evaluates to "" lastIndexOf() evaluates to lastIndexOf("",0) +if ("".lastIndexOf() !== -1) { + throw new Test262Error('#1: "".lastIndexOf() === -1. Actual: ' + ("".lastIndexOf())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T5.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T5.js new file mode 100644 index 0000000000..6e2f0811c4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T5.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T5 +description: > + Call lastIndexOf(searchString, position) function with null + argument of function object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(null) evaluates to "null" lastIndexOf(null) evaluates to lastIndexOf("",0) +if (function() { + return "gnullunazzgnull" + }().lastIndexOf(null) !== 11) { + throw new Test262Error('#1: function(){return "gnullunazzgnull"}().lastIndexOf(null) === 11. Actual: ' + function() { + return "gnullunazzgnull" + }().lastIndexOf(null)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T6.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T6.js new file mode 100644 index 0000000000..90b28bc8b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T6.js @@ -0,0 +1,23 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T6 +description: > + Call lastIndexOf(searchString, position) function with x argument + of new String object, where x is undefined variable +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "" lastIndexOf(undefined) evaluates to lastIndexOf("",0) +if (new String("undefined").lastIndexOf(x) !== 0) { + throw new Test262Error('#1: var x; new String("undefined").lastIndexOf(x) === 0. Actual: ' + new String("undefined").lastIndexOf(x)); +} +// +////////////////////////////////////////////////////////////////////////////// + +var x; + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T7.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T7.js new file mode 100644 index 0000000000..c8f5af9551 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T7.js @@ -0,0 +1,21 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T7 +description: > + Call lastIndexOf(searchString, position) function with undefined + argument of string object +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" lastIndexOf(undefined) evaluates to lastIndexOf("undefined",0) +if (String("undefined").lastIndexOf(undefined) !== 0) { + throw new Test262Error('#1: String("undefined").lastIndexOf(undefined) === 0. Actual: ' + String("undefined").lastIndexOf(undefined)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T8.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T8.js new file mode 100644 index 0000000000..e048c8fc7d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T8.js @@ -0,0 +1,25 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T8 +description: > + Call lastIndexOf(searchString, position) function with void 0 + argument of string object +---*/ + +var __obj = { + toString: function() {} +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(void 0) evaluates to "undefined" lastIndexOf(void 0) evaluates to lastIndexOf("undefined",0) +if (String(__obj).lastIndexOf(void 0) !== 0) { + throw new Test262Error('#1: __obj = {toString:function(){}}; String(__obj).lastIndexOf(void 0) === 0. Actual: ' + String(__obj).lastIndexOf(void 0)); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T9.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T9.js new file mode 100644 index 0000000000..942f54a2a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A1_T9.js @@ -0,0 +1,26 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf(searchString, position) +es5id: 15.5.4.8_A1_T9 +description: > + Call lastIndexOf(searchString, position) function with + function(){}() argument of string object +---*/ + +var __obj = { + valueOf: function() {}, + toString: void 0 +}; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +//since ToString(undefined) evaluates to "undefined" indexOf(undefined) evaluates to indexOf("undefined") +if (new String(__obj).lastIndexOf(function() {}()) !== 0) { + throw new Test262Error('#1: __obj = {valueOf:function(){}, toString:void 0}; new String(__obj).lastIndexOf(function(){}()) === 0. Actual: ' + new String(__obj).lastIndexOf(function() {}())); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T1.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T1.js new file mode 100644 index 0000000000..da1ba6bd97 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T1.js @@ -0,0 +1,37 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T1 +description: Override toString and valueOf functions, valueOf throw exception +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + throw "intointeger"; + } +} +var __str = "ABB\u0041BABAB"; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __str.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intointeger") { + throw new Test262Error('#1.1: Exception === "intointeger". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T2.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T2.js new file mode 100644 index 0000000000..a75fbedea6 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T2.js @@ -0,0 +1,42 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T2 +description: > + Override toString and valueOf functions, second toString throw + exception +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return {}; + }, + toString: function() { + throw "intointeger"; + } +} +var __str = new String("ABB\u0041BABAB"); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __str.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __str.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intointeger") { + throw new Test262Error('#1.1: Exception === "intointeger". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T3.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T3.js new file mode 100644 index 0000000000..944857f3f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T3.js @@ -0,0 +1,32 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T3 +description: Override toString and valueOf functions +---*/ + +var __obj = { + toString: function() { + return "\u0041B"; + } +} +var __obj2 = { + valueOf: function() { + return {}; + }, + toString: function() {} +} + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if ("ABB\u0041BABAB".lastIndexOf(__obj, __obj2) !== 7) { + throw new Test262Error('#1: var __obj = {toString:function(){return "\u0041B";}}; var __obj2 = {valueOf:function(){return {};},toString:function(){}}; "ABB\\u0041BABAB".lastIndexOf(__obj, __obj2)===7. Actual: ' + ("ABB\u0041BABAB".lastIndexOf(__obj, __obj2))); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T4.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T4.js new file mode 100644 index 0000000000..7994195012 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T4.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T4 +description: Override toString and valueOf functions, and they throw exceptions +---*/ + +var __obj = { + toString: function() { + throw "intostr"; + } +}; +var __obj2 = { + valueOf: function() { + throw "intoint"; + } +}; +var __instance = new Number(10001.10001); +Number.prototype.lastIndexOf = String.prototype.lastIndexOf; + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __instance.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T5.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T5.js new file mode 100644 index 0000000000..4921647303 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A4_T5.js @@ -0,0 +1,56 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + when String.prototype.lastIndexOf(searchString, position) is called first Call ToString, giving it the this value as its argument. + Then Call ToString(searchString) and Call ToNumber(position) +es5id: 15.5.4.8_A4_T5 +description: > + Override toString and valueOf functions, first and second valueOf + throw exception +---*/ + +var __obj = { + toString: function() { + return {}; + }, + valueOf: function() { + throw "intostr"; + } +}; + +var __obj2 = { + valueOf: function() { + throw "intointeger"; + } +}; + +__FACTORY.prototype.lastIndexOf = String.prototype.lastIndexOf; + +var __instance = new __FACTORY(void 0); + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +try { + var x = __instance.lastIndexOf(__obj, __obj2); + throw new Test262Error('#1: var x = __instance.lastIndexOf(__obj, __obj2) lead to throwing exception'); +} catch (e) { + if (e !== "intostr") { + throw new Test262Error('#1.1: Exception === "intostr". Actual: ' + e); + } +} +// +////////////////////////////////////////////////////////////////////////////// + +function __FACTORY(value) { + this.value = value; + this.toString = function() { + return new Number; + }; + this.valueOf = function() { + return this.value + "" + }; +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A6.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A6.js new file mode 100644 index 0000000000..8bd0287c74 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A6.js @@ -0,0 +1,18 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf has not prototype property +es5id: 15.5.4.8_A6 +description: Checking String.prototype.lastIndexOf.prototype +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (String.prototype.lastIndexOf.prototype !== undefined) { + throw new Test262Error('#1: String.prototype.lastIndexOf.prototype === undefined. Actual: ' + String.prototype.lastIndexOf.prototype); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A7.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A7.js new file mode 100644 index 0000000000..0838bbcd81 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A7.js @@ -0,0 +1,16 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: String.prototype.lastIndexOf can't be used as constructor +es5id: 15.5.4.8_A7 +description: Checking if creating the String.prototype.lastIndexOf object fails +---*/ + +var FACTORY = String.prototype.lastIndexOf; + +assert.throws(TypeError, function() { + new FACTORY; +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A8.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A8.js new file mode 100644 index 0000000000..ab788685bc --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A8.js @@ -0,0 +1,45 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The String.prototype.lastIndexOf.length property has the attribute + DontEnum +es5id: 15.5.4.8_A8 +description: > + Checking if enumerating the String.prototype.lastIndexOf.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.lastIndexOf.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.lastIndexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////////// +// CHECK#1 +if (String.prototype.lastIndexOf.propertyIsEnumerable('length')) { + throw new Test262Error('#1: String.prototype.lastIndexOf.propertyIsEnumerable(\'length\') return false. Actual: ' + String.prototype.lastIndexOf.propertyIsEnumerable('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// CHECK#2 +var count = 0; + +for (var p in String.prototype.lastIndexOf) { + if (p === "length") count++; +} + +if (count !== 0) { + throw new Test262Error('#2: count=0; for (p in String.prototype.lastIndexOf){if (p==="length") count++;}; count === 0. Actual: ' + count); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A9.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A9.js new file mode 100644 index 0000000000..d592c5357d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/S15.5.4.8_A9.js @@ -0,0 +1,38 @@ +// Copyright 2009 the Sputnik authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + The String.prototype.lastIndexOf.length property does not have the + attribute DontDelete +es5id: 15.5.4.8_A9 +description: > + Checking if deleting the String.prototype.lastIndexOf.length + property fails +---*/ + +////////////////////////////////////////////////////////////////////////////// +//CHECK#0 +if (!(String.prototype.lastIndexOf.hasOwnProperty('length'))) { + throw new Test262Error('#0: String.prototype.lastIndexOf.hasOwnProperty(\'length\') return true. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#1 +if (!delete String.prototype.lastIndexOf.length) { + throw new Test262Error('#1: delete String.prototype.lastIndexOf.length return true'); +} +// +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +//CHECK#2 +if (String.prototype.lastIndexOf.hasOwnProperty('length')) { + throw new Test262Error('#2: delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.hasOwnProperty(\'length\') return false. Actual: ' + String.prototype.lastIndexOf.hasOwnProperty('length')); +} +// +////////////////////////////////////////////////////////////////////////////// + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/browser.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/browser.js diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js new file mode 100644 index 0000000000..62353147a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es6id: 21.1.3.9 +description: > + String.prototype.lastIndexOf.name is "lastIndexOf". +info: | + String.prototype.lastIndexOf ( searchString [ , position ] ) + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value + is a String. + + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(String.prototype.lastIndexOf.name, "lastIndexOf"); + +verifyNotEnumerable(String.prototype.lastIndexOf, "name"); +verifyNotWritable(String.prototype.lastIndexOf, "name"); +verifyConfigurable(String.prototype.lastIndexOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js new file mode 100644 index 0000000000..14485de716 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/not-a-constructor.js @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + String.prototype.lastIndexOf does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects + + Built-in function objects that are not identified as constructors do not + implement the [[Construct]] internal method unless otherwise specified in + the description of a particular function. + + sec-evaluatenew + + ... + 7. If IsConstructor(constructor) is false, throw a TypeError exception. + ... +includes: [isConstructor.js] +features: [Reflect.construct, arrow-function] +---*/ + +assert.sameValue( + isConstructor(String.prototype.lastIndexOf), + false, + 'isConstructor(String.prototype.lastIndexOf) must return false' +); + +assert.throws(TypeError, () => { + new String.prototype.lastIndexOf(); +}, '`new String.prototype.lastIndexOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/shell.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/shell.js diff --git a/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js new file mode 100644 index 0000000000..e8ceaa298d --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/lastIndexOf/this-value-not-obj-coercible.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.lastindexof +description: The "this" value must be object-coercible +info: | + 1. Let O be ? RequireObjectCoercible(this value). +---*/ + +var lastIndexOf = String.prototype.lastIndexOf; + +assert.sameValue(typeof lastIndexOf, 'function'); + +assert.throws(TypeError, function() { + lastIndexOf.call(undefined, ''); +}, 'undefined'); + +assert.throws(TypeError, function() { + lastIndexOf.call(null, ''); +}, 'null'); + +reportCompare(0, 0); |