1// Copyright 2019 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// Flags: --harmony-top-level-await --allow-natives-syntax 6// Flags: --harmony-dynamic-import 7 8var ran = false; 9 10async function test1() { 11 try { 12 let x = await import('modules-skip-8.mjs'); 13 %AbortJS('failure: should be unreachable'); 14 } catch(e) { 15 assertEquals('x is not defined', e.message); 16 ran = true; 17 } 18} 19 20test1(); 21%PerformMicrotaskCheckpoint(); 22assertTrue(ran); 23 24ran = false; 25 26async function test2() { 27 try { 28 let x = await import('modules-skip-9.mjs'); 29 %AbortJS('failure: should be unreachable'); 30 } catch(e) { 31 assertInstanceof(e, SyntaxError); 32 assertEquals( 33 "The requested module 'modules-skip-empty.mjs' does not provide an " + 34 "export named 'default'", 35 e.message); 36 ran = true; 37 } 38} 39 40test2(); 41%PerformMicrotaskCheckpoint(); 42assertTrue(ran); 43 44ran = false; 45 46async function test3() { 47 try { 48 let x = await import('nonexistent-file.mjs'); 49 %AbortJS('failure: should be unreachable'); 50 } catch(e) { 51 assertTrue(e.message.startsWith('d8: Error reading')); 52 ran = true; 53 } 54} 55 56test3(); 57%PerformMicrotaskCheckpoint(); 58assertTrue(ran); 59