Coverage: calling array methods with boolean as thisValue. Fixes gh-2803

This commit is contained in:
Rick Waldron 2020-09-22 11:32:16 -04:00
parent 4bcc582183
commit 07cc3c8bb1
26 changed files with 402 additions and 0 deletions

View File

@ -0,0 +1,18 @@
// 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.concat
description: Array.prototype.concat applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.concat.call(true)[0] instanceof Boolean,
true,
'The result of `(Array.prototype.concat.call(true)[0] instanceof Boolean)` is true'
);
assert.sameValue(
Array.prototype.concat.call(false)[0] instanceof Boolean,
true,
'The result of `(Array.prototype.concat.call(false)[0] instanceof Boolean)` is true'
);

View File

@ -0,0 +1,18 @@
// 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.copyWithin
description: Array.prototype.copyWithin applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.copyWithin.call(true) instanceof Boolean,
true,
'The result of `(Array.prototype.copyWithin.call(true) instanceof Boolean)` is true'
);
assert.sameValue(
Array.prototype.copyWithin.call(false) instanceof Boolean,
true,
'The result of `(Array.prototype.copyWithin.call(false) instanceof Boolean)` is true'
);

View File

@ -0,0 +1,18 @@
// 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.every
description: Array.prototype.every applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.every.call(true, () => {}),
true,
'Array.prototype.every.call(true, () => {}) must return true'
);
assert.sameValue(
Array.prototype.every.call(false, () => {}),
true,
'Array.prototype.every.call(false, () => {}) must return true'
);

View File

@ -0,0 +1,18 @@
// 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.fill
description: Array.prototype.fill applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.fill.call(true) instanceof Boolean,
true,
'The result of `(Array.prototype.fill.call(true) instanceof Boolean)` is true'
);
assert.sameValue(
Array.prototype.fill.call(false) instanceof Boolean,
true,
'The result of `(Array.prototype.fill.call(false) instanceof Boolean)` is true'
);

View File

@ -0,0 +1,19 @@
// 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.filter
description: Array.prototype.filter applied to boolean primitive
includes: [compareArray.js]
---*/
assert.compareArray(
Array.prototype.filter.call(true, () => {}),
[],
'Array.prototype.filter.call(true, () => {}) must return []'
);
assert.compareArray(
Array.prototype.filter.call(false, () => {}),
[],
'Array.prototype.filter.call(false, () => {}) must return []'
);

View File

@ -0,0 +1,18 @@
// 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.find
description: Array.prototype.find applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.find.call(true, () => {}),
undefined,
'Array.prototype.find.call(true, () => {}) must return undefined'
);
assert.sameValue(
Array.prototype.find.call(false, () => {}),
undefined,
'Array.prototype.find.call(false, () => {}) must return undefined'
);

View File

@ -0,0 +1,18 @@
// 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.findIndex
description: Array.prototype.findIndex applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.findIndex.call(true, () => {}),
-1,
'Array.prototype.findIndex.call(true, () => {}) must return -1'
);
assert.sameValue(
Array.prototype.findIndex.call(false, () => {}),
-1,
'Array.prototype.findIndex.call(false, () => {}) must return -1'
);

View File

@ -0,0 +1,11 @@
// 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.flat
description: Array.prototype.flat applied to boolean primitive
includes: [compareArray.js]
---*/
assert.compareArray(Array.prototype.flat.call(true), [], 'Array.prototype.flat.call(true) must return []');
assert.compareArray(Array.prototype.flat.call(false), [], 'Array.prototype.flat.call(false) must return []');

View File

@ -0,0 +1,19 @@
// 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.flatMap
description: Array.prototype.flatMap applied to boolean primitive
includes: [compareArray.js]
---*/
assert.compareArray(
Array.prototype.flatMap.call(true, () => {}),
[],
'Array.prototype.flatMap.call(true, () => {}) must return []'
);
assert.compareArray(
Array.prototype.flatMap.call(false, () => {}),
[],
'Array.prototype.flatMap.call(false, () => {}) must return []'
);

View File

@ -0,0 +1,18 @@
// 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.forEach
description: Array.prototype.forEach applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.forEach.call(true, () => {}),
undefined,
'Array.prototype.forEach.call(true, () => {}) must return undefined'
);
assert.sameValue(
Array.prototype.forEach.call(false, () => {}),
undefined,
'Array.prototype.forEach.call(false, () => {}) must return undefined'
);

View File

@ -0,0 +1,14 @@
// 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.includes
description: Array.prototype.includes applied to boolean primitive
---*/
assert.sameValue(Array.prototype.includes.call(true), false, 'Array.prototype.includes.call(true) must return false');
assert.sameValue(
Array.prototype.includes.call(false),
false,
'Array.prototype.includes.call(false) must return false'
);

View File

@ -0,0 +1,10 @@
// 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.indexOf
description: Array.prototype.indexOf applied to boolean primitive
---*/
assert.sameValue(Array.prototype.indexOf.call(true), -1, 'Array.prototype.indexOf.call(true) must return -1');
assert.sameValue(Array.prototype.indexOf.call(false), -1, 'Array.prototype.indexOf.call(false) must return -1');

View File

@ -0,0 +1,10 @@
// 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.join
description: Array.prototype.join applied to boolean primitive
---*/
assert.sameValue(Array.prototype.join.call(true), "", 'Array.prototype.join.call(true) must return ""');
assert.sameValue(Array.prototype.join.call(false), "", 'Array.prototype.join.call(false) must return ""');

View File

@ -0,0 +1,14 @@
// 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'
);

View File

@ -0,0 +1,19 @@
// 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.map
description: Array.prototype.map applied to boolean primitive
includes: [compareArray.js]
---*/
assert.compareArray(
Array.prototype.map.call(true, () => {}),
[],
'Array.prototype.map.call(true, () => {}) must return []'
);
assert.compareArray(
Array.prototype.map.call(false, () => {}),
[],
'Array.prototype.map.call(false, () => {}) must return []'
);

View File

@ -0,0 +1,10 @@
// 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.pop
description: Array.prototype.pop applied to boolean primitive
---*/
assert.sameValue(Array.prototype.pop.call(true), undefined, 'Array.prototype.pop.call(true) must return undefined');
assert.sameValue(Array.prototype.pop.call(false), undefined, 'Array.prototype.pop.call(false) must return undefined');

View File

@ -0,0 +1,10 @@
// 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.push
description: Array.prototype.push applied to boolean primitive
---*/
assert.sameValue(Array.prototype.push.call(true), 0, 'Array.prototype.push.call(true) must return 0');
assert.sameValue(Array.prototype.push.call(false), 0, 'Array.prototype.push.call(false) must return 0');

View File

@ -0,0 +1,18 @@
// 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.reduce
description: Array.prototype.reduce applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.reduce.call(true, () => {}, -1),
-1,
'Array.prototype.reduce.call(true, () => {}, -1) must return -1'
);
assert.sameValue(
Array.prototype.reduce.call(false, () => {}, -1),
-1,
'Array.prototype.reduce.call(false, () => {}, -1) must return -1'
);

View File

@ -0,0 +1,18 @@
// 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.reduceRight
description: Array.prototype.reduceRight applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.reduceRight.call(true, () => {}, -1),
-1,
'Array.prototype.reduceRight.call(true, () => {}, -1) must return -1'
);
assert.sameValue(
Array.prototype.reduceRight.call(false, () => {}, -1),
-1,
'Array.prototype.reduceRight.call(false, () => {}, -1) must return -1'
);

View File

@ -0,0 +1,18 @@
// 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.reverse
description: Array.prototype.reverse applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.reverse.call(true) instanceof Boolean,
true,
'The result of `(Array.prototype.reverse.call(true) instanceof Boolean)` is true'
);
assert.sameValue(
Array.prototype.reverse.call(false) instanceof Boolean,
true,
'The result of `(Array.prototype.reverse.call(false) instanceof Boolean)` is true'
);

View File

@ -0,0 +1,18 @@
// 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.shift
description: Array.prototype.shift applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.shift.call(true),
undefined,
'Array.prototype.shift.call(true) must return undefined'
);
assert.sameValue(
Array.prototype.shift.call(false),
undefined,
'Array.prototype.shift.call(false) must return undefined'
);

View File

@ -0,0 +1,11 @@
// 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.slice
description: Array.prototype.slice applied to boolean primitive
includes: [compareArray.js]
---*/
assert.compareArray(Array.prototype.slice.call(true), [], 'Array.prototype.slice.call(true) must return []');
assert.compareArray(Array.prototype.slice.call(false), [], 'Array.prototype.slice.call(false) must return []');

View File

@ -0,0 +1,18 @@
// 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.some
description: Array.prototype.some applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.some.call(true, () => {}),
false,
'Array.prototype.some.call(true, () => {}) must return false'
);
assert.sameValue(
Array.prototype.some.call(false, () => {}),
false,
'Array.prototype.some.call(false, () => {}) must return false'
);

View File

@ -0,0 +1,11 @@
// 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.splice
description: Array.prototype.splice applied to boolean primitive
includes: [compareArray.js]
---*/
assert.compareArray(Array.prototype.splice.call(true), [], 'Array.prototype.splice.call(true) must return []');
assert.compareArray(Array.prototype.splice.call(false), [], 'Array.prototype.splice.call(false) must return []');

View File

@ -0,0 +1,18 @@
// 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.toString
description: Array.prototype.toString applied to boolean primitive
---*/
assert.sameValue(
Array.prototype.toString.call(true),
"[object Boolean]",
'Array.prototype.toString.call(true) must return "[object Boolean]"'
);
assert.sameValue(
Array.prototype.toString.call(false),
"[object Boolean]",
'Array.prototype.toString.call(false) must return "[object Boolean]"'
);

View File

@ -0,0 +1,10 @@
// 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.unshift
description: Array.prototype.unshift applied to boolean primitive
---*/
assert.sameValue(Array.prototype.unshift.call(true), 0, 'Array.prototype.unshift.call(true) must return 0');
assert.sameValue(Array.prototype.unshift.call(false), 0, 'Array.prototype.unshift.call(false) must return 0');