summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/new.target
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/expressions/new.target')
-rw-r--r--js/src/tests/test262/language/expressions/new.target/asi.js69
-rw-r--r--js/src/tests/test262/language/expressions/new.target/browser.js0
-rw-r--r--js/src/tests/test262/language/expressions/new.target/escaped-new.js26
-rw-r--r--js/src/tests/test262/language/expressions/new.target/escaped-target.js26
-rw-r--r--js/src/tests/test262/language/expressions/new.target/shell.js0
-rw-r--r--js/src/tests/test262/language/expressions/new.target/unary-expr.js32
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-call.js25
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-fpapply.js23
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-fpcall.js23
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-member.js36
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-new.js42
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-reflect-apply.js23
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-reflect-construct.js30
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-super-call.js43
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-super-property.js36
-rw-r--r--js/src/tests/test262/language/expressions/new.target/value-via-tagged-template.js25
16 files changed, 459 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/new.target/asi.js b/js/src/tests/test262/language/expressions/new.target/asi.js
new file mode 100644
index 0000000000..e0244833a9
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/asi.js
@@ -0,0 +1,69 @@
+// 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-meta-properties-runtime-semantics-evaluation
+es6id: 12.3.8.1
+description: NewTarget is composed of three distinct tokens
+features: [new.target]
+---*/
+
+var newTarget = null;
+
+var withSpaces = function() {
+ newTarget = new . target;
+};
+
+withSpaces();
+assert.sameValue(newTarget, undefined, 'tokens seperated by whitespace');
+
+new withSpaces();
+assert.sameValue(newTarget, withSpaces, 'tokens separateed by whitespace');
+
+newTarget = null;
+
+var withLineBreaks = function() {
+ newTarget = new
+
+.
+
+target;
+};
+
+withLineBreaks();
+assert.sameValue(newTarget, undefined, 'tokens seperated by line breaks');
+
+new withLineBreaks();
+assert.sameValue(newTarget, withLineBreaks, 'tokens seperated by line breaks');
+
+var withSLDC = function() {
+ newTarget = new/* */./* */target;
+};
+
+withSLDC();
+assert.sameValue(
+ newTarget, undefined, 'tokens separated by SingleLineDelimitedComments'
+);
+
+new withSLDC();
+assert.sameValue(
+ newTarget, withSLDC, 'tokens separated by SingleLineDelimitedComments'
+);
+
+
+var withMLC = function() {
+ newTarget = new/*
+ */./*
+ */target;
+};
+
+withMLC();
+assert.sameValue(
+ newTarget, undefined, 'tokens separated by MultiLineComments'
+);
+
+new withMLC();
+assert.sameValue(
+ newTarget, withMLC, 'tokens separated by MultiLineComments'
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/browser.js b/js/src/tests/test262/language/expressions/new.target/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/browser.js
diff --git a/js/src/tests/test262/language/expressions/new.target/escaped-new.js b/js/src/tests/test262/language/expressions/new.target/escaped-new.js
new file mode 100644
index 0000000000..4e7ac97d5c
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/escaped-new.js
@@ -0,0 +1,26 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-grammar-notation
+description: >
+ The `new` keyword must not contain Unicode escape sequences.
+info: |
+ Terminal symbols of the lexical, RegExp, and numeric string grammars are shown
+ in fixed width font, both in the productions of the grammars and throughout this
+ specification whenever the text directly refers to such a terminal symbol. These
+ are to appear in a script exactly as written. All terminal symbol code points
+ specified in this way are to be understood as the appropriate Unicode code points
+ from the Basic Latin range, as opposed to any similar-looking code points from
+ other Unicode ranges.
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+function f() {
+ n\u0065w.target;
+}
diff --git a/js/src/tests/test262/language/expressions/new.target/escaped-target.js b/js/src/tests/test262/language/expressions/new.target/escaped-target.js
new file mode 100644
index 0000000000..f6cab0aac5
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/escaped-target.js
@@ -0,0 +1,26 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-grammar-notation
+description: >
+ The `target` contextual keyword must not contain Unicode escape sequences.
+info: |
+ Terminal symbols of the lexical, RegExp, and numeric string grammars are shown
+ in fixed width font, both in the productions of the grammars and throughout this
+ specification whenever the text directly refers to such a terminal symbol. These
+ are to appear in a script exactly as written. All terminal symbol code points
+ specified in this way are to be understood as the appropriate Unicode code points
+ from the Basic Latin range, as opposed to any similar-looking code points from
+ other Unicode ranges.
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+function f() {
+ new.t\u0061rget;
+}
diff --git a/js/src/tests/test262/language/expressions/new.target/shell.js b/js/src/tests/test262/language/expressions/new.target/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/shell.js
diff --git a/js/src/tests/test262/language/expressions/new.target/unary-expr.js b/js/src/tests/test262/language/expressions/new.target/unary-expr.js
new file mode 100644
index 0000000000..d632717998
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/unary-expr.js
@@ -0,0 +1,32 @@
+// |reftest| async
+// Copyright (C) 2019 Alexey Shvayka. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: prod-UnaryExpression
+description: >
+ While increments and decrements are restricted to use with NewTarget,
+ other unary operators should not throw SyntaxError.
+info: |
+ UnaryExpression[Yield, Await]:
+ UpdateExpression[?Yield, ?Await]:
+ LeftHandSideExpression[?Yield, ?Await]:
+ NewExpression[?Yield, ?Await]:
+ MemberExpression[Yield, Await]:
+ MetaProperty:
+ NewTarget
+features: [new.target, async-functions]
+flags: [async]
+---*/
+
+(function() { assert.sameValue(delete (new.target), true); })();
+(function() { assert.sameValue(void new.target, undefined); })();
+new function() { assert.sameValue(typeof new.target, 'function'); };
+new function() { assert.sameValue(+(new.target), NaN); };
+(function() { assert.sameValue(-(new.target), NaN); })();
+new function() { assert.sameValue(~new.target, -1); };
+(function() { assert.sameValue(!new.target, true); })();
+new function() { assert.sameValue(delete void typeof +-~!(new.target), true); };
+
+(async function() {
+ assert.sameValue(await new.target, undefined);
+})().then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-call.js b/js/src/tests/test262/language/expressions/new.target/value-via-call.js
new file mode 100644
index 0000000000..29483d17a4
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-call.js
@@ -0,0 +1,25 @@
+// 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-function-calls-runtime-semantics-evaluation
+es6id: 12.3.4.1
+description: Value when invoked via CallExpression
+info: |
+ CallExpression : MemberExpressionArguments
+
+ [...]
+ 8. Return ? EvaluateDirectCall(func, thisValue, Arguments, tailCall).
+features: [new.target]
+---*/
+
+var newTarget = null;
+
+function f() {
+ newTarget = new.target;
+}
+
+f();
+
+assert.sameValue(newTarget, undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-fpapply.js b/js/src/tests/test262/language/expressions/new.target/value-via-fpapply.js
new file mode 100644
index 0000000000..603a1a700d
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-fpapply.js
@@ -0,0 +1,23 @@
+// 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-function.prototype.apply
+es6id: 19.2.3.1
+description: Value when invoked via `Function.prototype.apply`
+info: |
+ [...]
+ 5. Return ? Call(func, thisArg, argList).
+features: [new.target]
+---*/
+
+var newTarget = null;
+
+function f() {
+ newTarget = new.target;
+}
+
+f.apply({});
+
+assert.sameValue(newTarget, undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-fpcall.js b/js/src/tests/test262/language/expressions/new.target/value-via-fpcall.js
new file mode 100644
index 0000000000..9e9c63aea6
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-fpcall.js
@@ -0,0 +1,23 @@
+// 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-function.prototype.call
+es6id: 19.2.3.3
+description: Value when invoked via `Function.prototype.call`
+info: |
+ [...]
+ 5. Return ? Call(func, thisArg, argList).
+features: [new.target]
+---*/
+
+var newTarget = null;
+
+function f() {
+ newTarget = new.target;
+}
+
+f.call({});
+
+assert.sameValue(newTarget, undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-member.js b/js/src/tests/test262/language/expressions/new.target/value-via-member.js
new file mode 100644
index 0000000000..6c668a747f
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-member.js
@@ -0,0 +1,36 @@
+// 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-property-accessors-runtime-semantics-evaluation
+es6id: 12.3.2.1
+description: Value when invoked via MemberExpression
+info: |
+ MemberExpression:MemberExpression.IdentifierName
+
+ [...]
+ 6. Return a value of type Reference whose base value component is bv, whose
+ referenced name component is propertyNameString, and whose strict
+ reference flag is strict.
+
+ 13.5.1 Runtime Semantics: Evaluation
+
+ ExpressionStatement : Expression ;
+
+ 1. Let exprRef be the result of evaluating Expression.
+ 2. Return ? GetValue(exprRef).
+features: [new.target]
+---*/
+
+var newTarget = null;
+
+var obj = {
+ get m() {
+ newTarget = new.target;
+ }
+};
+
+obj.m;
+
+assert.sameValue(newTarget, undefined);
+
+reportCompare(0, 0);
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);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-reflect-apply.js b/js/src/tests/test262/language/expressions/new.target/value-via-reflect-apply.js
new file mode 100644
index 0000000000..f811818cbc
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-reflect-apply.js
@@ -0,0 +1,23 @@
+// 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-reflect.apply
+es6id: 26.1.1
+description: Value when invoked via `Reflect.apply`
+info: |
+ [...]
+ 5. Return ? Call(target, thisArgument, args).
+features: [new.target, Reflect]
+---*/
+
+var newTarget = null;
+
+function f() {
+ newTarget = new.target;
+}
+
+Reflect.apply(f, {}, []);
+
+assert.sameValue(newTarget, undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-reflect-construct.js b/js/src/tests/test262/language/expressions/new.target/value-via-reflect-construct.js
new file mode 100644
index 0000000000..6e157d465b
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-reflect-construct.js
@@ -0,0 +1,30 @@
+// 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-reflect.construct
+es6id: 26.1.2
+description: Value when invoked via `Reflect.construct`
+info: |
+ [...]
+ 2. If newTarget is not present, let newTarget be target.
+ [...]
+ 5. Return ? Construct(target, args, newTarget).
+features: [new.target, Reflect, Reflect.construct]
+---*/
+
+var customNewTarget = function() {};
+var newTarget = null;
+
+function f() {
+ newTarget = new.target;
+}
+
+Reflect.construct(f, []);
+
+assert.sameValue(newTarget, f, 'NewTarget unspecified');
+
+Reflect.construct(f, [], customNewTarget);
+
+assert.sameValue(newTarget, customNewTarget, 'NewTarget explicitly defined');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-super-call.js b/js/src/tests/test262/language/expressions/new.target/value-via-super-call.js
new file mode 100644
index 0000000000..730f086f21
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-super-call.js
@@ -0,0 +1,43 @@
+// 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-super-keyword-runtime-semantics-evaluation
+es6id: 12.3.5.1
+description: Value when invoked via SuperCall
+info: |
+ SuperCall : super Arguments
+
+ 1. Let newTarget be GetNewTarget().
+ [...]
+ 6. Let result be ? Construct(func, argList, newTarget).
+ [...]
+features: [class, new.target]
+---*/
+
+var baseNewTarget, parentNewTarget;
+
+class Base {
+ constructor() {
+ baseNewTarget = new.target;
+ }
+}
+
+class Parent extends Base {
+ constructor() {
+ parentNewTarget = new.target;
+ super();
+ }
+}
+
+class Child extends Parent {
+ constructor() {
+ super();
+ }
+}
+
+new Child();
+
+assert.sameValue(parentNewTarget, Child, 'within "parent" constructor');
+assert.sameValue(baseNewTarget, Child, 'within "base" constructor');
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-super-property.js b/js/src/tests/test262/language/expressions/new.target/value-via-super-property.js
new file mode 100644
index 0000000000..e19b1e2c55
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-super-property.js
@@ -0,0 +1,36 @@
+// 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-super-keyword-runtime-semantics-evaluation
+es6id: 12.3.5.1
+description: Value when invoked via SuperCall
+info: |
+ SuperCall : super Arguments
+
+ 1. Let newTarget be GetNewTarget().
+ [...]
+ 6. Let result be ? Construct(func, argList, newTarget).
+ [...]
+features: [class, new.target]
+---*/
+
+var newTarget = null;
+
+class Parent {
+ get attr() {
+ newTarget = new.target;
+ }
+}
+
+class Child extends Parent {
+ constructor() {
+ super();
+ super.attr;
+ }
+}
+
+new Child();
+
+assert.sameValue(newTarget, undefined);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/expressions/new.target/value-via-tagged-template.js b/js/src/tests/test262/language/expressions/new.target/value-via-tagged-template.js
new file mode 100644
index 0000000000..928af96d14
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/new.target/value-via-tagged-template.js
@@ -0,0 +1,25 @@
+// 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-tagged-templates-runtime-semantics-evaluation
+es6id: 12.3.7.1
+description: Value when invoked via tagged template
+info: |
+ MemberExpression : MemberExpression TemplateLiteral
+
+ [...]
+ 4. Return ? EvaluateCall(tagRef, TemplateLiteral, tailCall).
+features: [new.target, template]
+---*/
+
+var newTarget = null;
+
+function f() {
+ newTarget = new.target;
+}
+
+f``;
+
+assert.sameValue(newTarget, undefined);
+
+reportCompare(0, 0);