summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/new.target/value-via-new.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/expressions/new.target/value-via-new.js')
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-new.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-new.js b/js/src/tests/test262/language/expressions/new.target/value-via-new.js
new file mode 100644
index 0000000000..795e9dc0e8
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-new.js
@@ -0,0 +1,42 @@
+// Copyright (C) 2016 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-new-operator-runtime-semantics-evaluation
+es6id: 12.3.3.1
+description: Value when invoked via NewExpression
+info: |
+ NewExpression:newNewExpression
+
+ 1. Return ? EvaluateNew(NewExpression, empty).
+
+ MemberExpression:newMemberExpressionArguments
+
+ 2. Return ? EvaluateNew(MemberExpression, Arguments).
+
+ 12.3.3.1.1 Runtime Semantics: EvaluateNew
+
+ [...]
+ 8. Return ? Construct(constructor, argList).
+
+ 7.3.13 Construct (F [ , argumentsList [ , newTarget ]])
+
+ 1. If newTarget was not passed, let newTarget be F.
+features: [new.target]
+---*/
+
+var newTarget = null;
+function f() {
+ newTarget = new.target;
+}
+
+new f;
+
+assert.sameValue(newTarget, f, 'Invoked without Arguments');
+
+newTarget = null;
+
+new f();
+
+assert.sameValue(newTarget, f, 'Invoked with Arguments');
+
+reportCompare(0, 0);