v8/test/mjsunit/modules-namespace4.mjs
Mathias Bynens 5c2c5ce133 [test] Remove module pragma in favor of .mjs
d8 treats files with the .mjs extension as modules instead of
classic scripts. Thus, the `// MODULE` pragma and its corresponding
logic in test runners can be removed in favor of explicitly adding
the extension.

Bug: v8:7950, v8:9395, v8:9406
Also-By: tmrts@chromium.org
Change-Id: Ic74328dc5c5f176bb4bdf6d74bdd4d3966279ba5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1675958
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Tamer Tas <tmrts@chromium.org>
Auto-Submit: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62421}
2019-06-27 13:25:48 +00:00

58 lines
1.5 KiB
JavaScript

// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as foo from "modules-namespace4.mjs";
assertSame(undefined, a);
assertThrows(() => b, ReferenceError);
assertThrows(() => B, ReferenceError);
assertThrows(() => c, ReferenceError);
assertEquals(45, d());
assertSame(undefined, foo.a);
assertThrows(() => foo.b, ReferenceError);
assertThrows(() => foo.B, ReferenceError);
assertThrows(() => foo.c, ReferenceError);
assertEquals(45, foo.d());
assertThrows(() => foo.default, ReferenceError);
assertSame(undefined, foo.doesnotexist);
Function("Foo", " \
with (Foo) { \
assertEquals(undefined, a); \
assertThrows(() => b, ReferenceError); \
assertThrows(() => B, ReferenceError); \
assertThrows(() => c, ReferenceError); \
assertEquals(45, d()); \
}")(foo);
export var a = 42;
export let b = 43;
export {b as B};
export const c = 44;
export function d() { return 45 };
export default 46;
assertEquals(42, a);
assertEquals(43, b);
assertEquals(44, c);
assertEquals(45, d());
assertEquals(42, foo.a);
assertEquals(43, foo.b);
assertEquals(43, foo.B);
assertEquals(44, foo.c);
assertEquals(45, foo.d());
assertEquals(46, foo.default);
assertSame(undefined, foo.doesnotexist);
Function("Foo", " \
with (Foo) { \
assertEquals(42, a); \
assertEquals(43, b); \
assertEquals(43, B); \
assertEquals(44, c); \
assertEquals(45, d()); \
}")(foo);