add tests for `for ( async of`

This commit is contained in:
Kevin Gibbons 2021-01-16 14:58:54 -08:00 committed by Rick Waldron
parent df1961f16a
commit 96f1e2713b
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// Copyright (C) 2021 Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: leading `async` token in for-of LHS
info: |
The `async` token is allowed in the LHS if not followed by `of`
esid: sec-for-in-and-for-of-statements
---*/
var async = { x: 0 };
for (async.x of [1]) ;
assert.sameValue(async.x, 1);

View File

@ -0,0 +1,17 @@
// Copyright (C) 2021 Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: leading `async` token in for-of LHS
info: |
The `async` token is disallowed in the LHS when followed by `of`
esid: sec-for-in-and-for-of-statements
negative:
phase: parse
type: SyntaxError
---*/
$DONOTEVALUATE();
var async;
for (async of [1]) ;

View File

@ -0,0 +1,16 @@
// Copyright (C) 2021 Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: for statement beginning with `async of`
info: |
`for (async of =>` is the begining of a regular for loop, rather than a for-of
esid: sec-for-statement
---*/
var i = 0;
var counter = 0;
for (async of => {}; i < 10; ++i) {
++counter;
}
assert.sameValue(counter, 10);