From 1547e49c9510e06d361cbb94d6df73063d7e124f Mon Sep 17 00:00:00 2001 From: shilpi Date: Thu, 4 Jan 2018 14:16:37 -0800 Subject: [PATCH] flatten and flatMap tests --- .../prototype/flatMap/array-like-objects.js | 33 +++++++++++++++ .../flatMap/bound-function-argument.js | 13 ++++++ .../prototype/flatMap/depth-always-one.js | 24 +++++++++++ .../Array/prototype/flatMap/length.js | 18 ++++++++ .../built-ins/Array/prototype/flatMap/name.js | 18 ++++++++ .../flatMap/non-callable-argument-throws.js | 11 +++++ .../flatMap/non-object-ctor-throws.js | 34 +++++++++++++++ .../flatMap/null-undefined-input-throws.js | 20 +++++++++ .../prototype/flatMap/thisArg-argument.js | 20 +++++++++ .../prototype/flatten/array-like-objects.js | 31 ++++++++++++++ .../prototype/flatten/bound-function-call.js | 13 ++++++ .../prototype/flatten/empty-array-elements.js | 15 +++++++ .../flatten/empty-object-elements.js | 12 ++++++ .../Array/prototype/flatten/length.js | 18 ++++++++ .../built-ins/Array/prototype/flatten/name.js | 20 +++++++++ .../non-numeric-depth-should-not-throw.js | 42 +++++++++++++++++++ .../flatten/non-object-ctor-throws.js | 33 +++++++++++++++ .../flatten/null-undefined-elements.js | 15 +++++++ .../flatten/null-undefined-input-throws.js | 20 +++++++++ .../prototype/flatten/positive-infinity.js | 11 +++++ .../Array/prototype/flatten/prop-desc.js | 20 +++++++++ .../symbol-object-create-null-depth-throws.js | 21 ++++++++++ 22 files changed, 462 insertions(+) create mode 100644 test/built-ins/Array/prototype/flatMap/array-like-objects.js create mode 100644 test/built-ins/Array/prototype/flatMap/bound-function-argument.js create mode 100644 test/built-ins/Array/prototype/flatMap/depth-always-one.js create mode 100644 test/built-ins/Array/prototype/flatMap/length.js create mode 100644 test/built-ins/Array/prototype/flatMap/name.js create mode 100644 test/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js create mode 100644 test/built-ins/Array/prototype/flatMap/non-object-ctor-throws.js create mode 100644 test/built-ins/Array/prototype/flatMap/null-undefined-input-throws.js create mode 100644 test/built-ins/Array/prototype/flatMap/thisArg-argument.js create mode 100644 test/built-ins/Array/prototype/flatten/array-like-objects.js create mode 100644 test/built-ins/Array/prototype/flatten/bound-function-call.js create mode 100644 test/built-ins/Array/prototype/flatten/empty-array-elements.js create mode 100644 test/built-ins/Array/prototype/flatten/empty-object-elements.js create mode 100644 test/built-ins/Array/prototype/flatten/length.js create mode 100644 test/built-ins/Array/prototype/flatten/name.js create mode 100644 test/built-ins/Array/prototype/flatten/non-numeric-depth-should-not-throw.js create mode 100644 test/built-ins/Array/prototype/flatten/non-object-ctor-throws.js create mode 100644 test/built-ins/Array/prototype/flatten/null-undefined-elements.js create mode 100644 test/built-ins/Array/prototype/flatten/null-undefined-input-throws.js create mode 100644 test/built-ins/Array/prototype/flatten/positive-infinity.js create mode 100644 test/built-ins/Array/prototype/flatten/prop-desc.js create mode 100644 test/built-ins/Array/prototype/flatten/symbol-object-create-null-depth-throws.js diff --git a/test/built-ins/Array/prototype/flatMap/array-like-objects.js b/test/built-ins/Array/prototype/flatMap/array-like-objects.js new file mode 100644 index 0000000000..dcb9f5c9ca --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/array-like-objects.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + array-like objects can be flattened +includes: [compareArray.js] +---*/ + +function takesTwoParams(a, b) { + return Array.prototype.flatMap.call(arguments, function(ele) { return ele * 2}); +} + +var actual = takesTwoParams(1,[2]); +var expected = [2, 4]; + +assert(compareArray(actual, expected), 'arguments array like object'); + +var a = { + "length": 1, + "0": 1 +}; + +actual = Array.prototype.flatMap.call(a, function(ele) { return ele * 2}); +assert.sameValue(JSON.stringify(actual), JSON.stringify(['2']), 'array like objects'); + +var a = { + "length": undefined, + "0": 1 +}; + +actual = Array.prototype.flatMap.call(a, function(ele) { return ele * 2}); +assert.sameValue(JSON.stringify(actual), JSON.stringify([]), 'array like objects'); diff --git a/test/built-ins/Array/prototype/flatMap/bound-function-argument.js b/test/built-ins/Array/prototype/flatMap/bound-function-argument.js new file mode 100644 index 0000000000..b85b9aaa3d --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/bound-function-argument.js @@ -0,0 +1,13 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when array is depth more than 1 +includes: [compareArray.js] +---*/ + +var a = [void 0,[void 0]]; +var flattenMap = [].flatMap.bind(a, function() {}); + +assert.compareArray(a.flatMap(flattenMap), [undefined, undefined, undefined, undefined]); diff --git a/test/built-ins/Array/prototype/flatMap/depth-always-one.js b/test/built-ins/Array/prototype/flatMap/depth-always-one.js new file mode 100644 index 0000000000..624392c2dc --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/depth-always-one.js @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when array is depth more than 1 +includes: [compareArray.js] +---*/ + +assert(compareArray([1, [2]].flatMap(function(ele) { + return ele * 2; +}), [2, 4]), 'array depth is 1'); + +assert(compareArray([1, [2], [[3]]].flatMap(function(ele) { + return ele * 2; +}), [2, 4, 6]), 'array depth is more than 1'); + +var actual = [1, [2], [3, [3]]].flatMap(function(ele) { + return ele * 2; +}); + +assert.sameValue(actual[0], 2); +assert.sameValue(actual[1], 4); +assert(isNaN(actual[2])); diff --git a/test/built-ins/Array/prototype/flatMap/length.js b/test/built-ins/Array/prototype/flatMap/length.js new file mode 100644 index 0000000000..e93fc14680 --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/length.js @@ -0,0 +1,18 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: sec-array.prototype.flatMap +description: Array.prototype.flatMap.length value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.flatMap.length, 1, + 'The value of `Array.prototype.flatmap.length` is `1`' +); + +verifyNotEnumerable(Array.prototype.flatMap, 'length'); +verifyNotWritable(Array.prototype.flatMap, 'length'); +verifyConfigurable(Array.prototype.flatMap, 'length'); diff --git a/test/built-ins/Array/prototype/flatMap/name.js b/test/built-ins/Array/prototype/flatMap/name.js new file mode 100644 index 0000000000..7d0bff1745 --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/name.js @@ -0,0 +1,18 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: sec-array.prototype.flatmap +description: Array.prototype.flatmap name value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.flatMap.name, 'flatMap', + 'The value of `Array.prototype.flatMap.name` is `"flatMap"`' +); + +verifyNotEnumerable(Array.prototype.flatMap, 'name'); +verifyNotWritable(Array.prototype.flatMap, 'name'); +verifyConfigurable(Array.prototype.flatMap, 'name'); diff --git a/test/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js b/test/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js new file mode 100644 index 0000000000..9c46e7d5bd --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js @@ -0,0 +1,11 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + non callable argument should throw TypeError Exception +---*/ + +assert.throws(TypeError, function () { + [].flatMap({}); +}, 'non callable argument'); diff --git a/test/built-ins/Array/prototype/flatMap/non-object-ctor-throws.js b/test/built-ins/Array/prototype/flatMap/non-object-ctor-throws.js new file mode 100644 index 0000000000..962bd16fb4 --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/non-object-ctor-throws.js @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when `constructor` property is neither an Object nor undefined + - if IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; + +a.constructor = null; +assert.throws(TypeError, function() { + a.flatMap(); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flatMap(); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flatMap(); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flatMap(); +}, 'boolean value'); + diff --git a/test/built-ins/Array/prototype/flatMap/null-undefined-input-throws.js b/test/built-ins/Array/prototype/flatMap/null-undefined-input-throws.js new file mode 100644 index 0000000000..841d47734e --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/null-undefined-input-throws.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + null or undefined should throw TypeError Exception +---*/ + +assert.throws(TypeError, function() { + [].flatMap.call(null); +}, 'null value'); + +assert.throws(TypeError, function() { + [].flatMap.call(); +}, 'missing'); + +assert.throws(TypeError, function() { + [].flatMap.call(void 0); +}, 'undefined'); + diff --git a/test/built-ins/Array/prototype/flatMap/thisArg-argument.js b/test/built-ins/Array/prototype/flatMap/thisArg-argument.js new file mode 100644 index 0000000000..097ec0c872 --- /dev/null +++ b/test/built-ins/Array/prototype/flatMap/thisArg-argument.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when thisArg is provided + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +includes: [compareArray.js] +---*/ + +"use strict"; + +var a; + +assert(compareArray([1].flatMap(function() { return this}, "TestString"), ["TestString"])); +assert(compareArray([1].flatMap(function() { return this}, 1), [1])); +assert(compareArray([1].flatMap(function() { return this}, null), [null])); +assert(compareArray([1].flatMap(function() { return this}, true), [true])); +assert(compareArray([1].flatMap(function() { return this}, a = {}), [a])); +assert(compareArray([1].flatMap(function() { return this}, void 0), [undefined])); diff --git a/test/built-ins/Array/prototype/flatten/array-like-objects.js b/test/built-ins/Array/prototype/flatten/array-like-objects.js new file mode 100644 index 0000000000..d4a210444b --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/array-like-objects.js @@ -0,0 +1,31 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + array-like objects can be flattened +includes: [compareArray.js] +---*/ + +function takesTwoParams(a, b) { + return Array.prototype.flatten.call(arguments); +} + +var actual = takesTwoParams(1,[2]); +var expected = [1, 2]; + +assert(compareArray(actual, expected), 'arguments array like object'); + +var a = { + "length": 1, + "0": 'a' +}; + +actual = Array.prototype.flatten.call(a); +assert.sameValue(JSON.stringify(actual), JSON.stringify(['a']), 'array like objects'); + +a = { + "length": undefined, + "0": 'a' +}; +assert.sameValue(JSON.stringify(actual), JSON.stringify([]), 'array like objects undefined length'); diff --git a/test/built-ins/Array/prototype/flatten/bound-function-call.js b/test/built-ins/Array/prototype/flatten/bound-function-call.js new file mode 100644 index 0000000000..e456ba0318 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/bound-function-call.js @@ -0,0 +1,13 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + using bound functions +includes: [compareArray.js] +---*/ + +var a = [1,[1]]; +var flattenIt = [].flatten.bind(a); + +assert(compareArray(flattenIt(), [1, 1]), 'bound functions'); diff --git a/test/built-ins/Array/prototype/flatten/empty-array-elements.js b/test/built-ins/Array/prototype/flatten/empty-array-elements.js new file mode 100644 index 0000000000..ebcf785869 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/empty-array-elements.js @@ -0,0 +1,15 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + arrays with empty arrays elements +includes: [compareArray.js] +---*/ + +var a; +assert(compareArray([].flatten([[]]), [])); +assert(compareArray(Array.prototype.flatten.call([[], []]), [])); +assert(compareArray(Array.prototype.flatten.call([[], [1]]), [1])); +assert(compareArray(Array.prototype.flatten.call([[], [1, a = []]]), [1, a])); +assert.sameValue(JSON.stringify(Array.prototype.flatten.call([{}, []])), JSON.stringify([{}])); diff --git a/test/built-ins/Array/prototype/flatten/empty-object-elements.js b/test/built-ins/Array/prototype/flatten/empty-object-elements.js new file mode 100644 index 0000000000..6bc6086c81 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/empty-object-elements.js @@ -0,0 +1,12 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + arrays with empty object elements +---*/ + +assert.sameValue(JSON.stringify(Array.prototype.flatten.call([{}])), JSON.stringify([{}])); +assert.sameValue(JSON.stringify(Array.prototype.flatten.call([{}, [{}]])), JSON.stringify([{}, {}])); +assert.sameValue(JSON.stringify(Array.prototype.flatten.call([[{null: {}}], [{}]])), JSON.stringify([{null: {}}, {}])); +assert.sameValue(JSON.stringify(Array.prototype.flatten.call([[{null: null}], [{}]])), JSON.stringify([{null: null}, {}])); diff --git a/test/built-ins/Array/prototype/flatten/length.js b/test/built-ins/Array/prototype/flatten/length.js new file mode 100644 index 0000000000..1f32fecc81 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/length.js @@ -0,0 +1,18 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: sec-array.prototype.flatten +description: Array.prototype.flatten.length value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.flatten.length, 0, + 'The value of `Array.prototype.flatten.length` is `0`' +); + +verifyNotEnumerable(Array.prototype.flatten, 'length'); +verifyNotWritable(Array.prototype.flatten, 'length'); +verifyConfigurable(Array.prototype.flatten, 'length'); diff --git a/test/built-ins/Array/prototype/flatten/name.js b/test/built-ins/Array/prototype/flatten/name.js new file mode 100644 index 0000000000..3344833fee --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/name.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + Array.prototype.flatten.name value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + Array.prototype.flatten.name, 'flatten', + 'The value of `Array.prototype.flatten.name` is `"flatten"`' +); + +verifyNotEnumerable(Array.prototype.flatten, 'name'); +verifyNotWritable(Array.prototype.flatten, 'name'); +verifyConfigurable(Array.prototype.flatten, 'name'); + diff --git a/test/built-ins/Array/prototype/flatten/non-numeric-depth-should-not-throw.js b/test/built-ins/Array/prototype/flatten/non-numeric-depth-should-not-throw.js new file mode 100644 index 0000000000..52f0892464 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/non-numeric-depth-should-not-throw.js @@ -0,0 +1,42 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + if the argument is a string or object, the depthNum is 0 +includes: [compareArray.js] +---*/ + +var a = [1, [2]]; +var expected = a; + +// non integral string depthNum is converted to 0 +var depthNum = 'TestString'; +var actual = a.flatten(depthNum); +assert(compareArray(actual, expected), 'non integral string depthNum'); + +// object type depthNum is converted to 0 +depthNum = {}; +var actual = a.flatten(depthNum); +assert(compareArray(actual, expected), 'object type depthNum'); + +// negative infinity depthNum is converted to 0 +depthNum = Number.NEGATIVE_INFINITY; +var actual = a.flatten(depthNum); +assert(compareArray(actual, expected), 'negative infinity depthNum'); + +// positive zero depthNum is converted to 0 +depthNum = +0; +var actual = a.flatten(depthNum); +assert(compareArray(actual, expected), 'positive zero depthNum'); + +// negative zero depthNum is converted to 0 +depthNum = -0; +var actual = a.flatten(depthNum); +assert(compareArray(actual, expected), 'negative zero depthNum'); + +// integral string depthNum is converted to an integer +depthNum = '1'; +var actual = a.flatten(depthNum); +expected = [1, 2] +assert(compareArray(actual, expected), 'integral string depthNum'); diff --git a/test/built-ins/Array/prototype/flatten/non-object-ctor-throws.js b/test/built-ins/Array/prototype/flatten/non-object-ctor-throws.js new file mode 100644 index 0000000000..853ee8cd78 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/non-object-ctor-throws.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + Behavior when `constructor` property is neither an Object nor undefined + - if IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; + +a.constructor = null; +assert.throws(TypeError, function() { + a.flatten(); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flatten(); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flatten(); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flatten(); +}, 'boolean value'); diff --git a/test/built-ins/Array/prototype/flatten/null-undefined-elements.js b/test/built-ins/Array/prototype/flatten/null-undefined-elements.js new file mode 100644 index 0000000000..247be9a8a6 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/null-undefined-elements.js @@ -0,0 +1,15 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + arrays with null, and undefined +includes: [compareArray.js] +---*/ +var a; + +assert(compareArray(Array.prototype.flatten.call([1, null, void 0]), [1, null, undefined])); +assert(compareArray(Array.prototype.flatten.call([1,[null, void 0]]), [1, null, undefined])); +assert(compareArray(Array.prototype.flatten.call([[null, void 0], [null, void 0]]), [null, undefined, null, undefined])); +assert(compareArray(Array.prototype.flatten.call([1,[null, a = [void 0]]], 1), [1, null, a])); +assert(compareArray(Array.prototype.flatten.call([1,[null, [void 0]]], 2), [1, null, undefined])); diff --git a/test/built-ins/Array/prototype/flatten/null-undefined-input-throws.js b/test/built-ins/Array/prototype/flatten/null-undefined-input-throws.js new file mode 100644 index 0000000000..443840ff0f --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/null-undefined-input-throws.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + null or undefined should throw TypeError Exception +---*/ + +assert.throws(TypeError, function() { + [].flatten.call(null); +}, 'null value'); + +assert.throws(TypeError, function() { + [].flatten.call(); +}, 'missing'); + +assert.throws(TypeError, function() { + [].flatten.call(void 0); +}, 'undefined'); + diff --git a/test/built-ins/Array/prototype/flatten/positive-infinity.js b/test/built-ins/Array/prototype/flatten/positive-infinity.js new file mode 100644 index 0000000000..ea2f882e79 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/positive-infinity.js @@ -0,0 +1,11 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + if the argument is a positive infinity, the depthNum is max depth of the array +includes: [compareArray.js] +---*/ + +var a = [1, [2, [3, [4]]]] +assert(compareArray(a.flatten(Number.POSITIVE_INFINITY), [1, 2, 3, 4]), 'positive infinity depthNum'); diff --git a/test/built-ins/Array/prototype/flatten/prop-desc.js b/test/built-ins/Array/prototype/flatten/prop-desc.js new file mode 100644 index 0000000000..3dc6fe3291 --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/prop-desc.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +es6id: 22.1.3 +description: Property type and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof Array.prototype.flatten, + 'function', + '`typeof Array.prototype.flatten` is `function`' +); + +verifyNotEnumerable(Array.prototype, 'flatten'); +verifyWritable(Array.prototype, 'flatten'); +verifyConfigurable(Array.prototype, 'flatten'); diff --git a/test/built-ins/Array/prototype/flatten/symbol-object-create-null-depth-throws.js b/test/built-ins/Array/prototype/flatten/symbol-object-create-null-depth-throws.js new file mode 100644 index 0000000000..b12046925d --- /dev/null +++ b/test/built-ins/Array/prototype/flatten/symbol-object-create-null-depth-throws.js @@ -0,0 +1,21 @@ +// Copyright (C) 2018 Shilpi Jain. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flatten +description: > + if the argument is a Symbol or Object null, it throws exception +---*/ + +var a = []; +var depthNum = Symbol(); + +assert.throws(TypeError, function() { + a.flatten(depthNum); +}, 'symbol value'); + +depthNum = Object.create(null); + +assert.throws(TypeError, function() { + a.flatten(depthNum); +}, 'object create null'); +