From 8183e9a629111103ca183e708d78c75639e74983 Mon Sep 17 00:00:00 2001 From: jugglinmike Date: Fri, 14 May 2021 12:26:25 -0400 Subject: [PATCH] Add test for TLA DFS invariant (#2989) This behavior was introduced after the Top-Level Await proposal reached stage 3: https://github.com/tc39/proposal-top-level-await/pull/159 --- .../dfs-invariant-async_FIXTURE.js | 4 ++ .../dfs-invariant-direct-1_FIXTURE.js | 4 ++ .../dfs-invariant-direct-2_FIXTURE.js | 4 ++ .../dfs-invariant-indirect_FIXTURE.js | 4 ++ .../top-level-await/dfs-invariant.js | 40 +++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 test/language/module-code/top-level-await/dfs-invariant-async_FIXTURE.js create mode 100644 test/language/module-code/top-level-await/dfs-invariant-direct-1_FIXTURE.js create mode 100644 test/language/module-code/top-level-await/dfs-invariant-direct-2_FIXTURE.js create mode 100644 test/language/module-code/top-level-await/dfs-invariant-indirect_FIXTURE.js create mode 100644 test/language/module-code/top-level-await/dfs-invariant.js diff --git a/test/language/module-code/top-level-await/dfs-invariant-async_FIXTURE.js b/test/language/module-code/top-level-await/dfs-invariant-async_FIXTURE.js new file mode 100644 index 0000000000..7f9405dacf --- /dev/null +++ b/test/language/module-code/top-level-await/dfs-invariant-async_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +await 0; +globalThis.test262 = 'async'; diff --git a/test/language/module-code/top-level-await/dfs-invariant-direct-1_FIXTURE.js b/test/language/module-code/top-level-await/dfs-invariant-direct-1_FIXTURE.js new file mode 100644 index 0000000000..abbf070c66 --- /dev/null +++ b/test/language/module-code/top-level-await/dfs-invariant-direct-1_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +import './dfs-invariant-async_FIXTURE.js'; +globalThis.test262 += ':direct-1'; diff --git a/test/language/module-code/top-level-await/dfs-invariant-direct-2_FIXTURE.js b/test/language/module-code/top-level-await/dfs-invariant-direct-2_FIXTURE.js new file mode 100644 index 0000000000..a3189698e0 --- /dev/null +++ b/test/language/module-code/top-level-await/dfs-invariant-direct-2_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +import './dfs-invariant-async_FIXTURE.js'; +globalThis.test262 += ':direct-2'; diff --git a/test/language/module-code/top-level-await/dfs-invariant-indirect_FIXTURE.js b/test/language/module-code/top-level-await/dfs-invariant-indirect_FIXTURE.js new file mode 100644 index 0000000000..ee0c272b86 --- /dev/null +++ b/test/language/module-code/top-level-await/dfs-invariant-indirect_FIXTURE.js @@ -0,0 +1,4 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +import './dfs-invariant-direct-1_FIXTURE.js'; +globalThis.test262 += ':indirect'; diff --git a/test/language/module-code/top-level-await/dfs-invariant.js b/test/language/module-code/top-level-await/dfs-invariant.js new file mode 100644 index 0000000000..3c9512650e --- /dev/null +++ b/test/language/module-code/top-level-await/dfs-invariant.js @@ -0,0 +1,40 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Parent completion orderings match the synchronous module behavior +info: | + 6.2.4 AsyncModuleExecutionFulfilled ( module ) + + [...] + 5. Let _execList_ be a new empty List. + 6. Perform ! GatherAsyncParentCompletions(_module_, _execList_). + 7. Let _sortedExecList_ be a List of elements that are the elements of + _execList_, in the order in which they had their [[AsyncEvaluating]] + fields set to *true* in InnerModuleEvaluation. + 8. Assert: All elements of _sortedExecList_ have their [[AsyncEvaluating]] + field set to *true*, [[PendingAsyncDependencies]] field set to 0 and + [[EvaluationError]] field set to *undefined*. + [...] + + Dependency graph for this test: + + dfs-invariant.js + .-----------------------------------+-------. + | | v + | | dfs-invariant-indirect_FIXTURE.js + | .---|----------------------' + v v v + dfs-invariant-direct-1_FIXTURE.js dfs-invariant-direct-2_FIXTURE.js + '--------. .--------' + v v + dfs-invariant-async_FIXTURE.js +esid: sec-moduleevaluation +flags: [module] +features: [top-level-await, globalThis] +---*/ + +import './dfs-invariant-direct-1_FIXTURE.js'; +import './dfs-invariant-direct-2_FIXTURE.js'; +import './dfs-invariant-indirect_FIXTURE.js'; + +assert.sameValue(globalThis.test262, 'async:direct-1:direct-2:indirect');