Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Add test for hoisting declarations before module execution.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Oct 7, 2017
1 parent 920ae01 commit 44811ef
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
7 changes: 7 additions & 0 deletions test/fixture/cycle/declarations/a.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { b } from "./b.mjs"

function a() {
return b()
}

export { a }
8 changes: 8 additions & 0 deletions test/fixture/cycle/declarations/b.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { a } from "./a.mjs"

function b() {
return true
}

export { b }
export default a()
10 changes: 8 additions & 2 deletions test/misc-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,14 @@ describe("Node rules", () => {
})

describe("spec compliance", () => {
it("should bind exports before the module executes", () =>
import("./misc/export/cycle-named.mjs")
it("should establish bindings before the module executes", () =>
import("./misc/bindings.mjs")
.then((ns) => ns.default())
.catch((e) => assert.ifError(e))
)

it("should hoist declarations before the module executes", () =>
import("./misc/declarations.mjs")
.then((ns) => ns.default())
.catch((e) => assert.ifError(e))
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "assert"
import def from "../../fixture/cycle/named/a.mjs"
import def from "../fixture/cycle/named/a.mjs"

export default () => {
assert.strictEqual(def, true)
Expand Down
9 changes: 9 additions & 0 deletions test/misc/declarations.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import assert from "assert"
import { a } from "../fixture/cycle/declarations/a.mjs"
import def, { b } from "../fixture/cycle/declarations/b.mjs"

export default () => {
assert.strictEqual(a(), true)
assert.strictEqual(b(), true)
assert.strictEqual(def, true)
}

0 comments on commit 44811ef

Please sign in to comment.