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

Commit

Permalink
Add more cyclical namespace tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 26, 2019
1 parent 3c1357c commit 5a2f040
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 10 deletions.
3 changes: 0 additions & 3 deletions test/cycle/namespace/immutable/c.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const ns = getNS()

assert.strictEqual(inspect(ns), "[Module] { default: <uninitialized> }")
assert.strictEqual(Reflect.isExtensible(ns), true)
assert.strictEqual(Reflect.defineProperty(ns, "b", { value: "b" }), false)
assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false)
assert.strictEqual(inspect(ns), "[Module] { default: <uninitialized> }")
assert.strictEqual(Reflect.preventExtensions(ns), false)
3 changes: 3 additions & 0 deletions test/cycle/namespace/immutable/cjs/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

exports.c = "c"
6 changes: 6 additions & 0 deletions test/cycle/namespace/immutable/re-export/a.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "./b.mjs"
import * as ns from "./c.mjs"

export function getNS() {
return ns
}
11 changes: 11 additions & 0 deletions test/cycle/namespace/immutable/re-export/b.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import assert from "assert"
import { inspect } from "util"
import { getNS } from "./a.mjs"

const ns = getNS()

assert.strictEqual(inspect(ns), "[Module] {}")
assert.strictEqual(Reflect.isExtensible(ns), true)
assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false)
assert.strictEqual(inspect(ns), "[Module] {}")
assert.strictEqual(Reflect.preventExtensions(ns), false)
3 changes: 3 additions & 0 deletions test/cycle/namespace/immutable/re-export/c.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./d.js"
export * from "./e.mjs"
export * from "./f.js"
3 changes: 3 additions & 0 deletions test/cycle/namespace/immutable/re-export/d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

exports.d = "d"
1 change: 1 addition & 0 deletions test/cycle/namespace/immutable/re-export/e.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const e = "e"
3 changes: 3 additions & 0 deletions test/cycle/namespace/immutable/re-export/f.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

exports.f = "f"
3 changes: 0 additions & 3 deletions test/cycle/namespace/mutable/c.js

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const ns = getNS()

assert.strictEqual(inspect(ns), "[Module] {}")
assert.strictEqual(Reflect.isExtensible(ns), true)
assert.strictEqual(Reflect.defineProperty(ns, "b", { value: "b" }), false)
assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false)
assert.strictEqual(inspect(ns), "[Module] {}")
assert.strictEqual(Reflect.preventExtensions(ns), false)
3 changes: 3 additions & 0 deletions test/cycle/namespace/mutable/cjs/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

exports.c = "c"
6 changes: 6 additions & 0 deletions test/cycle/namespace/mutable/re-export/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import "./b.js"
import * as ns from "./c.js"

export function getNS() {
return ns
}
11 changes: 11 additions & 0 deletions test/cycle/namespace/mutable/re-export/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import assert from "assert"
import { inspect } from "util"
import { getNS } from "./a.js"

const ns = getNS()

assert.strictEqual(inspect(ns), "[Module] {}")
assert.strictEqual(Reflect.isExtensible(ns), true)
assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false)
assert.strictEqual(inspect(ns), "[Module] {}")
assert.strictEqual(Reflect.preventExtensions(ns), false)
3 changes: 3 additions & 0 deletions test/cycle/namespace/mutable/re-export/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./d.js"
export * from "./e.js"
export * from "./f.js"
3 changes: 3 additions & 0 deletions test/cycle/namespace/mutable/re-export/d.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

exports.d = "d"
1 change: 1 addition & 0 deletions test/cycle/namespace/mutable/re-export/e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const e = "e"
3 changes: 3 additions & 0 deletions test/cycle/namespace/mutable/re-export/f.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict"

exports.f = "f"
13 changes: 11 additions & 2 deletions test/misc-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,17 @@ describe("miscellaneous tests", () => {
it("should support namespace objects of cyclical CJS modules", () =>
Promise
.all([
"./cycle/namespace/immutable/a.mjs",
"./cycle/namespace/mutable/a.js"
"./cycle/namespace/immutable/cjs/a.mjs",
"./cycle/namespace/mutable/cjs/a.js"
]
.map((request) => import(request)))
)

it("should defer finalization of ESM namespace objects containing re-exports of CJS modules", () =>
Promise
.all([
"./cycle/namespace/immutable/re-export/a.mjs",
"./cycle/namespace/mutable/re-export/a.js"
]
.map((request) => import(request)))
)
Expand Down

0 comments on commit 5a2f040

Please sign in to comment.