diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/lastIndexOf')
197 files changed, 4298 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js new file mode 100644 index 0000000000..f4385f56f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to undefined throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(undefined); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js new file mode 100644 index 0000000000..9d791295f8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the Math object +---*/ + +Math.length = 2; +Math[1] = 100; + +assert.sameValue(Array.prototype.lastIndexOf.call(Math, 100), 1, 'Array.prototype.lastIndexOf.call(Math, 100)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js new file mode 100644 index 0000000000..ba3a3046b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Date object +---*/ + +var obj = new Date(); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js new file mode 100644 index 0000000000..ad8fdee8d0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to RegExp object +---*/ + +var obj = new RegExp("afdasf"); +obj.length = 100; +obj[1] = "afdasf"; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, "afdasf"), 1, 'Array.prototype.lastIndexOf.call(obj, "afdasf")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js new file mode 100644 index 0000000000..0c1b6d06ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the JSON object +---*/ + +var targetObj = {}; + +JSON[3] = targetObj; +JSON.length = 5; + +assert.sameValue(Array.prototype.lastIndexOf.call(JSON, targetObj), 3, 'Array.prototype.lastIndexOf.call(JSON, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js new file mode 100644 index 0000000000..c4ff1e4c1d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Error object +---*/ + +var obj = new SyntaxError(); +obj.length = 2; +obj[1] = Infinity; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, Infinity), 1, 'Array.prototype.lastIndexOf.call(obj, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js new file mode 100644 index 0000000000..2fd89b80d1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the Arguments object +---*/ + +var obj = (function fun() { + return arguments; +}(1, 2, 3)); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js new file mode 100644 index 0000000000..ab7a152285 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to null throws a TypeError +---*/ + + +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(null); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js new file mode 100644 index 0000000000..d662edf0e0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to boolean primitive +---*/ + +Boolean.prototype[1] = true; +Boolean.prototype.length = 2; + +assert.sameValue(Array.prototype.lastIndexOf.call(true, true), 1, 'Array.prototype.lastIndexOf.call(true, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js new file mode 100644 index 0000000000..7f11852e14 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Boolean object +---*/ + +var obj = new Boolean(false); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js new file mode 100644 index 0000000000..d2432b9b22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to number primitive +---*/ + +Number.prototype[1] = isNaN; +Number.prototype.length = 2; + +assert.sameValue(Array.prototype.lastIndexOf.call(5, isNaN), 1, 'Array.prototype.lastIndexOf.call(5, isNaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js new file mode 100644 index 0000000000..6cd70edfd6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Number object +---*/ + +var obj = new Number(-3); +obj.length = 2; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js new file mode 100644 index 0000000000..5fa4fa5da9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to string primitive +---*/ + +assert.sameValue(Array.prototype.lastIndexOf.call("abc", "c"), 2, 'Array.prototype.lastIndexOf.call("abc", "c")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js new file mode 100644 index 0000000000..8a94cd4945 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to String object +---*/ + +var obj = new String("undefined"); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, "f"), 4, 'Array.prototype.lastIndexOf.call(obj, "f")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js new file mode 100644 index 0000000000..d01b502e5d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Function object +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js new file mode 100644 index 0000000000..1b26440d04 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property on an + Array-like object +---*/ + +var obj = { + 1: null, + 2: undefined, + length: 2 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), 1, 'Array.prototype.lastIndexOf.call(obj, null)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), -1, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js new file mode 100644 index 0000000000..672f273669 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is inherited accessor + property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = 1; +child[2] = 2; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, 1), 1, 'Array.prototype.lastIndexOf.call(child, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(child, 2), -1, 'Array.prototype.lastIndexOf.call(child, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js new file mode 100644 index 0000000000..e5008d2ffb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + without a get function on an Array-like object +---*/ + +var obj = { + 0: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js new file mode 100644 index 0000000000..a9bbce058e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + without a get function that overrides an inherited accessor + property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 20; + }, + configurable: true +}); + +var obj = { + 1: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js new file mode 100644 index 0000000000..dcecfb9241 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is inherited accessor + property without a get function on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[0] = true; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, true), -1, 'Array.prototype.lastIndexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js new file mode 100644 index 0000000000..58062484b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is undefined property on an + Array-like object +---*/ + +var obj = { + 0: null, + 1: undefined +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), -1, 'Array.prototype.lastIndexOf.call(obj, null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js new file mode 100644 index 0000000000..5e29cd9be5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method +---*/ + +var targetObj = function() {}; +var func = function(a, b) { + arguments[2] = function() {}; + return Array.prototype.lastIndexOf.call(arguments, targetObj) === 1 && + Array.prototype.lastIndexOf.call(arguments, arguments[2]) === -1; +}; + +assert(func(0, targetObj), 'func(0, targetObj) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js new file mode 100644 index 0000000000..90c8ee9d56 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to String object which + implements its own property get method +---*/ + +var str = new String("012"); + +String.prototype[3] = "3"; + +assert.sameValue(Array.prototype.lastIndexOf.call(str, "2"), 2, 'Array.prototype.lastIndexOf.call(str, "2")'); +assert.sameValue(Array.prototype.lastIndexOf.call(str, "3"), -1, 'Array.prototype.lastIndexOf.call(str, "3")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js new file mode 100644 index 0000000000..6278205ca0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to String object which + implements its own property get method +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = "b"; +obj[2] = "c"; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, obj[1]), 1, 'Array.prototype.lastIndexOf.call(obj, obj[1])'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, obj[2]), -1, 'Array.prototype.lastIndexOf.call(obj, obj[2])'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js new file mode 100644 index 0000000000..53f995706d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property on an + Array +---*/ + +var targetObj = {}; + +Array.prototype[2] = targetObj; + +assert.sameValue([0, targetObj].lastIndexOf(targetObj), 1, '[0, targetObj].lastIndexOf(targetObj)'); +assert.sameValue([0, 1].lastIndexOf(targetObj), -1, '[0, 1].lastIndexOf(targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js new file mode 100644 index 0000000000..b280836efe --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property that + overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.length = 2; +child[1] = child; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, child), 1, 'Array.prototype.lastIndexOf.call(child, child)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js new file mode 100644 index 0000000000..7289b10cef --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf when 'length' is own data property + that overrides an inherited data property on an Array +---*/ + +var targetObj = {}; +var arrProtoLen; + +arrProtoLen = Array.prototype.length; +Array.prototype.length = 0; + +assert.sameValue([0, targetObj, 2].lastIndexOf(targetObj), 1, '[0, targetObj, 2].lastIndexOf(targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js new file mode 100644 index 0000000000..342a9b7b38 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property that + overrides an inherited accessor property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); + +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[1] = null; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, null), 1, 'Array.prototype.lastIndexOf.call(child, null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js new file mode 100644 index 0000000000..c667d16d54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is an inherited data + property on an Array-like object +---*/ + +var proto = { + length: 2 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = "x"; +child[2] = "y"; + +assert.sameValue(Array.prototype.lastIndexOf.call(child, "x"), 1, 'Array.prototype.lastIndexOf.call(child, "x")'); +assert.sameValue(Array.prototype.lastIndexOf.call(child, "y"), -1, 'Array.prototype.lastIndexOf.call(child, "y")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js new file mode 100644 index 0000000000..c288c87c01 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property on + an Array-like object +---*/ + +var obj = { + 1: true, + 2: false +}; + +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js new file mode 100644 index 0000000000..6bc99e9075 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + that overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = eval; + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(child, eval), 1, 'Array.prototype.lastIndexOf.call(child, eval)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js new file mode 100644 index 0000000000..eeaf5fea4e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + that overrides an inherited accessor property on an Array-like + object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child[1] = true; + +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(child, true), 1, 'Array.prototype.lastIndexOf.call(child, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js new file mode 100644 index 0000000000..f86e3f5311 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - value of 'length' is undefined +---*/ + +var obj = { + 0: 1, + 1: 1, + length: undefined +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js new file mode 100644 index 0000000000..a5c9bddfda --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is NaN) +---*/ + +var obj = { + 0: 0, + length: NaN +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), -1, 'Array.prototype.lastIndexOf.call(obj, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js new file mode 100644 index 0000000000..c86e83fedb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing positive number +---*/ + +var obj = { + 1: true, + 2: false, + length: "2" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js new file mode 100644 index 0000000000..354a3df9a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing negative number +---*/ + +var obj = { + 1: null, + 2: undefined, + length: "-4294967294" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, null), -1, 'Array.prototype.lastIndexOf.call(obj, null)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), -1, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js new file mode 100644 index 0000000000..e5e15da4a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing a decimal number +---*/ + +var obj = { + 4: 4, + 5: 5, + length: "5.512345" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 4), 4, 'Array.prototype.lastIndexOf.call(obj, 4)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 5), -1, 'Array.prototype.lastIndexOf.call(obj, 5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js new file mode 100644 index 0000000000..efae423b3d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing -Infinity +---*/ + +var objThree = { + 0: true, + 1: true, + length: "-Infinity" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(objThree, true), -1, 'Array.prototype.lastIndexOf.call(objThree, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js new file mode 100644 index 0000000000..ad686a0d7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing an exponential number +---*/ + +var obj = { + 229: 229, + 230: 2.3E2, + length: "2.3E2" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 229), 229, 'Array.prototype.lastIndexOf.call(obj, 229)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2.3E2), -1, 'Array.prototype.lastIndexOf.call(obj, 2.3E2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js new file mode 100644 index 0000000000..8a834a9473 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string which + is able to be converted into hex number +---*/ + +var obj = { + 2573: 2573, + 2574: 0x000A0E, + length: "0x000A0E" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2573), 2573, 'Array.prototype.lastIndexOf.call(obj, 2573)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0x000A0E), -1, 'Array.prototype.lastIndexOf.call(obj, 0x000A0E)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js new file mode 100644 index 0000000000..00f1012438 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing a number with leading zeros +---*/ + +var obj = { + 1: 1, + 2: 2, + length: "0002.0" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js new file mode 100644 index 0000000000..913eef31ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string that + can't convert to a number +---*/ + +var targetObj = new String("123abc123"); +var obj = { + 0: targetObj, + length: "123abc123" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js new file mode 100644 index 0000000000..fd1ee62626 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is an Object which + has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +var targetObj = this; +var obj = { + 1: targetObj, + 2: 2, + + length: { + toString: function() { + return '2'; + } + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js new file mode 100644 index 0000000000..025ec6cb7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf return -1 when value of 'length' is a + boolean (value is true) +---*/ + +var obj = { + 0: 0, + 1: 1, + length: true +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), -1, 'Array.prototype.lastIndexOf.call(obj, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js new file mode 100644 index 0000000000..880f103161 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is an Object which + has an own valueOf method +---*/ + +//valueOf method will be invoked first, since hint is Number +var obj = { + 1: true, + 2: 2, + + length: { + valueOf: function() { + return 2; + } + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), -1, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js new file mode 100644 index 0000000000..274586c363 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is an object that has an + own valueOf method that returns an object and toString method that + returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var targetObj = this; +var obj = { + 1: targetObj, + length: { + toString: function() { + toStringAccessed = true; + return '3'; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js new file mode 100644 index 0000000000..69b038aec8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf throws TypeError exception when + 'length' is an object with toString and valueOf methods that don�t + return primitive values +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var obj = { + 1: true, + length: { + toString: function() { + toStringAccessed = true; + return {}; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; + +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(obj, true); +}); + +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js new file mode 100644 index 0000000000..af48742adb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js @@ -0,0 +1,40 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf uses inherited valueOf method when + 'length' is an object with an own toString and an inherited + valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 2; +}; + +var obj = { + 1: child, + length: child +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, child), 1, 'Array.prototype.lastIndexOf.call(obj, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js new file mode 100644 index 0000000000..ed6f48f6f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var obj = { + 122: true, + 123: false, + length: 123.5 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 122, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js new file mode 100644 index 0000000000..585ab0d4c7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a negative + non-integer +---*/ + +var obj = { + 1: true, + 2: false, + length: -4294967294.5 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), -1, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, false), -1, 'Array.prototype.lastIndexOf.call(obj, false)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js new file mode 100644 index 0000000000..24ea851f8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is boundary value + (2^32) +---*/ + +var targetObj = {}; +var obj = { + 0: targetObj, + 4294967294: targetObj, + 4294967295: targetObj, + length: 4294967296 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), 4294967295, 'verify length is 4294967296 finally'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js new file mode 100644 index 0000000000..de944fac4f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is 0) +---*/ + +var obj = { + 0: "undefined", + length: 0 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, "undefined"), -1, 'Array.prototype.lastIndexOf.call(obj, "undefined")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js new file mode 100644 index 0000000000..34a8125362 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is -0) +---*/ + +var obj = { + 0: true, + length: -0 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), -1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js new file mode 100644 index 0000000000..6afbbdf2ed --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is +0) +---*/ + +var obj = { + 0: +0, + length: +0 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, +0), -1, 'Array.prototype.lastIndexOf.call(obj, +0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js new file mode 100644 index 0000000000..8eda321c5c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is a positive number) +---*/ + +var obj = { + 99: true, + 100: 100, + length: 100 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 99, 'Array.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 100), -1, 'Array.prototype.lastIndexOf.call(obj, 100)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js new file mode 100644 index 0000000000..1927b2a448 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is a negative number) +---*/ + +var obj = { + 4: -Infinity, + 5: Infinity, + length: 5 - Math.pow(2, 32) +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, -Infinity), -1, 'Array.prototype.lastIndexOf.call(obj, -Infinity)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, Infinity), -1, 'Array.prototype.lastIndexOf.call(obj, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js new file mode 100644 index 0000000000..30c8ef8f83 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is -Infinity) +---*/ + +var obj = { + 0: 0, + length: -Infinity +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), -1, 'Array.prototype.lastIndexOf.call(obj, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js new file mode 100644 index 0000000000..bfb23e02ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (empty + array) +---*/ + +var i = [].lastIndexOf(42); + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js new file mode 100644 index 0000000000..5f8f630970 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is a number of value -6e-1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: -6e-1 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js new file mode 100644 index 0000000000..c61d585b22 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is an empty string +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: "" +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js new file mode 100644 index 0000000000..4d0ede9e0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + overridden to null (type conversion)) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: null +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js new file mode 100644 index 0000000000..baa7664f32 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (length + overridden to false (type conversion)) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: false +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js new file mode 100644 index 0000000000..c244013353 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (generic + 'array' with length 0 ) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; + +var i = Array.prototype.lastIndexOf.call({ + length: 0 +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js new file mode 100644 index 0000000000..0e714da0d2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + overridden to '0' (type conversion)) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: '0' +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js new file mode 100644 index 0000000000..a306208a54 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +var i = Array.prototype.lastIndexOf.call({ + length: { + valueOf: function() { + return 0; + } + } +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js new file mode 100644 index 0000000000..427740b352 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + is object overridden with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new Array(1, 2, 3); + +function foo() {} +var f = new foo(); + +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var i = Array.prototype.lastIndexOf.call({ + length: { + toString: function() { + return '0'; + } + } +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js new file mode 100644 index 0000000000..cf499e8c88 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (length is + an empty array) +---*/ + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var i = Array.prototype.lastIndexOf.call({ + length: [] +}, 1); + + +assert.sameValue(i, -1, 'i'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js new file mode 100644 index 0000000000..8f45c25286 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is a number of value 0.1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: 0.1 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, targetObj), -1, 'Array.prototype.lastIndexOf.call(obj, targetObj)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js new file mode 100644 index 0000000000..d3cdfb1cc3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is string +---*/ + +var a = new Array(0, 1, 1); + +assert.sameValue(a.lastIndexOf(1, "1"), 1, '"1" resolves to 1'); +assert.sameValue(a.lastIndexOf(1, "one"), -1, 'NaN string resolves to 01'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js new file mode 100644 index 0000000000..54e6f8d483 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is positive number) +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js new file mode 100644 index 0000000000..a7ba8fac31 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is negative number) +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js new file mode 100644 index 0000000000..d43456a631 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is Infinity) +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = null; // length is the max value of Uint type + +assert.sameValue(arr.lastIndexOf(null, Infinity), Math.pow(2, 32) - 2, 'arr.lastIndexOf(null, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js new file mode 100644 index 0000000000..8dd7c0b72d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is -Infinity) +---*/ + +assert.sameValue([true].lastIndexOf(true, -Infinity), -1, '[true].lastIndexOf(true, -Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js new file mode 100644 index 0000000000..719c88cd1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is NaN) +---*/ + +// from Index will be convert to +0 +assert.sameValue([0, true].lastIndexOf(true, NaN), -1, '[0, true].lastIndexOf(true, NaN)'); +assert.sameValue([true, 0].lastIndexOf(true, NaN), 0, '[true, 0].lastIndexOf(true, NaN)'); +assert.sameValue([0, true].lastIndexOf(true, -NaN), -1, '[0, true].lastIndexOf(true, -NaN)'); +assert.sameValue([true, 0].lastIndexOf(true, -NaN), 0, '[true, 0].lastIndexOf(true, -NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js new file mode 100644 index 0000000000..5e0bea2c89 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing a negative number +---*/ + +assert.sameValue([0, "-2", 2].lastIndexOf("-2", "-2"), 1, '[0, "-2", 2].lastIndexOf("-2", "-2")'); +assert.sameValue([0, 2, "-2"].lastIndexOf("-2", "-2"), -1, '[0, 2, "-2"].lastIndexOf("-2", "-2")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js new file mode 100644 index 0000000000..3732ca9a21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing Infinity +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = true; // length is the max value of Uint type + +assert.sameValue(arr.lastIndexOf(true, "Infinity"), Math.pow(2, 32) - 2, 'arr.lastIndexOf(true, "Infinity")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js new file mode 100644 index 0000000000..cbb216b417 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing -Infinity +---*/ + +assert.sameValue([true].lastIndexOf(true, "-Infinity"), -1, '[true].lastIndexOf(true, "-Infinity")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js new file mode 100644 index 0000000000..f38439c1c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing an exponential number +---*/ + +var targetObj = {}; + +assert.sameValue([0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0"), 2, '[0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0")'); +assert.sameValue([0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0"), -1, '[0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js new file mode 100644 index 0000000000..6045c3150d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing a hex number +---*/ + +var targetObj = {}; + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002")'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js new file mode 100644 index 0000000000..81044c0f9a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is floating point number +---*/ + +var a = new Array(1, 2, 1); + +assert.sameValue(a.lastIndexOf(2, 1.49), 1, '1.49 resolves to 1'); +assert.sameValue(a.lastIndexOf(2, 0.51), -1, '0.51 resolves to 0'); +assert.sameValue(a.lastIndexOf(1, 0.51), 0, '0.51 resolves to 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js new file mode 100644 index 0000000000..d4aeda529e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is a + string containing a number with leading zeros +---*/ + +var targetObj = {}; + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10")'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js new file mode 100644 index 0000000000..135ca125b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is an + Object, and has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var fromIndex = { + toString: function() { + return '2'; + } +}; +var targetObj = new RegExp(); + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js new file mode 100644 index 0000000000..66c7181a62 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is an + object, and has an own valueOf method +---*/ + +var fromIndex = { + valueOf: function() { + return 2; + } +}; + +var targetObj = function() {}; + +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js new file mode 100644 index 0000000000..5b47483aba --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is an object + that has an own valueOf method that returns an object and toString + method that returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var fromIndex = { + toString: function() { + toStringAccessed = true; + return '1'; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; + +assert.sameValue([0, true].lastIndexOf(true, fromIndex), 1, '[0, true].lastIndexOf(true, fromIndex)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js new file mode 100644 index 0000000000..241fd28960 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js @@ -0,0 +1,34 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf throws TypeError exception when value + of 'fromIndex' is an object that both toString and valueOf methods + than don't return primitive value +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var fromIndex = { + toString: function() { + toStringAccessed = true; + return {}; + }, + + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; + +assert.throws(TypeError, function() { + [0, null].lastIndexOf(null, fromIndex); +}); + +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js new file mode 100644 index 0000000000..880fd7b678 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf use inherited valueOf method when + value of 'fromIndex' is an object with an own toString and + inherited valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; + +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 1; + } +}; + +var Con = function() {}; +Con.prototype = proto; + +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 1; +}; + +assert.sameValue([0, true].lastIndexOf(true, child), 1, '[0, true].lastIndexOf(true, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js new file mode 100644 index 0000000000..99f034bb86 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js @@ -0,0 +1,38 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepTwoOccurs = false; +var stepFiveOccurs = false; +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + stepTwoOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; + +Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); + +assert(stepTwoOccurs, 'stepTwoOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js new file mode 100644 index 0000000000..446fa542ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js @@ -0,0 +1,43 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepThreeOccurs = false; +var stepFiveOccurs = false; + +var obj = {}; + +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + stepThreeOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + } + }; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; + +Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); + +assert(stepThreeOccurs, 'stepThreeOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js new file mode 100644 index 0000000000..27b7d245bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 1 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(undefined, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js new file mode 100644 index 0000000000..c5a9ce14be --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new RangeError(); + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(RangeError, function() { + Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js new file mode 100644 index 0000000000..56bfd0e78b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is boolean +---*/ + +var a = new Array(1, 2, 1); + +assert.sameValue(a.lastIndexOf(2, true), 1, 'true resolves to 1'); +assert.sameValue(a.lastIndexOf(2, false), -1, 'false resolves to 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js new file mode 100644 index 0000000000..4d4f6f0633 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + throw new TypeError(); + } + }; + }, + configurable: true +}); + +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js new file mode 100644 index 0000000000..7c4c6a233a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'fromIndex' is a positive + non-integer, verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js new file mode 100644 index 0000000000..8e1431b6b3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'fromIndex' is a negative + non-integer, verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; + +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js new file mode 100644 index 0000000000..6768c47c48 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - match on the first element, a middle + element and the last element when 'fromIndex' is passed +---*/ + +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 0), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 0)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 2), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 2)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 2), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 2)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 4), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 4)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(4, 4), 4, '[0, 1, 2, 3, 4].lastIndexOf(4, 4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js new file mode 100644 index 0000000000..6ae526981b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is undefined +---*/ + +var a = new Array(1, 2, 1); + +// undefined resolves to 0, no second argument resolves to len +assert.sameValue(a.lastIndexOf(2, undefined), -1, 'a.lastIndexOf(2,undefined)'); +assert.sameValue(a.lastIndexOf(1, undefined), 0, 'a.lastIndexOf(1,undefined)'); +assert.sameValue(a.lastIndexOf(1), 2, 'a.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js new file mode 100644 index 0000000000..1c5773d639 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is null +---*/ + +var a = new Array(1, 2, 1); + +// null resolves to 0 +assert.sameValue(a.lastIndexOf(2, null), -1, 'a.lastIndexOf(2,null)'); +assert.sameValue(a.lastIndexOf(1, null), 0, 'a.lastIndexOf(1,null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js new file mode 100644 index 0000000000..80cc1a0171 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when 'fromIndex' isn't passed +---*/ + +var arr = [0, 1, 2, 3, 4]; +//'fromIndex' will be set as 4 if not passed by default + +assert.sameValue(arr.lastIndexOf(0), arr.lastIndexOf(0, 4), 'arr.lastIndexOf(0)'); +assert.sameValue(arr.lastIndexOf(2), arr.lastIndexOf(2, 4), 'arr.lastIndexOf(2)'); +assert.sameValue(arr.lastIndexOf(4), arr.lastIndexOf(4, 4), 'arr.lastIndexOf(4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js new file mode 100644 index 0000000000..a35ae973b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is 0) +---*/ + +assert.sameValue([0, 100].lastIndexOf(100, 0), -1, 'verify fromIndex is not more than 0'); +assert.sameValue([200, 0].lastIndexOf(200, 0), 0, 'verify fromIndex is not less than 0'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js new file mode 100644 index 0000000000..3197f71bf5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is +0) +---*/ + +assert.sameValue([0, true].lastIndexOf(true, +0), -1, '[0, true].lastIndexOf(true, +0)'); +assert.sameValue([true, 0].lastIndexOf(true, +0), 0, '[true, 0].lastIndexOf(true, +0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js new file mode 100644 index 0000000000..c253f21f73 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is -0) +---*/ + +assert.sameValue([0, true].lastIndexOf(true, -0), -1, '[0, true].lastIndexOf(true, -0)'); +assert.sameValue([true, 0].lastIndexOf(true, -0), 0, '[true, 0].lastIndexOf(true, -0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js new file mode 100644 index 0000000000..955920f7ec --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf when fromIndex greater than + Array.length +---*/ + +var a = new Array(1, 2, 3); + +assert.sameValue(a.lastIndexOf(3, 5.4), 2, 'a.lastIndexOf(3,5.4)'); +assert.sameValue(a.lastIndexOf(3, 3.1), 2, 'a.lastIndexOf(3,3.1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js new file mode 100644 index 0000000000..f0844197a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is length of array - 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 2), 2, '[1, 2, 3].lastIndexOf(3, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js new file mode 100644 index 0000000000..ee9c2981b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when 'fromIndex' is length + of array - 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 1), -1, '[1, 2, 3].lastIndexOf(3, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js new file mode 100644 index 0000000000..8bdf1136b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when 'fromIndex' and + 'length' are both 0 +---*/ + +assert.sameValue([].lastIndexOf(1, 0), -1, '[].lastIndexOf(1, 0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js new file mode 100644 index 0000000000..7446566b69 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf returns -1 when 'fromIndex' is 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 1), -1, '[1, 2, 3].lastIndexOf(3, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js new file mode 100644 index 0000000000..b298623733 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(2, 1), 1, '[1, 2, 3].lastIndexOf(2, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js new file mode 100644 index 0000000000..b80100b7e4 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js @@ -0,0 +1,16 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf with negative fromIndex +---*/ + +var a = new Array(1, 2, 3); + + +assert.sameValue(a.lastIndexOf(2, -2), 1, 'a.lastIndexOf(2,-2)'); +assert.sameValue(a.lastIndexOf(2, -3), -1, 'a.lastIndexOf(2,-3)'); +assert.sameValue(a.lastIndexOf(1, -5.3), -1, 'a.lastIndexOf(1,-5.3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js new file mode 100644 index 0000000000..3cf39efa6b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is -1 +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(4, -1), 3, '[1, 2, 3, 4].lastIndexOf(4, -1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js new file mode 100644 index 0000000000..dfd6dcbf92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when abs('fromIndex') is + length of array - 1 +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(3, -3), -1, '[1, 2, 3, 4].lastIndexOf(3, -3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js new file mode 100644 index 0000000000..460ed58951 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when abs('fromIndex') is + length of array +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(2, -4), -1, '[1, 2, 3, 4].lastIndexOf(2, -4)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js new file mode 100644 index 0000000000..1c260c4cb9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(boolean) +---*/ + +var obj = { + toString: function() { + return true + } +}; +var _false = false; +var a = new Array(false, true, false, obj, _false, true, "true", undefined, 0, null, 1, "str", 0, 1); + +assert.sameValue(a.lastIndexOf(true), 5, 'a[5]=true'); +assert.sameValue(a.lastIndexOf(false), 4, 'a[4] =_false'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js new file mode 100644 index 0000000000..2915a82e7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +info: | + note that prior to the finally ES5 draft SameValue was used for comparisions + and hence NaNs could be found using lastIndexOf * +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index (NaN) +---*/ + +var _NaN = NaN; +var a = new Array("NaN", _NaN, NaN, undefined, 0, false, null, { + toString: function() { + return NaN + } +}, "false"); + +assert.sameValue(a.lastIndexOf(NaN), -1, 'NaN matches nothing, not even itself'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js new file mode 100644 index 0000000000..27fcf1ddfa --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - the length of iteration isn't + changed by adding elements to the array during iteration +---*/ + +var arr = [20]; + +Object.defineProperty(arr, "0", { + get: function() { + arr[1] = 1; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(1), -1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js new file mode 100644 index 0000000000..bd64d700ea --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(Number) +---*/ + +var obj = { + toString: function() { + return 0 + } +}; +var one = 1; +var _float = -(4 / 3); +var a = new Array(+0, true, 0, -0, false, undefined, null, "0", obj, _float, -(4 / 3), -1.3333333333333, "str", one, 1, false); + +assert.sameValue(a.lastIndexOf(-(4 / 3)), 10, 'a[10]=-(4/3)'); +assert.sameValue(a.lastIndexOf(0), 3, 'a[3] = -0, but using === -0 and 0 are equal'); +assert.sameValue(a.lastIndexOf(-0), 3, 'a[3] = -0'); +assert.sameValue(a.lastIndexOf(1), 14, 'a[14] = 1'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js new file mode 100644 index 0000000000..253cc86161 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(string) +---*/ + +var obj = { + toString: function() { + return "false" + } +}; +var szFalse = "false"; +var a = new Array(szFalse, "false", "false1", undefined, 0, false, null, 1, obj, 0); + +assert.sameValue(a.lastIndexOf("false"), 1, 'a.lastIndexOf("false")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js new file mode 100644 index 0000000000..f32dfa8da7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(undefined) +---*/ + +var obj = { + toString: function() { + return undefined; + } +}; +var _undefined1 = undefined; +var _undefined2; +var a = new Array(_undefined1, _undefined2, undefined, true, 0, false, null, 1, "undefined", obj, 1); + +assert.sameValue(a.lastIndexOf(undefined), 2, 'a.lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js new file mode 100644 index 0000000000..70abd20bc2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(Object) +---*/ + +var obj1 = { + toString: function() { + return "false" + } +}; +var obj2 = { + toString: function() { + return "false" + } +}; +var obj3 = obj1; +var a = new Array(obj2, obj1, obj3, false, undefined, 0, false, null, { + toString: function() { + return "false" + } +}, "false"); + +assert.sameValue(a.lastIndexOf(obj3), 2, 'a.lastIndexOf(obj3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js new file mode 100644 index 0000000000..6dcade2541 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(null) +---*/ + +var obj = { + toString: function() { + return null + } +}; +var _null = null; +var a = new Array(true, undefined, 0, false, null, 1, "str", 0, 1, null, true, false, undefined, _null, "null", undefined, "str", obj); + +assert.sameValue(a.lastIndexOf(null), 13, 'a.lastIndexOf(null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js new file mode 100644 index 0000000000..c564170300 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf must return correct index (self + reference) +---*/ + +var a = new Array(0, 1, 2, 3); +a[2] = a; + +assert.sameValue(a.lastIndexOf(a), 2, 'a.lastIndexOf(a)'); +assert.sameValue(a.lastIndexOf(3), 3, 'a.lastIndexOf(3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js new file mode 100644 index 0000000000..d31afa8f21 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index (Array) +---*/ + +var b = new Array("0,1"); +var a = new Array(0, b, "0,1", 3); + +assert.sameValue(a.lastIndexOf(b.toString()), 2, 'a.lastIndexOf(b.toString())'); +assert.sameValue(a.lastIndexOf("0,1"), 2, 'a.lastIndexOf("0,1")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js new file mode 100644 index 0000000000..142287e556 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js @@ -0,0 +1,27 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf must return correct index (Sparse + Array) +---*/ + +var a = new Array(0, 1); +a[4294967294] = 2; // 2^32-2 - is max array element index +a[4294967295] = 3; // 2^32-1 added as non-array element property +a[4294967296] = 4; // 2^32 added as non-array element property +a[4294967297] = 5; // 2^32+1 added as non-array element property +// stop searching near the end in case implementation actually tries to test all missing elements!! +a[4294967200] = 3; +a[4294967201] = 4; +a[4294967202] = 5; + + +assert.sameValue(a.lastIndexOf(2), 4294967294, 'a.lastIndexOf(2)'); +assert.sameValue(a.lastIndexOf(3), 4294967200, 'a.lastIndexOf(3)'); +assert.sameValue(a.lastIndexOf(4), 4294967201, 'a.lastIndexOf(4)'); +assert.sameValue(a.lastIndexOf(5), 4294967202, 'a.lastIndexOf(5)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js new file mode 100644 index 0000000000..842ce1212e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 2 are + visible here +---*/ + +var arr = {}; + +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, "length"), 2, 'Array.prototype.lastIndexOf.call(arr, "length")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js new file mode 100644 index 0000000000..7203adc20b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties can be added to prototype + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(Array.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(6.99), 1, 'arr.lastIndexOf(6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js new file mode 100644 index 0000000000..76ccef72e8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var arr = { + length: 200 +}; + +Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); + +Object.defineProperty(arr, "100", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 6.99), -1, 'Array.prototype.lastIndexOf.call(arr, 6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js new file mode 100644 index 0000000000..2f2acfd10e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property causes index + property not to be visited on an Array +---*/ + +var arr = [1, 2, 3, 4]; + +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); + +Object.defineProperty(arr, "3", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("6.99"), -1, 'arr.lastIndexOf("6.99")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js new file mode 100644 index 0000000000..71733f1f61 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting property of prototype + causes prototype index property not to be visited on an Array-like + Object +---*/ + +var arr = { + 2: 2, + length: 20 +}; + +Object.defineProperty(arr, "3", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 1), -1, 'Array.prototype.lastIndexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js new file mode 100644 index 0000000000..f9a2d957c3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting property of prototype + causes prototype index property not to be visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "20", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.lastIndexOf(1), -1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js new file mode 100644 index 0000000000..c49c77510d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property with + prototype property causes prototype index property to be visited + on an Array-like object +---*/ + +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; + +Object.defineProperty(arr, "6", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Object.prototype[1] = 1; + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 1), 1, 'Array.prototype.lastIndexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js new file mode 100644 index 0000000000..1759de886d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property with + prototype property causes prototype index property to be visited + on an Array +---*/ + +var arr = [0, 111, 2]; + +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); + +Array.prototype[1] = 1; + +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js new file mode 100644 index 0000000000..d31028ca92 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array causes + index property not to be visited +---*/ + +var arr = [0, 1, 2, "last", 4]; + +Object.defineProperty(arr, "4", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("last"), -1, 'arr.lastIndexOf("last")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js new file mode 100644 index 0000000000..8ca10a1747 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var arr = [0, 1, 2, 3, 4]; + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("prototype"), 2, 'arr.lastIndexOf("prototype")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js new file mode 100644 index 0000000000..5c83ccc2eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var arr = [0, 1, 2, 3]; + +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); + +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf("unconfigurable"), 2, 'arr.lastIndexOf("unconfigurable")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js new file mode 100644 index 0000000000..ba60f5372e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 5 are + visible here on an Array-like object +---*/ + +var arr = { + length: 30 +}; +var targetObj = function() {}; + +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 10; + } +}; + + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, targetObj, fromIndex), 4, 'Array.prototype.lastIndexOf.call(arr, targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js new file mode 100644 index 0000000000..c2e793eca2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 5 are + visible here on an Array +---*/ + +var arr = []; +arr.length = 30; +var targetObj = function() {}; + +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 11; + } +}; + +assert.sameValue(arr.lastIndexOf(targetObj, fromIndex), 4, 'arr.lastIndexOf(targetObj, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js new file mode 100644 index 0000000000..c679b73e99 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties in step 2 are + visible here +---*/ + +var arr = { + 2: 6.99 +}; + +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 3; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 6.99), -1, 'Array.prototype.lastIndexOf.call(arr, 6.99)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js new file mode 100644 index 0000000000..e2334b5c8e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties of step 5 are + visible here on an Array-like object +---*/ + +var arr = { + 10: false, + length: 30 +}; + +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 15; + } +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, false, fromIndex), -1, 'Array.prototype.lastIndexOf.call(arr, false, fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js new file mode 100644 index 0000000000..55b9946bcf --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties of step 5 are + visible here on an Array +---*/ + +var arr = []; +arr[10] = "10"; +arr.length = 20; + +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 11; + } +}; + +assert.sameValue(arr.lastIndexOf("10", fromIndex), -1, 'arr.lastIndexOf("10", fromIndex)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js new file mode 100644 index 0000000000..2841b2d2ca --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties added into own object + after current position are visited on an Array-like object +---*/ + +var arr = { + length: 8 +}; + +Object.defineProperty(arr, "4", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, 1), 1, 'Array.prototype.lastIndexOf.call(arr, 1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js new file mode 100644 index 0000000000..4ef6ff9545 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties added into own object + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; + +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js new file mode 100644 index 0000000000..4d49dddf43 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js @@ -0,0 +1,31 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties can be added to + prototype after current position are visited on an Array-like + object +---*/ + +var arr = { + length: 9 +}; + +Object.defineProperty(arr, "4", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return Infinity; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(arr, Infinity), 1, 'Array.prototype.lastIndexOf.call(arr, Infinity)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js new file mode 100644 index 0000000000..0b41785a4c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - undefined property wouldn't be called +---*/ + +assert.sameValue([0, , 2].lastIndexOf(undefined), -1, '[0, , 2].lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js new file mode 100644 index 0000000000..2742fd255f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property on an Array-like object +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 2, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js new file mode 100644 index 0000000000..bc71c16406 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js @@ -0,0 +1,39 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property on an Array-like object +---*/ + +var obj = { + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Object.defineProperty(obj, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 0), 0, 'Array.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 1), 1, 'Array.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, 2), 2, 'Array.prototype.lastIndexOf.call(obj, 2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js new file mode 100644 index 0000000000..3da84aa06f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js @@ -0,0 +1,24 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array +---*/ + +var arr = []; + +Array.prototype[0] = false; +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(true), 0, 'arr.lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js new file mode 100644 index 0000000000..e370128354 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js @@ -0,0 +1,26 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.prototype[0] = false; +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 0, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js new file mode 100644 index 0000000000..48fb0deee0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array +---*/ + +var arr = []; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(true), 0, 'arr.lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js new file mode 100644 index 0000000000..3242cd10a7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js @@ -0,0 +1,32 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 0, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js new file mode 100644 index 0000000000..17af30793e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js @@ -0,0 +1,36 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.defineProperty(Array.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(Array.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); + +assert.sameValue([, , , ].lastIndexOf(10), 0, '[, , , ].lastIndexOf(10)'); +assert.sameValue([, , , ].lastIndexOf(20), 1, '[, , , ].lastIndexOf(20)'); +assert.sameValue([, , , ].lastIndexOf(30), 2, '[, , , ].lastIndexOf(30)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js new file mode 100644 index 0000000000..08f99a3c0d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js @@ -0,0 +1,42 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); + +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(Object.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, 10), 0, 'Array.prototype.lastIndexOf.call({ length: 3 }, 10)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, 20), 1, 'Array.prototype.lastIndexOf.call({ length: 3 }, 20)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, 30), 2, 'Array.prototype.lastIndexOf.call({ length: 3 }, 30)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js new file mode 100644 index 0000000000..b14f5e38ee --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function on an Array +---*/ + +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(undefined), 0, 'arr.lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js new file mode 100644 index 0000000000..4e0b52c9b7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js @@ -0,0 +1,21 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function on an Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), 0, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js new file mode 100644 index 0000000000..c2aa8c19cb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js @@ -0,0 +1,30 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array-like object +---*/ + +var obj = { + length: 1 +}; + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); + +assert(obj.hasOwnProperty(0), 'obj.hasOwnProperty(0) !== true'); +assert.sameValue(Array.prototype.lastIndexOf.call(obj, undefined), 0, 'Array.prototype.lastIndexOf.call(obj, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js new file mode 100644 index 0000000000..0d6bcdbe1b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property on an Array +---*/ + +assert.sameValue([true, true, true].lastIndexOf(true), 2, '[true, true, true].lastIndexOf(true)'); +assert.sameValue([true, true, false].lastIndexOf(true), 1, '[true, true, false].lastIndexOf(true)'); +assert.sameValue([true, false, false].lastIndexOf(true), 0, '[true, false, false].lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js new file mode 100644 index 0000000000..9cda64323e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is an own + accessor property without a get function that overrides an + inherited accessor property on an Array +---*/ + +var arr = [, 1]; + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 100; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); + +assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true'); +assert.sameValue(arr.lastIndexOf(undefined), 0, 'arr.lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js new file mode 100644 index 0000000000..35f9c4af84 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js @@ -0,0 +1,18 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue([, ].lastIndexOf(undefined), 0, '[, ].lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js new file mode 100644 index 0000000000..b870f4e856 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + set: function() {}, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 1 +}, undefined), 0, 'Array.prototype.lastIndexOf.call({ length: 1 }, undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js new file mode 100644 index 0000000000..38363b773b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var func = function(a, b) { + return 0 === Array.prototype.lastIndexOf.call(arguments, arguments[0]) && + -1 === Array.prototype.lastIndexOf.call(arguments, arguments[1]); +}; + +assert(func(true), 'func(true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js new file mode 100644 index 0000000000..f3e209120c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments equals + to number of parameters) +---*/ + +var func = function(a, b) { + return 0 === Array.prototype.lastIndexOf.call(arguments, arguments[0]) && + 1 === Array.prototype.lastIndexOf.call(arguments, arguments[1]) && + -1 === Array.prototype.lastIndexOf.call(arguments, arguments[2]); +}; + +assert(func(0, true), 'func(0, true) !== true'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js new file mode 100644 index 0000000000..9e8618f62c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var func = function(a, b) { + assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[0]), 2); + assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[3]), 3); + assert.sameValue(Array.prototype.lastIndexOf.call(arguments, arguments[4]), -1); +}; + +(function() { + func(0, arguments, 0, Object.prototype); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js new file mode 100644 index 0000000000..6002512ccc --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side-effects are visible in + subsequent iterations on an Array +---*/ + +var preIterVisible = false; +var arr = []; + +Object.defineProperty(arr, "2", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(true), 1, 'arr.lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js new file mode 100644 index 0000000000..8add4d3af8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side-effects are visible in + subsequent iterations on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 3 +}; + +Object.defineProperty(obj, "2", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call(obj, true), 1, 'Array.prototype.lastIndexOf.call(obj, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js new file mode 100644 index 0000000000..9df7282978 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js @@ -0,0 +1,15 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +Array.prototype[0] = Object; + +assert.sameValue([Object.prototype].lastIndexOf(Object.prototype), 0, '[Object.prototype].lastIndexOf(Object.prototype)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js new file mode 100644 index 0000000000..15798087fd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js @@ -0,0 +1,33 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf terminates iteration on unhandled + exception on an Array +---*/ + +var accessed = false; +var arr = []; + +Object.defineProperty(arr, "2", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + arr.lastIndexOf(true); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js new file mode 100644 index 0000000000..638b3f2537 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf terminates iteration on unhandled + exception on an Array-like object +---*/ + +var accessed = false; +var obj = { + length: 3 +}; + +Object.defineProperty(obj, "2", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); + +Object.defineProperty(obj, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + Array.prototype.lastIndexOf.call(obj, true); +}); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js new file mode 100644 index 0000000000..9183e4d886 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +Object.prototype[0] = false; + +assert.sameValue(Array.prototype.lastIndexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'Array.prototype.lastIndexOf.call({ 0: true, 1: 1, length: 2 }, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js new file mode 100644 index 0000000000..bfabd45dfd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +Object.defineProperty(Array.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +assert.sameValue([Number].lastIndexOf(Number), 0, '[Number].lastIndexOf(Number)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js new file mode 100644 index 0000000000..fb30292d7d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); + +assert.sameValue(Array.prototype.lastIndexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'Array.prototype.lastIndexOf.call({ 0: true, 1: 1, length: 2 }, true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js new file mode 100644 index 0000000000..1b4eb1f2f0 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js @@ -0,0 +1,19 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + data property on an Array +---*/ + +Array.prototype[0] = true; +Array.prototype[1] = false; +Array.prototype[2] = "true"; + +assert.sameValue([, , , ].lastIndexOf(true), 0, '[, , , ].lastIndexOf(true)'); +assert.sameValue([, , , ].lastIndexOf(false), 1, '[, , , ].lastIndexOf(false)'); +assert.sameValue([, , , ].lastIndexOf("true"), 2, '[, , , ].lastIndexOf("true")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js new file mode 100644 index 0000000000..5e055929b9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js @@ -0,0 +1,25 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + data property on an Array-like object +---*/ + +Object.prototype[0] = true; +Object.prototype[1] = false; +Object.prototype[2] = "true"; + +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, true), 0, 'Array.prototype.lastIndexOf.call({ length: 3 }, true)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, false), 1, 'Array.prototype.lastIndexOf.call({ length: 3 }, false)'); +assert.sameValue(Array.prototype.lastIndexOf.call({ + length: 3 +}, "true"), 2, 'Array.prototype.lastIndexOf.call({ length: 3 }, "true")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js new file mode 100644 index 0000000000..89a0753d96 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js @@ -0,0 +1,37 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property on an Array +---*/ + +var arr = [, , , ]; +Object.defineProperty(arr, "0", { + get: function() { + return 0; + }, + configurable: true +}); + +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); + +Object.defineProperty(arr, "2", { + get: function() { + return 2; + }, + configurable: true +}); + +assert.sameValue(arr.lastIndexOf(0), 0, 'arr.lastIndexOf(0)'); +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); +assert.sameValue(arr.lastIndexOf(2), 2, 'arr.lastIndexOf(2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js new file mode 100644 index 0000000000..ab569337cd --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js @@ -0,0 +1,20 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - type of array element is different + from type of search element +---*/ + +assert.sameValue(["true"].lastIndexOf(true), -1, '["true"].lastIndexOf(true)'); +assert.sameValue(["0"].lastIndexOf(0), -1, '["0"].lastIndexOf(0)'); +assert.sameValue([false].lastIndexOf(0), -1, '[false].lastIndexOf(0)'); +assert.sameValue([undefined].lastIndexOf(0), -1, '[undefined].lastIndexOf(0)'); +assert.sameValue([null].lastIndexOf(0), -1, '[null].lastIndexOf(0)'); +assert.sameValue([ + [] +].lastIndexOf(0), -1, '[[]].lastIndexOf(0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js new file mode 100644 index 0000000000..5fb4e0ab8d --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are booleans, and they have same value +---*/ + +assert.sameValue([false, true].lastIndexOf(true), 1, '[false, true].lastIndexOf(true)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js new file mode 100644 index 0000000000..15d142a080 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js @@ -0,0 +1,17 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are Objects, and they refer to the same object +---*/ + +var obj1 = {}; +var obj2 = {}; +var obj3 = obj2; + +assert.sameValue([obj2, obj1].lastIndexOf(obj3), 0, '[obj2, obj1].lastIndexOf(obj3)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js new file mode 100644 index 0000000000..3c752a3b0c --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both type of array element and type + of search element are Undefined +---*/ + +assert.sameValue([undefined].lastIndexOf(), 0, '[undefined].lastIndexOf()'); +assert.sameValue([undefined].lastIndexOf(undefined), 0, '[undefined].lastIndexOf(undefined)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js new file mode 100644 index 0000000000..8def039e6f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both type of array element and type + of search element are Null +---*/ + +assert.sameValue([null].lastIndexOf(null), 0, '[null].lastIndexOf(null)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js new file mode 100644 index 0000000000..5d001f88a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - search element is NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].lastIndexOf(NaN), -1, '[+NaN, NaN, -NaN].lastIndexOf(NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js new file mode 100644 index 0000000000..5d8ced85f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js @@ -0,0 +1,11 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - search element is -NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].lastIndexOf(-NaN), -1, '[+NaN, NaN, -NaN].lastIndexOf(-NaN)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js new file mode 100644 index 0000000000..c6c71dd524 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - array element is +0 and search + element is -0 +---*/ + +assert.sameValue([+0].lastIndexOf(-0), 0, '[+0].lastIndexOf(-0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js new file mode 100644 index 0000000000..a52c350499 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - array element is -0 and search + element is +0 +---*/ + +assert.sameValue([-0].lastIndexOf(+0), 0, '[-0].lastIndexOf(+0)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js new file mode 100644 index 0000000000..5a990835d5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are numbers, and they have same value +---*/ + +assert.sameValue([-1, 0, 1].lastIndexOf(-1), 0, '[-1, 0, 1].lastIndexOf(-1)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js new file mode 100644 index 0000000000..8a175e49bb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js @@ -0,0 +1,14 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are strings, and they have exactly the same sequence of + characters +---*/ + +assert.sameValue(["abc", "ab", "bca", ""].lastIndexOf("abc"), 0, '["abc", "ab", "bca", ""].lastIndexOf("abc")'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js new file mode 100644 index 0000000000..66ca31475f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns index of last one when more + than two elements in array are eligible +---*/ + +assert.sameValue([2, 1, 2, 2, 1].lastIndexOf(2), 3, '[2, 1, 2, 2, 1].lastIndexOf(2)'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js new file mode 100644 index 0000000000..c84939a8b8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js @@ -0,0 +1,35 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns without visiting subsequent + element once search value is found +---*/ + +var arr = [2, 1, , 1, 2]; +var elementFirstAccessed = false; +var elementThirdAccessed = false; + +Object.defineProperty(arr, "2", { + get: function() { + elementThirdAccessed = true; + return 2; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + elementFirstAccessed = true; + return 2; + }, + configurable: true +}); + +arr.lastIndexOf(2); + +assert.sameValue(elementThirdAccessed, false, 'elementThirdAccessed'); +assert.sameValue(elementFirstAccessed, false, 'elementFirstAccessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js new file mode 100644 index 0000000000..eaa3df340e --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js @@ -0,0 +1,29 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf returns -1 for elements not present +---*/ + +var a = new Array(); +a[100] = 1; +a[99999] = ""; +a[10] = new Object(); +a[5555] = 5.5; +a[123456] = "str"; +a[5] = 1E+309; + +assert.sameValue(a.lastIndexOf(1), 100, 'a.lastIndexOf(1)'); +assert.sameValue(a.lastIndexOf(""), 99999, 'a.lastIndexOf("")'); +assert.sameValue(a.lastIndexOf("str"), 123456, 'a.lastIndexOf("str")'); +assert.sameValue(a.lastIndexOf(5.5), 5555, 'a.lastIndexOf(5.5)'); +assert.sameValue(a.lastIndexOf(1E+309), 5, 'a.lastIndexOf(1E+309)'); + +assert.sameValue(a.lastIndexOf(true), -1, 'a.lastIndexOf(true)'); +assert.sameValue(a.lastIndexOf(5), -1, 'a.lastIndexOf(5)'); +assert.sameValue(a.lastIndexOf("str1"), -1, 'a.lastIndexOf("str1")'); +assert.sameValue(a.lastIndexOf(null), -1, 'a.lastIndexOf(null)'); +assert.sameValue(a.lastIndexOf(new Object()), -1, 'a.lastIndexOf(new Object())'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js new file mode 100644 index 0000000000..1ad6837c0f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js @@ -0,0 +1,28 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 and does + not access any other properties +---*/ + +var accessed = false; +var f = { + length: 0 +}; +Object.defineProperty(f, "0", { + get: function() { + accessed = true; + return 1; + } +}); + +var i = Array.prototype.lastIndexOf.call(f, 1); + + +assert.sameValue(i, -1, 'i'); +assert.sameValue(accessed, false, 'accessed'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/browser.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/browser.js diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/call-with-boolean.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/call-with-boolean.js new file mode 100644 index 0000000000..22c6b91a3f --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/call-with-boolean.js @@ -0,0 +1,16 @@ +// Copyright (c) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastIndexOf +description: Array.prototype.lastIndexOf applied to boolean primitive +---*/ + +assert.sameValue(Array.prototype.lastIndexOf.call(true), -1, 'Array.prototype.lastIndexOf.call(true) must return -1'); +assert.sameValue( + Array.prototype.lastIndexOf.call(false), + -1, + 'Array.prototype.lastIndexOf.call(false) must return -1' +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js new file mode 100644 index 0000000000..67a77465f5 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -0,0 +1,45 @@ +// Copyright (C) 2018 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Calls [[HasProperty]] on the prototype to check for existing elements. +info: | + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. If fromIndex is present, let n be ? ToInteger(fromIndex); else let n be len-1. + ... + 7. Repeat, while k ≥ 0 + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ... +includes: [proxyTrapsHelper.js] +features: [Proxy] +---*/ + +var array = [5, undefined, 7]; + +Object.setPrototypeOf(array, new Proxy(Array.prototype, allowProxyTraps({ + has: function(t, pk) { + return pk in t; + } +}))); + +var fromIndex = { + valueOf: function() { + // Zero the array's length. The loop in step 8 iterates over the original + // length value of 100, but the only prototype MOP method which should be + // called is [[HasProperty]]. + array.length = 0; + return 2; + } +}; + +Array.prototype.lastIndexOf.call(array, 100, fromIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js new file mode 100644 index 0000000000..6ee21c9d7a --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js @@ -0,0 +1,18 @@ +// Copyright 2016 The V8 project authors. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.prototype.lastindexof +description: > + Return +0 when fromIndex is -0 and return index refers to the first position +info: | + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + ... +---*/ + +assert.sameValue(1 / [true].lastIndexOf(true, -0), +Infinity); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-near-integer-limit.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-near-integer-limit.js new file mode 100644 index 0000000000..a10493c771 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-near-integer-limit.js @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Elements are found in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + [...] + 7. Repeat, while k ≥ 0 + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison searchElement === elementK. + iii. If same is true, return k. + [...] +---*/ + +var el = {}; +var elIndex = Number.MAX_SAFE_INTEGER - 3; +var fromIndex = Number.MAX_SAFE_INTEGER - 1; +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; + +arrayLike[elIndex] = el; + +var res = Array.prototype.lastIndexOf.call(arrayLike, el, fromIndex); + +assert.sameValue(res, elIndex); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js new file mode 100644 index 0000000000..1ffa00c9a3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.lastindexof +description: > + Returns -1 if length is 0. +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + 3. If len is 0, return -1. +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error("Length should be checked before ToInteger(fromIndex)."); + }, +}; + +assert.sameValue([].lastIndexOf(1), -1); +assert.sameValue([].lastIndexOf(2, fromIndex), -1); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js new file mode 100644 index 0000000000..56b0fd7f8b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + The "length" property of Array.prototype.lastIndexOf +info: | + 17 ECMAScript Standard Built-in Objects + + Every built-in function object, including constructors, has a length property + whose value is an integer. Unless otherwise specified, this value is equal to + the largest number of named arguments shown in the subclause headings for the + function description. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are shown using the form «...name») are not + included in the default argument count. + + Unless otherwise specified, the length property of a built-in function object + has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Array.prototype.lastIndexOf.length, 1); + +verifyNotEnumerable(Array.prototype.lastIndexOf, 'length'); +verifyNotWritable(Array.prototype.lastIndexOf, 'length'); +verifyConfigurable(Array.prototype.lastIndexOf, 'length'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/name.js new file mode 100644 index 0000000000..1ab52079e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf.name is "lastIndexOf". +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 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(Array.prototype.lastIndexOf.name, "lastIndexOf"); + +verifyNotEnumerable(Array.prototype.lastIndexOf, "name"); +verifyNotWritable(Array.prototype.lastIndexOf, "name"); +verifyConfigurable(Array.prototype.lastIndexOf, "name"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/not-a-constructor.js new file mode 100644 index 0000000000..e3d126b8f9 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/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: > + Array.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(Array.prototype.lastIndexOf), + false, + 'isConstructor(Array.prototype.lastIndexOf) must return false' +); + +assert.throws(TypeError, () => { + new Array.prototype.lastIndexOf(); +}, '`new Array.prototype.lastIndexOf()` throws TypeError'); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/prop-desc.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/prop-desc.js new file mode 100644 index 0000000000..8b70501c5b --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.lastindexof +description: > + "lastIndexOf" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex B.2 + has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Array.prototype.lastIndexOf, 'function', 'typeof'); + +verifyNotEnumerable(Array.prototype, "lastIndexOf"); +verifyWritable(Array.prototype, "lastIndexOf"); +verifyConfigurable(Array.prototype, "lastIndexOf"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/shell.js b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/shell.js new file mode 100644 index 0000000000..bc72493f03 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/shell.js @@ -0,0 +1,33 @@ +// GENERATED, DO NOT EDIT +// file: proxyTrapsHelper.js +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} |