Eliminate false positives: Array.prototype.flat, Array.prototype.flatMap

This commit is contained in:
Rick Waldron 2018-11-28 14:29:05 -05:00
parent d52f621aba
commit 2e18327af2
7 changed files with 15 additions and 1 deletions

View File

@ -8,6 +8,8 @@ description: >
features: [Array.prototype.flat] features: [Array.prototype.flat]
---*/ ---*/
assert.sameValue(typeof Array.prototype.flat, 'function');
var a = []; var a = [];
a.constructor = null; a.constructor = null;
assert.throws(TypeError, function() { assert.throws(TypeError, function() {

View File

@ -7,6 +7,8 @@ description: >
features: [Array.prototype.flat] features: [Array.prototype.flat]
---*/ ---*/
assert.sameValue(typeof Array.prototype.flat, 'function');
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
[].flat.call(null); [].flat.call(null);
}, 'null value'); }, 'null value');

View File

@ -7,6 +7,8 @@ description: >
features: [Array.prototype.flat] features: [Array.prototype.flat]
---*/ ---*/
assert.sameValue(typeof Array.prototype.flat, 'function');
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
[].flat(Symbol()); [].flat(Symbol());
}, 'symbol value'); }, 'symbol value');

View File

@ -7,6 +7,8 @@ description: >
features: [Array.prototype.flatMap] features: [Array.prototype.flatMap]
---*/ ---*/
assert(Array.prototype.flatMap);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
[].flatMap({}); [].flatMap({});
}, 'non callable argument'); }, 'non callable argument');

View File

@ -8,6 +8,8 @@ description: >
features: [Array.prototype.flatMap] features: [Array.prototype.flatMap]
---*/ ---*/
assert.sameValue(typeof Array.prototype.flatMap, 'function');
var a = []; var a = [];
a.constructor = null; a.constructor = null;
assert.throws(TypeError, function() { assert.throws(TypeError, function() {

View File

@ -7,6 +7,8 @@ description: >
features: [Array.prototype.flatMap] features: [Array.prototype.flatMap]
---*/ ---*/
assert.sameValue(typeof Array.prototype.flatMap, 'function');
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
[].flatMap.call(null); [].flatMap.call(null);
}, 'null value'); }, 'null value');

View File

@ -17,10 +17,12 @@ info: |
b. Let exists be ? HasProperty(source, P). b. Let exists be ? HasProperty(source, P).
c. If exists is true, then c. If exists is true, then
i. Let element be ? Get(source, P). i. Let element be ? Get(source, P).
features: [Array.prototype.flat] features: [Array.prototype.flatMap]
includes: [compareArray.js] includes: [compareArray.js]
---*/ ---*/
assert.sameValue(typeof Array.prototype.flatMap, 'function');
const getCalls = [], hasCalls = []; const getCalls = [], hasCalls = [];
const handler = { const handler = {
get : function (t, p, r) { getCalls.push(p); return Reflect.get(t, p, r); }, get : function (t, p, r) { getCalls.push(p); return Reflect.get(t, p, r); },