forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Builtin boilerplate tests from PR tc39#3866
Includes some proto-from-ctor-realm.js tests that look like standard tests for prototypes.
- Loading branch information
Showing
19 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
test/built-ins/AsyncDisposableStack/instance-extensible.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-asyncdisposablestack | ||
description: Instances of AsyncDisposableStack are extensible | ||
info: | | ||
AsyncDisposableStack( ) | ||
... | ||
2. Let asyncDisposableStack be ? OrdinaryCreateFromConstructor(NewTarget, "%AsyncDisposableStack.prototype%", « [[AsyncDisposableState]], [[DisposeCapability]] »). | ||
3. Set asyncDisposableStack.[[AsyncDisposableState]] to pending. | ||
4. Set asyncDisposableStack.[[DisposeCapability]] to NewDisposeCapability(). | ||
5. Return asyncDisposableStack. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
ObjectCreate ( proto [ , internalSlotsList ] ) | ||
4. Set obj.[[Prototype]] to proto. | ||
5. Set obj.[[Extensible]] to true. | ||
6. Return obj. | ||
features: [explicit-resource-management, Reflect] | ||
---*/ | ||
|
||
var stack = new AsyncDisposableStack(); | ||
assert.sameValue(Object.isExtensible(stack), true); |
59 changes: 59 additions & 0 deletions
59
test/built-ins/AsyncDisposableStack/proto-from-ctor-realm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-asyncdisposablestack | ||
description: Default [[Prototype]] value derived from realm of the newTarget | ||
info: | | ||
AsyncDisposableStack( ) | ||
... | ||
2. Let asyncDisposableStack be ? OrdinaryCreateFromConstructor(NewTarget, "%AsyncDisposableStack.prototype%", « [[AsyncDisposableState]], [[DisposeCapability]] »). | ||
3. Set asyncDisposableStack.[[AsyncDisposableState]] to pending. | ||
4. Set asyncDisposableStack.[[DisposeCapability]] to NewDisposeCapability(). | ||
5. Return asyncDisposableStack. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) | ||
3. Let proto be ? Get(constructor, 'prototype'). | ||
4. If Type(proto) is not Object, then | ||
a. Let realm be ? GetFunctionRealm(constructor). | ||
b. Set proto to realm's intrinsic object named intrinsicDefaultProto. | ||
5. Return proto. | ||
features: [explicit-resource-management, cross-realm, Reflect, Symbol] | ||
---*/ | ||
|
||
var other = $262.createRealm().global; | ||
var newTarget = new other.Function(); | ||
var stack; | ||
|
||
newTarget.prototype = undefined; | ||
stack = Reflect.construct(AsyncDisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.AsyncDisposableStack.prototype, 'newTarget.prototype is undefined'); | ||
|
||
newTarget.prototype = null; | ||
stack = Reflect.construct(AsyncDisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.AsyncDisposableStack.prototype, 'newTarget.prototype is null'); | ||
|
||
newTarget.prototype = true; | ||
stack = Reflect.construct(AsyncDisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.AsyncDisposableStack.prototype, 'newTarget.prototype is a Boolean'); | ||
|
||
newTarget.prototype = ''; | ||
stack = Reflect.construct(AsyncDisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.AsyncDisposableStack.prototype, 'newTarget.prototype is a String'); | ||
|
||
newTarget.prototype = Symbol(); | ||
stack = Reflect.construct(AsyncDisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.AsyncDisposableStack.prototype, 'newTarget.prototype is a Symbol'); | ||
|
||
newTarget.prototype = 1; | ||
stack = Reflect.construct(AsyncDisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.AsyncDisposableStack.prototype, 'newTarget.prototype is a Number'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-properties-of-asyncdisposablestack-constructor | ||
description: > | ||
The prototype of AsyncDisposableStack is Function.prototype | ||
info: | | ||
The value of the [[Prototype]] internal slot of the AsyncDisposableStack object is the | ||
intrinsic object %FunctionPrototype%. | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
assert.sameValue( | ||
Object.getPrototypeOf(AsyncDisposableStack), | ||
Function.prototype, | ||
'Object.getPrototypeOf(AsyncDisposableStack) returns the value of `Function.prototype`' | ||
); |
19 changes: 19 additions & 0 deletions
19
test/built-ins/AsyncDisposableStack/prototype/Symbol.asyncDispose.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-asyncdisposablestack.prototype-@@asyncDispose | ||
description: Initial state of the Symbol.asyncDispose property | ||
info: | | ||
The initial value of the @@asyncDispose property is the same function object as | ||
the initial value of the disposeAsync property. | ||
Per ES6 section 17, the method should exist on the Array prototype, and it | ||
should be writable and configurable, but not enumerable. | ||
includes: [propertyHelper.js] | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
assert.sameValue(AsyncDisposableStack.prototype[Symbol.asyncDispose], AsyncDisposableStack.prototype.disposeAsync); | ||
verifyNotEnumerable(AsyncDisposableStack.prototype, Symbol.asyncDispose); | ||
verifyWritable(AsyncDisposableStack.prototype, Symbol.asyncDispose); | ||
verifyConfigurable(AsyncDisposableStack.prototype, Symbol.asyncDispose); |
30 changes: 30 additions & 0 deletions
30
test/built-ins/AsyncDisposableStack/prototype/disposed/getter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-get-asyncdisposablestack.prototype.disposed | ||
description: > | ||
Property type and descriptor. | ||
info: | | ||
get AsyncDisposableStack.prototype.disposed | ||
17 ECMAScript Standard Built-in Objects | ||
includes: [propertyHelper.js] | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
var descriptor = Object.getOwnPropertyDescriptor(AsyncDisposableStack.prototype, 'disposed'); | ||
|
||
assert.sameValue( | ||
typeof descriptor.get, | ||
'function', | ||
'typeof descriptor.get is function' | ||
); | ||
assert.sameValue( | ||
typeof descriptor.set, | ||
'undefined', | ||
'typeof descriptor.set is undefined' | ||
); | ||
|
||
verifyNotEnumerable(AsyncDisposableStack.prototype, 'disposed'); | ||
verifyConfigurable(AsyncDisposableStack.prototype, 'disposed'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: The prototype of AsyncDisposableStack.prototype is Object.prototype | ||
esid: sec-properties-of-the-asyncdisposablestack-prototype-object | ||
info: | | ||
The value of the [[Prototype]] internal slot of the AsyncDisposableStack prototype object | ||
is the intrinsic object %Object.prototype%. | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
var proto = Object.getPrototypeOf(AsyncDisposableStack.prototype); | ||
assert.sameValue(proto, Object.prototype); |
13 changes: 13 additions & 0 deletions
13
test/built-ins/AsyncIteratorPrototype/Symbol.asyncDispose/is-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-%asynciteratorprototype%-@@asyncDispose | ||
description: > | ||
AsyncIterator.prototype[@@asyncDispose] is a built-in function | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
async function* generator() {} | ||
const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype)) | ||
|
||
assert.sameValue(typeof AsyncIteratorPrototype[Symbol.asyncDispose], 'function'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-disposablestack | ||
description: Instances of DisposableStack are extensible | ||
info: | | ||
DisposableStack( ) | ||
... | ||
2. Let disposableStack be ? OrdinaryCreateFromConstructor(NewTarget, "%DisposableStack.prototype%", « [[DisposableState]], [[DisposeCapability]] »). | ||
3. Set disposableStack.[[DisposableState]] to pending. | ||
4. Set disposableStack.[[DisposeCapability]] to NewDisposeCapability(). | ||
5. Return disposableStack. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
ObjectCreate ( proto [ , internalSlotsList ] ) | ||
4. Set obj.[[Prototype]] to proto. | ||
5. Set obj.[[Extensible]] to true. | ||
6. Return obj. | ||
features: [explicit-resource-management, Reflect] | ||
---*/ | ||
|
||
var stack = new DisposableStack(); | ||
assert.sameValue(Object.isExtensible(stack), true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-disposablestack | ||
description: Default [[Prototype]] value derived from realm of the newTarget | ||
info: | | ||
DisposableStack( ) | ||
... | ||
2. Let disposableStack be ? OrdinaryCreateFromConstructor(NewTarget, "%DisposableStack.prototype%", « [[DisposableState]], [[DisposeCapability]] »). | ||
3. Set disposableStack.[[DisposableState]] to pending. | ||
4. Set disposableStack.[[DisposeCapability]] to NewDisposeCapability(). | ||
5. Return disposableStack. | ||
OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) | ||
... | ||
2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). | ||
3. Return ObjectCreate(proto, internalSlotsList). | ||
GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) | ||
3. Let proto be ? Get(constructor, 'prototype'). | ||
4. If Type(proto) is not Object, then | ||
a. Let realm be ? GetFunctionRealm(constructor). | ||
b. Set proto to realm's intrinsic object named intrinsicDefaultProto. | ||
5. Return proto. | ||
features: [explicit-resource-management, cross-realm, Reflect, Symbol] | ||
---*/ | ||
|
||
var other = $262.createRealm().global; | ||
var newTarget = new other.Function(); | ||
var stack; | ||
|
||
newTarget.prototype = undefined; | ||
stack = Reflect.construct(DisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is undefined'); | ||
|
||
newTarget.prototype = null; | ||
stack = Reflect.construct(DisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is null'); | ||
|
||
newTarget.prototype = true; | ||
stack = Reflect.construct(DisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a Boolean'); | ||
|
||
newTarget.prototype = ''; | ||
stack = Reflect.construct(DisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a String'); | ||
|
||
newTarget.prototype = Symbol(); | ||
stack = Reflect.construct(DisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a Symbol'); | ||
|
||
newTarget.prototype = 1; | ||
stack = Reflect.construct(DisposableStack, [], newTarget); | ||
assert.sameValue(Object.getPrototypeOf(stack), other.DisposableStack.prototype, 'newTarget.prototype is a Number'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-properties-of-disposablestack-constructor | ||
description: > | ||
The prototype of DisposableStack is Function.prototype | ||
info: | | ||
The value of the [[Prototype]] internal slot of the DisposableStack object is the | ||
intrinsic object %FunctionPrototype%. | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
assert.sameValue( | ||
Object.getPrototypeOf(DisposableStack), | ||
Function.prototype, | ||
'Object.getPrototypeOf(DisposableStack) returns the value of `Function.prototype`' | ||
); |
19 changes: 19 additions & 0 deletions
19
test/built-ins/DisposableStack/prototype/Symbol.dispose.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-disposablestack.prototype-@@dispose | ||
description: Initial state of the Symbol.dispose property | ||
info: | | ||
The initial value of the @@dispose property is the same function object as | ||
the initial value of the dispose property. | ||
Per ES6 section 17, the method should exist on the Array prototype, and it | ||
should be writable and configurable, but not enumerable. | ||
includes: [propertyHelper.js] | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
assert.sameValue(DisposableStack.prototype[Symbol.dispose], DisposableStack.prototype.dispose); | ||
verifyNotEnumerable(DisposableStack.prototype, Symbol.dispose); | ||
verifyWritable(DisposableStack.prototype, Symbol.dispose); | ||
verifyConfigurable(DisposableStack.prototype, Symbol.dispose); |
30 changes: 30 additions & 0 deletions
30
test/built-ins/DisposableStack/prototype/disposed/getter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-get-disposablestack.prototype.disposed | ||
description: > | ||
Property type and descriptor. | ||
info: | | ||
get DisposableStack.prototype.disposed | ||
17 ECMAScript Standard Built-in Objects | ||
includes: [propertyHelper.js] | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
var descriptor = Object.getOwnPropertyDescriptor(DisposableStack.prototype, 'disposed'); | ||
|
||
assert.sameValue( | ||
typeof descriptor.get, | ||
'function', | ||
'typeof descriptor.get is function' | ||
); | ||
assert.sameValue( | ||
typeof descriptor.set, | ||
'undefined', | ||
'typeof descriptor.set is undefined' | ||
); | ||
|
||
verifyNotEnumerable(DisposableStack.prototype, 'disposed'); | ||
verifyConfigurable(DisposableStack.prototype, 'disposed'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
description: The prototype of DisposableStack.prototype is Object.prototype | ||
esid: sec-properties-of-the-disposablestack-prototype-object | ||
info: | | ||
The value of the [[Prototype]] internal slot of the DisposableStack prototype object | ||
is the intrinsic object %Object.prototype%. | ||
features: [explicit-resource-management] | ||
---*/ | ||
|
||
var proto = Object.getPrototypeOf(DisposableStack.prototype); | ||
assert.sameValue(proto, Object.prototype); |
13 changes: 13 additions & 0 deletions
13
test/built-ins/Iterator/prototype/Symbol.dispose/is-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (C) 2023 Ron Buckton. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-%iteratorprototype%-@@dispose | ||
description: > | ||
Iterator.prototype[@@dispose] is a built-in function | ||
features: [explicit-resource-management] | ||
---*/ | ||
const IteratorPrototype = Object.getPrototypeOf( | ||
Object.getPrototypeOf([][Symbol.iterator]()) | ||
); | ||
|
||
assert.sameValue(typeof IteratorPrototype[Symbol.dispose], 'function'); |
Oops, something went wrong.