Skip to content

Commit

Permalink
Update tests for ECMA262 #2216
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron authored and devsnek committed Oct 27, 2020
1 parent 0001489 commit 73dd91b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 91 deletions.
21 changes: 12 additions & 9 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,20 @@
/*---
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() {
let error;
try {
C();
});
} catch (e) {
error = e;
}

assert(e instanceof TE);

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);

0 comments on commit 73dd91b

Please sign in to comment.