Debian Codegraph @

js/src/tests/test262/language/expressions/new/ctorExpr-fn-ref-before-args-eval.js

raw
1 // Copyright (C) 2020 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-new-operator
6 description: >
7 The constructExpr is referenced before arguments in the same EvaluateNew evaluation.
8 info: |
9 NewExpression : new NewExpression
10 1. Return ? EvaluateNew(NewExpression, empty).
11 MemberExpression : new MemberExpression Arguments
12 1. Return ? EvaluateNew(MemberExpression, Arguments).
13
14 Runtime Semantics: EvaluateNew
15
16 3. Let ref be the result of evaluating constructExpr.
17 4. Let constructor be ? GetValue(ref).
18 5. If arguments is empty, let argList be a new empty List.
19 6. Else,
20 a. Let argList be ? ArgumentListEvaluation of arguments.
21 7. If IsConstructor(constructor) is false, throw a TypeError exception.
22 8. Return ? Construct(constructor, argList).
23 ---*/
24
25 var x = function() {
26 this.foo = 42;
27 };
28
29 var result = new x(x = 1);
30
31 assert.sameValue(x, 1);
32 assert.sameValue(result.foo, 42);
33
34 reportCompare(0, 0);