summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js')
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js b/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js
new file mode 100644
index 0000000000..572f4afe54
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/includes/get-prop.js
@@ -0,0 +1,48 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.includes
+description: get array-like indexed properties
+info: |
+ 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] )
+
+ ...
+ 7. Repeat, while k < len
+ a. Let elementK be the result of ? Get(O, ! ToString(k)).
+ ...
+includes: [compareArray.js]
+features: [Proxy, Array.prototype.includes]
+---*/
+
+var calls;
+
+var obj = {};
+
+var p = new Proxy(obj, {
+ get: function(_, key) {
+ calls.push(key);
+
+ if (key === "length") {
+ return 4;
+ }
+
+ return key * 10;
+ }
+});
+
+calls = [];
+assert.sameValue(
+ [].includes.call(p, 42),
+ false,
+ '[].includes.call("new Proxy(obj, {get: function(_, key) {calls.push(key); if (key === "length") {return 4;} return key * 10;}})", 42) must return false'
+);
+assert.compareArray(calls, ["length", "0", "1", "2", "3"],
+ 'The value of calls is expected to be ["length", "0", "1", "2", "3"]'
+);
+
+calls = [];
+assert.sameValue([].includes.call(p, 10), true, '[].includes.call("new Proxy(obj, {get: function(_, key) {calls.push(key); if (key === "length") {return 4;} return key * 10;}})", 10) must return true');
+assert.compareArray(calls, ["length", "0", "1"], 'The value of calls is expected to be ["length", "0", "1"]');
+
+reportCompare(0, 0);