diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js new file mode 100644 index 0000000000..fe6886dcc1 --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flat/non-object-ctor-throws.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-array.prototype.flat +description: > + Behavior when `constructor` property is neither an Object nor undefined + - if IsConstructor(C) is false, throw a TypeError exception. +features: [Array.prototype.flat] +---*/ + +assert.sameValue(typeof Array.prototype.flat, 'function'); + +var a = []; +a.constructor = null; +assert.throws(TypeError, function() { + a.flat(); +}, 'null value'); + +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flat(); +}, 'number value'); + +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flat(); +}, 'string value'); + +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flat(); +}, 'boolean value'); + +reportCompare(0, 0); |