Commit 92e3bcb1 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[runtime] Use TLA in more tests

Enable more tests to use top level await modules.

Bug: v8:9344
Change-Id: I61c0c0205235969a43af602af327654b7e8a3dad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2074402Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66726}
parent f2a0f53c
......@@ -45,6 +45,9 @@ MaybeLocal<Module> ResolveCallback(Local<Context> context,
}
TEST(ModuleInstantiationFailures1) {
bool prev_top_level_await = i::FLAG_harmony_top_level_await;
for (auto top_level_await : {true, false}) {
i::FLAG_harmony_top_level_await = top_level_await;
Isolate* isolate = CcTest::isolate();
HandleScope scope(isolate);
LocalContext env;
......@@ -73,7 +76,8 @@ TEST(ModuleInstantiationFailures1) {
// Instantiation should fail.
{
v8::TryCatch inner_try_catch(isolate);
CHECK(module->InstantiateModule(env.local(), ResolveCallback).IsNothing());
CHECK(
module->InstantiateModule(env.local(), ResolveCallback).IsNothing());
CHECK(inner_try_catch.HasCaught());
CHECK(inner_try_catch.Exception()->StrictEquals(v8_str("boom")));
CHECK_EQ(Module::kUninstantiated, module->GetStatus());
......@@ -100,16 +104,23 @@ TEST(ModuleInstantiationFailures1) {
// Instantiation should fail because a sub-module fails to resolve.
{
v8::TryCatch inner_try_catch(isolate);
CHECK(module->InstantiateModule(env.local(), ResolveCallback).IsNothing());
CHECK(
module->InstantiateModule(env.local(), ResolveCallback).IsNothing());
CHECK(inner_try_catch.HasCaught());
CHECK(inner_try_catch.Exception()->StrictEquals(v8_str("boom")));
CHECK_EQ(Module::kUninstantiated, module->GetStatus());
}
CHECK(!try_catch.HasCaught());
}
i::FLAG_harmony_top_level_await = prev_top_level_await;
}
TEST(ModuleInstantiationFailures2) {
bool prev_top_level_await = i::FLAG_harmony_top_level_await;
for (auto top_level_await : {true, false}) {
i::FLAG_harmony_top_level_await = top_level_await;
Isolate* isolate = CcTest::isolate();
HandleScope scope(isolate);
LocalContext env;
......@@ -186,6 +197,8 @@ TEST(ModuleInstantiationFailures2) {
CHECK_EQ(Module::kInstantiated, dep1->GetStatus());
CHECK_EQ(Module::kUninstantiated, dep2->GetStatus());
}
}
i::FLAG_harmony_top_level_await = prev_top_level_await;
}
static MaybeLocal<Module> CompileSpecifierAsModuleResolveCallback(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment