Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests for ECMA262 #2216 #2878

Merged
merged 1 commit into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions test/built-ins/Function/internals/Call/class-ctor-realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
rwaldron marked this conversation as resolved.
Show resolved Hide resolved

assert.throws(TypeError, function() {
assert.throws(TE, function() {
C();
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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);