mirror of https://github.com/tc39/test262.git
Update tests for ECMA262 #2216
https://github.com/tc39/ecma262/pull/2216
This commit is contained in:
parent
0d922ddc97
commit
516ca9af39
|
@ -3,17 +3,15 @@
|
||||||
/*---
|
/*---
|
||||||
esid: sec-ecmascript-function-objects-call-thisargument-argumentslist
|
esid: sec-ecmascript-function-objects-call-thisargument-argumentslist
|
||||||
description: >
|
description: >
|
||||||
Error when invoking a class constructor (honoring the Realm of the current
|
Error when invoking a default class constructor, honoring the Realm
|
||||||
execution context)
|
that the class was defined in.
|
||||||
info: |
|
|
||||||
[...]
|
|
||||||
2. If F's [[FunctionKind]] internal slot is "classConstructor", throw a
|
|
||||||
TypeError exception.
|
|
||||||
features: [cross-realm, class]
|
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();
|
C();
|
||||||
});
|
});
|
||||||
|
|
|
@ -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');
|
|
|
@ -4,52 +4,22 @@
|
||||||
/*---
|
/*---
|
||||||
esid: sec-runtime-semantics-classdefinitionevaluation
|
esid: sec-runtime-semantics-classdefinitionevaluation
|
||||||
description: >
|
description: >
|
||||||
Default class constructor uses standard iterator spread semantics.
|
Default class constructor does not use argument evaluation.
|
||||||
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)).
|
|
||||||
...
|
|
||||||
features: [Symbol.iterator]
|
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() {
|
Array.prototype[Symbol.iterator] = function() {
|
||||||
return arrayIterator.call(["spread-value"]);
|
$ERROR('@@iterator invoked');
|
||||||
};
|
};
|
||||||
|
|
||||||
var receivedValue;
|
|
||||||
|
|
||||||
class Base {
|
class Base {
|
||||||
constructor(value) {
|
constructor(value) {
|
||||||
receivedValue = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Derived extends Base {}
|
class Derived extends Base {}
|
||||||
|
|
||||||
new Derived();
|
const instance = new Derived(5);
|
||||||
|
|
||||||
assert.sameValue(receivedValue, "spread-value");
|
assert.sameValue(instance.value, 5);
|
||||||
|
|
Loading…
Reference in New Issue