mirror of https://github.com/tc39/test262.git
Basic constructor and newtarget tests for AsyncDisposableStack
This commit is contained in:
parent
7c37969378
commit
5bdc35ab46
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (C) 2023 Ron Buckton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-asyncdisposablestack-constructor
|
||||||
|
description: >
|
||||||
|
The AsyncDisposableStack constructor is the %AsyncDisposableStack% intrinsic object and the initial
|
||||||
|
value of the AsyncDisposableStack property of the global object.
|
||||||
|
features: [explicit-resource-management]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
typeof AsyncDisposableStack, 'function',
|
||||||
|
'typeof AsyncDisposableStack is function'
|
||||||
|
);
|
|
@ -0,0 +1,42 @@
|
||||||
|
// 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: >
|
||||||
|
Return abrupt from getting the NewTarget prototype
|
||||||
|
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').
|
||||||
|
features: [explicit-resource-management, Reflect.construct]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var calls = 0;
|
||||||
|
var newTarget = function() {}.bind(null);
|
||||||
|
Object.defineProperty(newTarget, 'prototype', {
|
||||||
|
get: function() {
|
||||||
|
calls += 1;
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Reflect.construct(AsyncDisposableStack, [], newTarget);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.sameValue(calls, 1);
|
|
@ -0,0 +1,45 @@
|
||||||
|
// 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: >
|
||||||
|
The [[Prototype]] internal slot is computed from 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, Reflect.construct]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var stack;
|
||||||
|
|
||||||
|
stack = Reflect.construct(AsyncDisposableStack, [], Object);
|
||||||
|
assert.sameValue(Object.getPrototypeOf(stack), Object.prototype, 'NewTarget is built-in Object constructor');
|
||||||
|
|
||||||
|
var newTarget = function() {}.bind(null);
|
||||||
|
Object.defineProperty(newTarget, 'prototype', {
|
||||||
|
get: function() {
|
||||||
|
return Array.prototype;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
stack = Reflect.construct(AsyncDisposableStack, [], newTarget);
|
||||||
|
assert.sameValue(Object.getPrototypeOf(stack), Array.prototype, 'NewTarget is BoundFunction with accessor');
|
|
@ -0,0 +1,34 @@
|
||||||
|
// 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: >
|
||||||
|
The [[Prototype]] internal slot is computed from 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]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var stack = new AsyncDisposableStack();
|
||||||
|
assert.sameValue(Object.getPrototypeOf(stack), AsyncDisposableStack.prototype);
|
|
@ -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-asyncdisposablestack
|
||||||
|
description: >
|
||||||
|
Throws a TypeError if NewTarget is undefined.
|
||||||
|
info: |
|
||||||
|
AsyncDisposableStack ( )
|
||||||
|
|
||||||
|
1. If NewTarget is undefined, throw a TypeError exception.
|
||||||
|
...
|
||||||
|
features: [explicit-resource-management]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
AsyncDisposableStack();
|
||||||
|
});
|
Loading…
Reference in New Issue