Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial work #2

Open
wants to merge 17 commits into
base: AsyncGeneratorExpressions
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*~
*.pyc
console/TestCases
.idea
28 changes: 28 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator-construct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: pending
description: >
%AsyncGeneratorProrotype% creates functions with or without new and handles arguments
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly about arguments parsing in CreateDynamicFunction

similarly to functions.
---*/

var AsyncGeneratorProrotype = async function* foo() { }.constructor;
var fn;

fn = AsyncGeneratorProrotype("a", "await 1;");
assert.sameValue(fn.length, 1, "length with 1 argument, call");

fn = AsyncGeneratorProrotype("a,b", "await 1;");
assert.sameValue(fn.length, 2, "length with 2 arguments in one, call");

fn = AsyncGeneratorProrotype("a", "b", "await 1;");
assert.sameValue(fn.length, 2, "length with 2 arguments, call");

fn = new AsyncGeneratorProrotype("a", "await 1;");
assert.sameValue(fn.length, 1, "length with 1 argument, construct");

fn = new AsyncGeneratorProrotype("a,b", "await 1;");
assert.sameValue(fn.length, 2, "length with 2 arguments in one, construct");

fn = new AsyncGeneratorProrotype("a", "b", "await 1;");
assert.sameValue(fn.length, 2, "length with 2 arguments, construct");
10 changes: 10 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator-is-extensible.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: pending
description: >
%AsyncGeneratorFunction% is extensible
---*/

var AsyncGeneratorFunction = async function*() { }.constructor;
AsyncGeneratorFunction.x = 1;
assert.sameValue(AsyncGeneratorFunction.x, 1);
14 changes: 14 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator-is-subclass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: pending
description: >
%AsyncGeneratorFunction% is a subclass of Function
(The AsyncGeneratorFunction constructor is a standard built-in
function object that inherits from the Function constructor. )
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parenthesized bit might not add much, dunno

---*/
async function* foo() { };
var AsyncGeneratorFunction = foo.constructor;
assert.sameValue(Object.getPrototypeOf(AsyncGeneratorFunction), Function, "Prototype of constructor is Function");
assert.sameValue(Object.getPrototypeOf(AsyncGeneratorFunction.prototype), Function.prototype, "Prototype of constructor's prototype is Function.prototype");
assert(foo instanceof Function, 'async generator instance is instanceof Function');

13 changes: 13 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator-length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: pending
description: >
%AsyncGeneratorFunction% has a length of 1 with writable false, enumerable false, configurable true.
includes: [propertyHelper.js]
---*/

var AsyncGeneratorFunction = async function* foo() { }.constructor;
assert.sameValue(AsyncGeneratorFunction.length, 1);
verifyNotWritable(AsyncGeneratorFunction, 'length');
verifyNotEnumerable(AsyncGeneratorFunction, 'length');
verifyConfigurable(AsyncGeneratorFunction, 'length');
15 changes: 15 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: pending
description: >
The value of the name property of
the AsyncGeneratorFunction is "AsyncGeneratorFunction".
includes: [propertyHelper.js]
---*/

var AsyncGeneratorFunction = async function* foo() { }.constructor;
assert.sameValue(AsyncGeneratorFunction.name, "AsyncGeneratorFunction");
verifyNotWritable(AsyncGeneratorFunctionAsyncFunction, "name");
verifyNotEnumerable(AsyncGeneratorFunction, "name");
verifyConfigurable(AsyncGeneratorFunction, "name");

10 changes: 10 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator-next-callable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*---
author: Sasha Kruglyak <[email protected]>
esid: pending
description: >
%AsyncGeneratorPrototype%.next.[[Call]] exists (is callable)
---*/

async function* foo() { };
assert.sameValue(foo.hasOwnProperty("next"), true);
foo().next();
11 changes: 11 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator-prototype.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: pending
description: AsyncGeneratorFunction has a prototype property with writable false, enumerable false, configurable false.
includes: [propertyHelper.js]
---*/

var AsyncGeneratorFunction = async function* foo() { }.constructor;
verifyNotConfigurable(AsyncGeneratorFunction, 'prototype');
verifyNotWritable(AsyncGeneratorFunction, 'prototype');
verifyNotEnumerable(AsyncGeneratorFunctionAsyncFunction, 'prototype');
8 changes: 8 additions & 0 deletions test/built-ins/AsyncGenerator/AsyncGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
description: >
%AsyncGeneratorPrototype% exists and is a function
---*/

var AsyncGeneratorFunction = async function* foo() { }.constructor;
assert.sameValue(typeof AsyncGeneratorFunction, "function");
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*---
author: Sakthipriyan Vairamani (thefourtheye) <[email protected]>
description: Check if %AsyncGeneratorFunction% function's `prototype`
object's `constructor` property is %AsyncGeneratorFunction%
Copy link
Owner

@caitp caitp Jan 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove "Check if"

itself
---*/

const AsyncGeneratorFunction = async function* () {}.constructor;
const AGFPrototype = AsyncGeneratorFunction.prototype;
assert.sameValue(AGFPrototype.constructor, AsyncGeneratorFunction);

verifyNotEnumerable(AGFPrototype, 'constructor');
verifyNotWritable(AGFPrototype, 'constructor');
verifyConfigurable(AGFPrototype, 'constructor');
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: pending
description: >
%AsyncGeneratorPrototype% has a [[Extensible]] of true
---*/

var AsyncGeneratorFunction = async function* foo() { }.constructor;
AsyncGeneratorFunction.prototype.x = 1;
assert.sameValue(AsyncGeneratorFunction.prototype.x, 1);

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*---
author: Sakthipriyan Vairamani (thefourtheye) <[email protected]>
description: Make sure %AsyncGeneratorFunction% is exposed via the
`.constructor` property.
---*/

const AsyncGeneratorFunction = async function* () {}.constructor;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many test262 tests avoid using lexical variables unless specifically testing things related to lexical variables

assert.sameValue(typeof AsyncGeneratorFunction, 'function');
8 changes: 8 additions & 0 deletions test/built-ins/AsyncGenerator/is-not-a-global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*---
author: Sakthipriyan Vairamani (thefourtheye) <[email protected]>
description: Make sure %AsyncGeneratorFunction% is not a global function
---*/

assert.throws(ReferenceError, function() {
AsyncGeneratorFunction
}, 'AsyncGeneratorFunction should not be available in global scope');
15 changes: 15 additions & 0 deletions test/built-ins/AsyncGenerator/prototype-property-toStringTag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*---
author: Sakthipriyan Vairamani (thefourtheye) <[email protected]>
description: Check if %AsyncGeneratorFunction% function's `prototype`
object's `Symbol.toStringTag` property is
'AsyncGeneratorFunction'
---*/

const AsyncGeneratorFunction = async function* () {}.constructor;
const AGFPrototype = AsyncGeneratorFunction.prototype;

assert.sameValue(AGFPrototype[Symbol.toStringTag], 'AsyncGeneratorFunction');

verifyNotEnumerable(AGFPrototype, Symbol.toStringTag);
verifyNotWritable(AGFPrototype, Symbol.toStringTag);
verifyConfigurable(AGFPrototype, Symbol.toStringTag);
15 changes: 15 additions & 0 deletions test/built-ins/Symbol/asyncIterator/cross-realm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: early
description: Value shared by all realms
info: >
Unless otherwise specified, well-known symbols values are shared by all
realms.
features: [Symbol.asyncIterator]
---*/

var otherRealmSymbol = $.createRealm().global.Symbol;

assert.sameValue(Symbol.asyncIterator, otherRealmSymbol.asyncIterator);
11 changes: 11 additions & 0 deletions test/built-ins/Symbol/asyncIterator/name-prop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*---
author: Benjamin Gruenbaum <[email protected]>
esid: early
description: Name prop of Symbol.asyncIterator
info: >
The value of the name property of this function is "[Symbol.asyncIterator]".
features: [Symbol.asyncIterator]
---*/


assert.sameValue(Symbol.asyncIterator.name, '[Symbol.asyncIterator]');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"[Symbol.asyncIterator]" is not a name of the symbol, but the method of %AsyncIteratorPrototype%
https://tc39.github.io/proposal-async-iteration/#sec-asynciteratorprototype-asynciterator

17 changes: 17 additions & 0 deletions test/built-ins/Symbol/asyncIterator/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2015-2017 the V8 project authors. All rights reserved.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably rename this file to just "asyncIterator.js" unless this matches the conventions of the other well known symbol tests

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the conventions of the async function tests. I don't feel strongly about the name though.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: early
description: >
`Symbol.asyncIterator` property descriptor
info: >
This property has the attributes { [[Writable]]: false, [[Enumerable]]:
false, [[Configurable]]: false }.
includes: [propertyHelper.js]
features: [Symbol.asyncIterator]
---*/

assert.sameValue(typeof Symbol.asyncIterator, 'symbol');
verifyNotEnumerable(Symbol, 'asyncIterator');
verifyNotWritable(Symbol, 'asyncIterator');
verifyNotConfigurable(Symbol, 'asyncIterator');
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
IsSimpleParameterList of UniqueFormalParameters is false.
negative:
phase: early
type: SyntaxError
---*/

(async function*(x = 1) {"use strict"});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
It is a SyntaxError if FormalParameters contains arguments in strict mode.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/

(async function*(arguments) { });
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: 12.1.1
description: >
`await` is not a valid BindingIdentifier for AsyncGeneratorExpressions.
negative:
phase: early
type: SyntaxError
---*/

(async function* await() { });
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
If the source code matching this production is strict code, it is a
Syntax Error if BindingIdentifier is the IdentifierName arguments.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/

(async function* arguments() { });
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
If the source code matching this production is strict code, it is a
Syntax Error if BindingIdentifier is the IdentifierName eval.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/

(async function* eval() { });
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
It is a syntax error if AsyncGeneratorBody contains SuperCall is true.
negative:
phase: early
type: SyntaxError
---*/

(async function*() { super(); });
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
It is a syntax error if AsyncGeneratorBody contains SuperProperty is true.
negative:
phase: early
type: SyntaxError
---*/

(async function*() { super.prop; });
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
It is a SyntaxError if FormalParameters contains eval in strict mode.
negative:
phase: early
type: SyntaxError
flags: [onlyStrict]
---*/

(async function*(eval) { });
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
It is a SyntaxError if BoundNames of FormalParameters also occurs in the
LexicallyDeclaredNames of AsyncFunctionBody
negative:
phase: early
type: SyntaxError
---*/

(async function*(a) { const a = 0; });
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
author: Caitlin Potter <[email protected]>
esid: pending
description: >
It is a SyntaxError if BoundNames of FormalParameters also occurs in the
LexicallyDeclaredNames of AsyncFunctionBody
negative:
phase: early
type: SyntaxError
---*/

(async function*(a) { let a; });
Loading