| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-new-operator |
| 5 |
es6id: 12.3.3 |
| 6 |
description: Realm of error object produced when operand is not a constructor |
| 7 |
info: | |
| 8 |
NewExpression : new NewExpression |
| 9 |
|
| 10 |
1. Return ? EvaluateNew(NewExpression, empty). |
| 11 |
|
| 12 |
MemberExpression : new MemberExpression Arguments |
| 13 |
|
| 14 |
1. Return ? EvaluateNew(MemberExpression, Arguments). |
| 15 |
|
| 16 |
12.3.3.1.1 Runtime Semantics: EvaluateNew |
| 17 |
|
| 18 |
7. If IsConstructor(constructor) is false, throw a TypeError exception. |
| 19 |
features: [cross-realm] |
| 20 |
---*/ |
| 21 |
|
| 22 |
var otherParseInt = $262.createRealm().global.parseInt; |
| 23 |
|
| 24 |
assert.sameValue(typeof otherParseInt, 'function'); |
| 25 |
|
| 26 |
assert.throws(TypeError, function() { |
| 27 |
new otherParseInt(0); |
| 28 |
}, 'production including Arguments'); |
| 29 |
|
| 30 |
assert.throws(TypeError, function() { |
| 31 |
new otherParseInt; |
| 32 |
}, 'production eliding Arguments'); |