Backed out 3 changesets (bug 1892041) for causing failures on async-module-does-not...
[gecko.git] / js / src / tests / test262 / built-ins / JSON / parse / not-a-constructor.js
blobd46040d8a31d0dd31ead36514689740a195f511d
1 // Copyright (C) 2020 Rick Waldron. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-ecmascript-standard-built-in-objects
6 description: >
7   JSON.parse does not implement [[Construct]], is not new-able
8 info: |
9   ECMAScript Function Objects
11   Built-in function objects that are not identified as constructors do not
12   implement the [[Construct]] internal method unless otherwise specified in
13   the description of a particular function.
15   sec-evaluatenew
17   ...
18   7. If IsConstructor(constructor) is false, throw a TypeError exception.
19   ...
20 includes: [isConstructor.js]
21 features: [Reflect.construct, arrow-function]
22 ---*/
24 assert.sameValue(isConstructor(JSON.parse), false, 'isConstructor(JSON.parse) must return false');
26 assert.throws(TypeError, () => {
27   new JSON.parse('{}');
28 }, '`new JSON.parse(\'{}\')` throws TypeError');
31 reportCompare(0, 0);