From 96f1e2713bdcd96a3a3e1577f440c83ca86cd084 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sat, 16 Jan 2021 14:58:54 -0800 Subject: [PATCH] add tests for `for ( async of` --- .../statements/for-of/head-lhs-async-dot.js | 15 +++++++++++++++ .../statements/for-of/head-lhs-async-invalid.js | 17 +++++++++++++++++ .../statements/for/head-init-async-of.js | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 test/language/statements/for-of/head-lhs-async-dot.js create mode 100644 test/language/statements/for-of/head-lhs-async-invalid.js create mode 100644 test/language/statements/for/head-init-async-of.js diff --git a/test/language/statements/for-of/head-lhs-async-dot.js b/test/language/statements/for-of/head-lhs-async-dot.js new file mode 100644 index 0000000000..f5be9a28fa --- /dev/null +++ b/test/language/statements/for-of/head-lhs-async-dot.js @@ -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); diff --git a/test/language/statements/for-of/head-lhs-async-invalid.js b/test/language/statements/for-of/head-lhs-async-invalid.js new file mode 100644 index 0000000000..f899ad1326 --- /dev/null +++ b/test/language/statements/for-of/head-lhs-async-invalid.js @@ -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]) ; diff --git a/test/language/statements/for/head-init-async-of.js b/test/language/statements/for/head-init-async-of.js new file mode 100644 index 0000000000..f6f9e177ff --- /dev/null +++ b/test/language/statements/for/head-init-async-of.js @@ -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);