From 516ca9af3938bfe8694cf0998f9193c57e826adb Mon Sep 17 00:00:00 2001 From: Gus Caplan Date: Wed, 21 Oct 2020 20:14:28 -0400 Subject: [PATCH] Update tests for ECMA262 #2216 https://github.com/tc39/ecma262/pull/2216 --- .../internals/Call/class-ctor-realm.js | 14 +++--- ...nstructor-inferred-observable-iteration.js | 47 ------------------- .../default-constructor-spread-override.js | 40 ++-------------- 3 files changed, 11 insertions(+), 90 deletions(-) delete mode 100644 test/language/statements/class/constructor-inferred-observable-iteration.js diff --git a/test/built-ins/Function/internals/Call/class-ctor-realm.js b/test/built-ins/Function/internals/Call/class-ctor-realm.js index e66f7bc111..60762fccc1 100644 --- a/test/built-ins/Function/internals/Call/class-ctor-realm.js +++ b/test/built-ins/Function/internals/Call/class-ctor-realm.js @@ -3,17 +3,15 @@ /*--- esid: sec-ecmascript-function-objects-call-thisargument-argumentslist description: > - Error when invoking a class constructor (honoring the Realm of the current - execution context) -info: | - [...] - 2. If F's [[FunctionKind]] internal slot is "classConstructor", throw a - TypeError exception. + Error when invoking a default class constructor, honoring the Realm + that the class was defined in. features: [cross-realm, class] ---*/ -var C = $262.createRealm().global.eval('0, class {}'); +const realm = $262.createRealm(); +const C = realm.global.eval('(class {})'); +const TE = realm.global.eval('TypeError'); -assert.throws(TypeError, function() { +assert.throws(TE, function() { C(); }); diff --git a/test/language/statements/class/constructor-inferred-observable-iteration.js b/test/language/statements/class/constructor-inferred-observable-iteration.js deleted file mode 100644 index f6b7d9021f..0000000000 --- a/test/language/statements/class/constructor-inferred-observable-iteration.js +++ /dev/null @@ -1,47 +0,0 @@ -// 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-runtime-semantics-classdefinitionevaluation -es6id: 14.5.14 -description: > - Observable iteration of arguments during execution of "inferred" constructor -info: | - [...] - 10. If constructor is empty, then - a. If ClassHeritageopt is present and superclass is not null, then - i. Let constructor be the result of parsing the source text - - constructor(... args){ super (...args);} - - using the syntactic grammar with the goal symbol MethodDefinition[~Yield]. -features: [Symbol.iterator] ----*/ - -var otherIterator = ['fifth', 'sixth', 'seventh'][Symbol.iterator](); -var spread, parentArgs; -function Parent() { - parentArgs = arguments; -} -class C extends Parent {} - -Array.prototype[Symbol.iterator] = function() { - spread = this; - return otherIterator; -}; - -new C('first', 'second', 'third', 'fourth'); - -assert.sameValue(Object.getPrototypeOf(spread), Array.prototype); -assert.sameValue(spread.length, 4); -assert.sameValue(spread[0], 'first'); -assert.sameValue(spread[1], 'second'); -assert.sameValue(spread[2], 'third'); -assert.sameValue(spread[3], 'fourth'); - -assert.sameValue( - typeof parentArgs, 'object', 'parent arguments object' -); -assert.sameValue(parentArgs.length, 3); -assert.sameValue(parentArgs[0], 'fifth'); -assert.sameValue(parentArgs[1], 'sixth'); -assert.sameValue(parentArgs[2], 'seventh'); diff --git a/test/language/statements/class/subclass/default-constructor-spread-override.js b/test/language/statements/class/subclass/default-constructor-spread-override.js index b3a7babcec..679deaed34 100644 --- a/test/language/statements/class/subclass/default-constructor-spread-override.js +++ b/test/language/statements/class/subclass/default-constructor-spread-override.js @@ -4,52 +4,22 @@ /*--- esid: sec-runtime-semantics-classdefinitionevaluation description: > - Default class constructor uses standard iterator spread semantics. -info: | - 14.5.14 Runtime Semantics: ClassDefinitionEvaluation - ... - 10. If constructor is empty, then - a. If ClassHeritageopt is present, then - i Let constructor be the result of parsing the source text - constructor(...args){ super(...args); } - using the syntactic grammar with the goal symbol MethodDefinition. - ... - - 14.1.19 Runtime Semantics: IteratorBindingInitialization - `FunctionRestParameter : BindingRestElement` - 1. Let result be IteratorBindingInitialization of BindingRestElement with arguments iteratorRecord and environment. - - 13.3.3.6 Runtime Semantics: IteratorBindingInitialization - `BindingRestElement : ...BindingIdentifier` - ... - 2. Let A be ArrayCreate(0). - ... - - 12.3.6.1 Runtime Semantics: ArgumentListEvaluation - `ArgumentList : ArgumentList , ...AssignmentExpression` - ... - 3. Let iterator be ? GetIterator(? GetValue(spreadRef)). - ... + Default class constructor does not use argument evaluation. features: [Symbol.iterator] ---*/ -var arrayIterator = Array.prototype[Symbol.iterator]; - -// Redefine Array iterator to change the result of spreading `args` in `super(...args)`. Array.prototype[Symbol.iterator] = function() { - return arrayIterator.call(["spread-value"]); + $ERROR('@@iterator invoked'); }; -var receivedValue; - class Base { constructor(value) { - receivedValue = value; + this.value = value; } } class Derived extends Base {} -new Derived(); +const instance = new Derived(5); -assert.sameValue(receivedValue, "spread-value"); +assert.sameValue(instance.value, 5);