From 510d6b7f44e96e452bc26ce603542d9b2b5592dc Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Mon, 12 Feb 2018 14:12:16 -0500 Subject: [PATCH 1/3] async-iteration: add tests for AsyncGenerationFunction --- .../AsyncGeneratorFunction/extensibility.js | 14 ++++++ .../AsyncGeneratorFunction/has-instance.js | 34 ++++++++++++++ .../instance-await-expr-in-param.js | 42 +++++++++++++++++ .../instance-construct-throws.js | 31 +++++++++++++ .../AsyncGeneratorFunction/instance-length.js | 45 +++++++++++++++++++ .../AsyncGeneratorFunction/instance-name.js | 28 ++++++++++++ .../instance-prototype.js | 37 +++++++++++++++ .../instance-yield-expr-in-param.js | 42 +++++++++++++++++ .../invoked-as-constructor-no-arguments.js | 20 +++++++++ .../invoked-as-function-multiple-arguments.js | 26 +++++++++++ .../invoked-as-function-no-arguments.js | 19 ++++++++ .../invoked-as-function-single-argument.js | 28 ++++++++++++ .../AsyncGeneratorFunction/length.js | 19 ++++++++ test/built-ins/AsyncGeneratorFunction/name.js | 29 ++++++++++++ .../prototype/Symbol.toStringTag.js | 25 +++++++++++ .../prototype/constructor.js | 25 +++++++++++ .../prototype/extensibility.js | 14 ++++++ .../prototype/prop-desc.js | 19 ++++++++ .../prototype/prototype.js | 26 +++++++++++ 19 files changed, 523 insertions(+) create mode 100644 test/built-ins/AsyncGeneratorFunction/extensibility.js create mode 100644 test/built-ins/AsyncGeneratorFunction/has-instance.js create mode 100644 test/built-ins/AsyncGeneratorFunction/instance-await-expr-in-param.js create mode 100644 test/built-ins/AsyncGeneratorFunction/instance-construct-throws.js create mode 100644 test/built-ins/AsyncGeneratorFunction/instance-length.js create mode 100644 test/built-ins/AsyncGeneratorFunction/instance-name.js create mode 100644 test/built-ins/AsyncGeneratorFunction/instance-prototype.js create mode 100644 test/built-ins/AsyncGeneratorFunction/instance-yield-expr-in-param.js create mode 100644 test/built-ins/AsyncGeneratorFunction/invoked-as-constructor-no-arguments.js create mode 100644 test/built-ins/AsyncGeneratorFunction/invoked-as-function-multiple-arguments.js create mode 100644 test/built-ins/AsyncGeneratorFunction/invoked-as-function-no-arguments.js create mode 100644 test/built-ins/AsyncGeneratorFunction/invoked-as-function-single-argument.js create mode 100644 test/built-ins/AsyncGeneratorFunction/length.js create mode 100644 test/built-ins/AsyncGeneratorFunction/name.js create mode 100644 test/built-ins/AsyncGeneratorFunction/prototype/Symbol.toStringTag.js create mode 100644 test/built-ins/AsyncGeneratorFunction/prototype/constructor.js create mode 100644 test/built-ins/AsyncGeneratorFunction/prototype/extensibility.js create mode 100644 test/built-ins/AsyncGeneratorFunction/prototype/prop-desc.js create mode 100644 test/built-ins/AsyncGeneratorFunction/prototype/prototype.js diff --git a/test/built-ins/AsyncGeneratorFunction/extensibility.js b/test/built-ins/AsyncGeneratorFunction/extensibility.js new file mode 100644 index 0000000000..e0d2517d02 --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/extensibility.js @@ -0,0 +1,14 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-asyncgeneratorfunction +description: Object extensibility +info: | + The value of the [[Extensible]] internal slot of the AsyncGeneratorFunction + constructor is true. +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +assert(Object.isExtensible(AsyncGeneratorFunction)); diff --git a/test/built-ins/AsyncGeneratorFunction/has-instance.js b/test/built-ins/AsyncGeneratorFunction/has-instance.js new file mode 100644 index 0000000000..ab9388b41f --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/has-instance.js @@ -0,0 +1,34 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-asyncgeneratorfunction +description: > + AsyncGenerator function instances are correctly reported as instances of the + AsyncGeneratorFunction intrinsic. +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +async function* agDecl() {} +var agExpr = async function* () {}; + +assert( + agDecl instanceof AsyncGeneratorFunction, + 'AsyncGenerators created via AsyncGeneratorDeclaration syntax are proper instances of AsyncGeneratorFunction' +); + +assert( + agExpr instanceof AsyncGeneratorFunction, + 'AsyncGenerators created via AsyncGeneratorExpression syntax are proper instances of AsyncGeneratorFunction' +); + +assert( + new AsyncGeneratorFunction() instanceof AsyncGeneratorFunction, + 'AsyncGenerators created via constructor invocation of AsyncGeneratorFunction are proper instances of AsyncGeneratorFunction' +); + +assert( + AsyncGeneratorFunction() instanceof AsyncGeneratorFunction, + 'AsyncGenerators created via function invocation of AsyncGeneratorFunction are proper instances of AsyncGeneratorFunction' +); diff --git a/test/built-ins/AsyncGeneratorFunction/instance-await-expr-in-param.js b/test/built-ins/AsyncGeneratorFunction/instance-await-expr-in-param.js new file mode 100644 index 0000000000..460f554a6e --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/instance-await-expr-in-param.js @@ -0,0 +1,42 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: Definition of instance `length` property +info: | + AsyncGeneratorFunction ( p1, p2, … , pn, body ) + ... + 3. Return CreateDynamicFunction(C, NewTarget, "async generator", args). + + Runtime Semantics: CreateDynamicFunction + ... + 29. If kind is "async" or "async generator", then + a. If parameters Contains AwaitExpression is true, throw a SyntaxError + exception. +features: [async-iteration] +flags: [async] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +// AwaitExpression is permitted in function body. +AsyncGeneratorFunction('x = await 42'); + +assert.throws(SyntaxError, function() { + AsyncGeneratorFunction('x = await 42', ''); +}, 'AwaitExpression not permitted in parameters'); + +var withinAsyncGenerator = async function*() { + AsyncGeneratorFunction('x = await 42', ''); +}; + +withinAsyncGenerator().next().then( + function () { + throw new Test262Error("AwaitExpression not permitted when calling context is a async generator"); + }, + function (e) { + if (!(e instanceof SyntaxError)) { + throw new Test262Error("Expected SyntaxError but got " + e); + } + } +).then($DONE, $DONE); diff --git a/test/built-ins/AsyncGeneratorFunction/instance-construct-throws.js b/test/built-ins/AsyncGeneratorFunction/instance-construct-throws.js new file mode 100644 index 0000000000..eba1a5f310 --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/instance-construct-throws.js @@ -0,0 +1,31 @@ +// Copyright 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgeneratorfunction +description: The instance created by AsyncGeneratorFunction is not a constructor +info: | + AsyncGeneratorFunction ( p1, p2, … , pn, body ) + ... + 3. Return ? CreateDynamicFunction(C, NewTarget, "async generator", args). + + Runtime Semantics: CreateDynamicFunction( constructor, newTarget, kind, args ) + ... + 32. Let F be FunctionAllocate(proto, strict, kind). + ... + + FunctionAllocate ( functionPrototype, strict, functionKind ) + // [[Construct]] and [[ConstructKind]] are not set for functionKind="async generators" + +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var instance = AsyncGeneratorFunction(); + +assert.throws(TypeError, function() { + new instance(); +}) + + diff --git a/test/built-ins/AsyncGeneratorFunction/instance-length.js b/test/built-ins/AsyncGeneratorFunction/instance-length.js new file mode 100644 index 0000000000..a7ea763f80 --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/instance-length.js @@ -0,0 +1,45 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: Definition of instance `length` property +info: | + AsyncGeneratorFunction ( p1, p2, … , pn, body ) + ... + 3. Return CreateDynamicFunction(C, NewTarget, "async generator", args). + + Runtime Semantics: CreateDynamicFunction + ... + // the parameter "args" is sliced into "parameters" and "body" + 26. Perform FunctionInitialize(F, Normal, parameters, body, scope). + ... + + FunctionInitialize + ... + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", + PropertyDescriptor{[[Value]]: len, [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true}). + ... +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var instance = AsyncGeneratorFunction() + +verifyProperty(AsyncGeneratorFunction(), "length", { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); + +assert.sameValue(AsyncGeneratorFunction('').length, 0, "test 1"); +assert.sameValue(AsyncGeneratorFunction('x').length, 0, "test 2"); +assert.sameValue(AsyncGeneratorFunction('x', '').length, 1, "test 3"); +assert.sameValue(AsyncGeneratorFunction('x', 'y', '').length, 2, "test 4"); +assert.sameValue(AsyncGeneratorFunction('x, y', '').length, 2, "test 5"); + + diff --git a/test/built-ins/AsyncGeneratorFunction/instance-name.js b/test/built-ins/AsyncGeneratorFunction/instance-name.js new file mode 100644 index 0000000000..62e47d643d --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/instance-name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgeneratorfunction +description: Assignment of function `name` attribute +info: | + AsyncGeneratorFunction ( p1, p2, … , pn, body ) + ... + 3. Return CreateDynamicFunction(C, NewTarget, "async generator", args). + + RuntimeSemantics: CreateDynamicFunction(constructor, newTarget, kind, args) + ... + 29. Perform SetFunctionName(F, "anonymous"). +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var instance = AsyncGeneratorFunction() + +verifyProperty(instance, "name", { + value: "anonymous", + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/AsyncGeneratorFunction/instance-prototype.js b/test/built-ins/AsyncGeneratorFunction/instance-prototype.js new file mode 100644 index 0000000000..57c2efd26b --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/instance-prototype.js @@ -0,0 +1,37 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: Definition of instance `prototype` property +info: | + AsyncGeneratorFunction ( p1, p2, … , pn, body ) + ... + 3. Return CreateDynamicFunction(C, NewTarget, "async generator", args). + + Runtime Semantics: CreateDynamicFunction + ... + 37. Else if kind is "async generator", then + a. Let prototype be ObjectCreate(%AsyncGeneratorPrototype%). + b. Perform DefinePropertyOrThrow(F, "prototype", + PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: false}). + ... +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var instance = AsyncGeneratorFunction(); + +assert.sameValue(typeof instance.prototype, 'object'); +assert.sameValue( + Object.getPrototypeOf(instance.prototype), + Object.getPrototypeOf(instance).prototype +); + +verifyProperty(instance, "prototype", { + enumerable: false, + writable: true, + configurable: false, +}); diff --git a/test/built-ins/AsyncGeneratorFunction/instance-yield-expr-in-param.js b/test/built-ins/AsyncGeneratorFunction/instance-yield-expr-in-param.js new file mode 100644 index 0000000000..5bddd0a89f --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/instance-yield-expr-in-param.js @@ -0,0 +1,42 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: Definition of instance `length` property +info: | + AsyncGeneratorFunction ( p1, p2, … , pn, body ) + ... + 3. Return CreateDynamicFunction(C, NewTarget, "async generator", args). + + Runtime Semantics: CreateDynamicFunction + ... + 28. If kind is "generator" or "async generator", then + a. If parameters Contains YieldExpression is true, throw a SyntaxError + exception. +features: [async-iteration] +flags: [async] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +// YieldExpression is permitted in function body. +AsyncGeneratorFunction('x = yield'); + +assert.throws(SyntaxError, function() { + AsyncGeneratorFunction('x = yield', ''); +}, 'YieldExpression not permitted generally'); + +var withinAsyncGenerator = async function*() { + AsyncGeneratorFunction('x = yield', ''); +}; + +withinAsyncGenerator().next().then( + function () { + throw new Test262Error("YieldExpression not permitted when calling context is a async generator"); + }, + function (e) { + if (!(e instanceof SyntaxError)) { + throw new Test262Error("Expected SyntaxError but got " + e); + } + } +).then($DONE, $DONE); diff --git a/test/built-ins/AsyncGeneratorFunction/invoked-as-constructor-no-arguments.js b/test/built-ins/AsyncGeneratorFunction/invoked-as-constructor-no-arguments.js new file mode 100644 index 0000000000..6400a8e530 --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/invoked-as-constructor-no-arguments.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: > + When invoked via the constructor invocation pattern without arguments, the + GeneratorFunction intrinsic returns a valid async generator with an empty body. +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var g = new AsyncGeneratorFunction(); +var iter = g(); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Result `value`'); + assert.sameValue(result.done, true, 'Result `done` flag'); +}).then($DONE, $DONE) + diff --git a/test/built-ins/AsyncGeneratorFunction/invoked-as-function-multiple-arguments.js b/test/built-ins/AsyncGeneratorFunction/invoked-as-function-multiple-arguments.js new file mode 100644 index 0000000000..7e7ee7a918 --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/invoked-as-function-multiple-arguments.js @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: > + When invoked via the function invocation pattern with multiple arguments, + the AsyncGeneratorFunction intrinsic creates a valid generator whose body is the + last argument evaluated as source code and whose formal parameters are + defined by the preceeding arguments. +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var g = AsyncGeneratorFunction('x', 'y', 'yield x + y;'); +var iter = g(2, 3); + +iter.next().then(function(result) { + assert.sameValue(result.value, 5, 'First result `value`'); + assert.sameValue(result.done, false, 'First result `done` flag'); +}).then(undefined, $DONE) + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Final result `value`'); + assert.sameValue(result.done, true, 'Final result `done` flag'); +}).then($DONE, $DONE) diff --git a/test/built-ins/AsyncGeneratorFunction/invoked-as-function-no-arguments.js b/test/built-ins/AsyncGeneratorFunction/invoked-as-function-no-arguments.js new file mode 100644 index 0000000000..e3b7c24f1b --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/invoked-as-function-no-arguments.js @@ -0,0 +1,19 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: > + When invoked via the function invocation pattern without arguments, the + AsyncGeneratorFunction intrinsic returns a valid generator with an empty body. +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var g = AsyncGeneratorFunction(); +var iter = g(); + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Result `value`'); + assert.sameValue(result.done, true, 'Result `done` flag'); +}).then($DONE, $DONE) diff --git a/test/built-ins/AsyncGeneratorFunction/invoked-as-function-single-argument.js b/test/built-ins/AsyncGeneratorFunction/invoked-as-function-single-argument.js new file mode 100644 index 0000000000..d7329136fa --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/invoked-as-function-single-argument.js @@ -0,0 +1,28 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction +description: > + When invoked via the function invocation pattern with a single argument, + the AsyncGeneratorFunction intrinsic creates a valid async generator whose body is the + first argument evaluated as source code. +features: [async-iteration] +flags: [async] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +var g = AsyncGeneratorFunction('yield 1;'); +var iter = g(); +var result; + + +iter.next().then(function(result) { + assert.sameValue(result.value, 1, 'First result `value`'); + assert.sameValue(result.done, false, 'First result `done` flag'); +}).then(undefined, $DONE) + +iter.next().then(function(result) { + assert.sameValue(result.value, undefined, 'Final result `value`'); + assert.sameValue(result.done, true, 'Final result `done` flag'); +}).then($DONE, $DONE) diff --git a/test/built-ins/AsyncGeneratorFunction/length.js b/test/built-ins/AsyncGeneratorFunction/length.js new file mode 100644 index 0000000000..5b7fbf590f --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/length.js @@ -0,0 +1,19 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction-length +description: > + This is a data property with a value of 1. This property has the attributes + { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +verifyProperty(AsyncGeneratorFunction, "length", { + value: 1, + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/AsyncGeneratorFunction/name.js b/test/built-ins/AsyncGeneratorFunction/name.js new file mode 100644 index 0000000000..17132afc5c --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/name.js @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-asyncgeneratorfunction +description: Function "name" property +info: | + The value of the name property of the AsyncGeneratorFunction + is "AsyncGeneratorFunction". + + 17 ECMAScript Standard Built-in Objects: + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value is a + String. + + Unless otherwise specified, the name property of a built-in Function object, + if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +verifyProperty(AsyncGeneratorFunction, "name", { + value: "AsyncGeneratorFunction", + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/AsyncGeneratorFunction/prototype/Symbol.toStringTag.js b/test/built-ins/AsyncGeneratorFunction/prototype/Symbol.toStringTag.js new file mode 100644 index 0000000000..78b38767ab --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/prototype/Symbol.toStringTag.js @@ -0,0 +1,25 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-asyncgeneratorfunction-prototype-tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String + value "AsyncGeneratorFunction". + + This property has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [async-iteration, Symbol.toStringTag] +---*/ + +var AsyncGeneratorFunctionPrototype = Object.getPrototypeOf(async function*() {}); + +verifyProperty(AsyncGeneratorFunctionPrototype, Symbol.toStringTag, { + value: 'AsyncGeneratorFunction', + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/AsyncGeneratorFunction/prototype/constructor.js b/test/built-ins/AsyncGeneratorFunction/prototype/constructor.js new file mode 100644 index 0000000000..c36680252b --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/prototype/constructor.js @@ -0,0 +1,25 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction-prototype-constructor +description: > + `constructor` property of the AsyncGeneratorFunction.prototype object +info: | + The initial value of AsyncGeneratorFunction.prototype.constructor is the intrinsic + object %AsyncGeneratorFunction%. + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +assert.sameValue(AsyncGeneratorFunction.prototype.constructor, AsyncGeneratorFunction); + +verifyProperty(AsyncGeneratorFunction.prototype, "constructor", { + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/AsyncGeneratorFunction/prototype/extensibility.js b/test/built-ins/AsyncGeneratorFunction/prototype/extensibility.js new file mode 100644 index 0000000000..b4360e4f13 --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/prototype/extensibility.js @@ -0,0 +1,14 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-properties-of-asyncgenerator-prototype +description: Object extensibility +info: | + The initial value of the [[Extensible]] internal slot of the + AsyncGeneratorFunction prototype object is true. +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +assert(Object.isExtensible(AsyncGeneratorFunction.prototype)); diff --git a/test/built-ins/AsyncGeneratorFunction/prototype/prop-desc.js b/test/built-ins/AsyncGeneratorFunction/prototype/prop-desc.js new file mode 100644 index 0000000000..a1b49c240b --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/prototype/prop-desc.js @@ -0,0 +1,19 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: AsyncGeneratorFunction.prototype property descriptor +esid: sec-asyncgeneratorfunction-prototype +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; + +verifyProperty(AsyncGeneratorFunction, "prototype", { + enumerable: false, + writable: false, + configurable: false, +}); diff --git a/test/built-ins/AsyncGeneratorFunction/prototype/prototype.js b/test/built-ins/AsyncGeneratorFunction/prototype/prototype.js new file mode 100644 index 0000000000..66c5cd1708 --- /dev/null +++ b/test/built-ins/AsyncGeneratorFunction/prototype/prototype.js @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asyncgeneratorfunction-prototype-prototype +description: > + The value of AsyncGeneratorFunction.prototype.prototype is the + %AsyncGeneratorPrototype% intrinsic object. + + This property has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [async-iteration] +---*/ + +var AsyncGeneratorFunctionPrototype = Object.getPrototypeOf(async function*() {}); + +assert.sameValue( + AsyncGeneratorFunctionPrototype.prototype, + Object.getPrototypeOf(async function*() {}.prototype) +); + +verifyProperty(AsyncGeneratorFunctionPrototype, "prototype", { + enumerable: false, + writable: false, + configurable: true, +}); From 14d7bfeda2b5e0188b89f7326dba0d18d92e6d31 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Wed, 14 Feb 2018 10:56:16 -0500 Subject: [PATCH 2/3] async-iteration: add tests for AsyncIteratorPrototype --- .../Symbol.asyncIterator/length.js | 29 ++++++++++++++++ .../Symbol.asyncIterator/name.js | 33 +++++++++++++++++++ .../Symbol.asyncIterator/prop-desc.js | 26 +++++++++++++++ .../Symbol.asyncIterator/return-val.js | 20 +++++++++++ 4 files changed, 108 insertions(+) create mode 100644 test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/length.js create mode 100644 test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/name.js create mode 100644 test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js create mode 100644 test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js diff --git a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/length.js b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/length.js new file mode 100644 index 0000000000..ea8e7300a3 --- /dev/null +++ b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/length.js @@ -0,0 +1,29 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asynciteratorprototype-asynciterator +description: Length of AsyncIteratorPrototype[ @@asyncIterator ] +info: | + ECMAScript Standard Built-in Objects + ... + Every built-in Function object, including constructors, has a length + property whose value is an integer. Unless otherwise specified, this value + is equal to the largest number of named arguments shown in the subclause + headings for the function description, including optional parameters. + ... + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +features: [Symbol.asyncIterator, async-iteration] +includes: [propertyHelper.js] +---*/ + +async function* generator() {} +var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype)) + +verifyProperty(AsyncIteratorPrototype[Symbol.asyncIterator], "length", { + value: 0, + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/name.js b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/name.js new file mode 100644 index 0000000000..2c2a859619 --- /dev/null +++ b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/name.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-asynciteratorprototype-asynciterator +description: Descriptor for `name` property +info: | + %AsyncIteratorPrototype% [ @@asyncIterator ] ( ) + ... + The value of the name property of this function is "[Symbol.asyncIterator]". + + ECMAScript Standard Built-in Objects + ... + Every built-in Function object, including constructors, that is not + identified as an anonymous function has a name property whose value is a + String. Unless otherwise specified, this value is the name that is given to + the function in this specification. + ... + Unless otherwise specified, the name property of a built-in Function + object, if it exists, has the attributes { [[Writable]]: false, + [[Enumerable]]: false, [[Configurable]]: true }. +features: [Symbol.asyncIterator, async-iteration] +includes: [propertyHelper.js] +---*/ + +async function* generator() {} +var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype)) + +verifyProperty(AsyncIteratorPrototype[Symbol.asyncIterator], "name", { + value: '[Symbol.asyncIterator]', + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js new file mode 100644 index 0000000000..8da5c4a68e --- /dev/null +++ b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js @@ -0,0 +1,26 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: sec-asynciteratorprototype +description: Property descriptor +info: | + ECMAScript Standard Built-in Objects + + Every other data property described in clauses 18 through 26 and in Annex + B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, + [[Configurable]]: true } unless otherwise specified. +features: [Symbol.asyncIterator, async-iteration] +includes: [propertyHelper.js] +---*/ + +async function* generator() {} +var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype)) + +assert.sameValue(typeof AsyncIteratorPrototype[Symbol.asyncIterator], 'function'); + +verifyProperty(AsyncIteratorPrototype, Symbol.asyncIterator, { + enumerable: false, + writable: true, + configurable: true, +}); + diff --git a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js new file mode 100644 index 0000000000..506ddedc5f --- /dev/null +++ b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: sec-asynciteratorprototype-asynciterator +description: Return value of @@asyncIterator +info: | + %AsyncIteratorPrototype% [ @@asyncIterator ] ( ) + 1. Return the this value. +features: [Symbol.asyncIterator, async-iteration] +---*/ + +async function* generator() {} +var AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(generator.prototype)) + +var thisValue = {}; + +assert.sameValue( + AsyncIteratorPrototype[Symbol.asyncIterator].call(thisValue), + thisValue +); From 832542844cf86471ceb6828e36cb33a3666cafdf Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Thu, 15 Feb 2018 10:46:28 -0500 Subject: [PATCH 3/3] s/es6id/esid --- .../AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js | 2 +- .../AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js index 8da5c4a68e..68aadc9b72 100644 --- a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js +++ b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/prop-desc.js @@ -1,7 +1,7 @@ // Copyright (C) 2018 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: sec-asynciteratorprototype +esid: sec-asynciteratorprototype description: Property descriptor info: | ECMAScript Standard Built-in Objects diff --git a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js index 506ddedc5f..cabd2aa689 100644 --- a/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js +++ b/test/built-ins/AsyncIteratorPrototype/Symbol.asyncIterator/return-val.js @@ -1,7 +1,7 @@ // Copyright (C) 2018 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: sec-asynciteratorprototype-asynciterator +esid: sec-asynciteratorprototype-asynciterator description: Return value of @@asyncIterator info: | %AsyncIteratorPrototype% [ @@asyncIterator ] ( )