| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 34e8331 commit 48ae00c
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,65 @@ | |||
| 1 | + import { mustCall } from '../common/index.mjs'; | ||
| 2 | + import { fileURL, path } from '../common/fixtures.mjs'; | ||
| 3 | + import { match, ok, notStrictEqual, strictEqual } from 'assert'; | ||
| 4 | + import { spawn } from 'child_process'; | ||
| 5 | + import { execPath } from 'process'; | ||
| 6 | + | ||
| 7 | + { | ||
| 8 | + const child = spawn(execPath, [ | ||
| 9 | + '--experimental-loader', | ||
| 10 | + fileURL('es-module-loaders', 'thenable-load-hook.mjs').href, | ||
| 11 | + path('es-modules', 'test-esm-ok.mjs'), | ||
| 12 | + ]); | ||
| 13 | + | ||
| 14 | + let stderr = ''; | ||
| 15 | + child.stderr.setEncoding('utf8'); | ||
| 16 | + child.stderr.on('data', (data) => { | ||
| 17 | + stderr += data; | ||
| 18 | + }); | ||
| 19 | + child.on('close', mustCall((code, _signal) => { | ||
| 20 | + strictEqual(code, 0); | ||
| 21 | + ok(!stderr.includes('must not call')); | ||
| 22 | + })); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + { | ||
| 26 | + const child = spawn(execPath, [ | ||
| 27 | + '--experimental-loader', | ||
| 28 | + fileURL('es-module-loaders', 'thenable-load-hook-rejected.mjs').href, | ||
| 29 | + path('es-modules', 'test-esm-ok.mjs'), | ||
| 30 | + ]); | ||
| 31 | + | ||
| 32 | + let stderr = ''; | ||
| 33 | + child.stderr.setEncoding('utf8'); | ||
| 34 | + child.stderr.on('data', (data) => { | ||
| 35 | + stderr += data; | ||
| 36 | + }); | ||
| 37 | + child.on('close', mustCall((code, _signal) => { | ||
| 38 | + notStrictEqual(code, 0); | ||
| 39 | + | ||
| 40 | + match(stderr, /\sError: must crash the process\r?\n/); | ||
| 41 | + | ||
| 42 | + ok(!stderr.includes('must not call')); | ||
| 43 | + })); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + { | ||
| 47 | + const child = spawn(execPath, [ | ||
| 48 | + '--experimental-loader', | ||
| 49 | + fileURL('es-module-loaders', 'thenable-load-hook-rejected-no-arguments.mjs').href, | ||
| 50 | + path('es-modules', 'test-esm-ok.mjs'), | ||
| 51 | + ]); | ||
| 52 | + | ||
| 53 | + let stderr = ''; | ||
| 54 | + child.stderr.setEncoding('utf8'); | ||
| 55 | + child.stderr.on('data', (data) => { | ||
| 56 | + stderr += data; | ||
| 57 | + }); | ||
| 58 | + child.on('close', mustCall((code, _signal) => { | ||
| 59 | + notStrictEqual(code, 0); | ||
| 60 | + | ||
| 61 | + match(stderr, /\sundefined\r?\n/); | ||
| 62 | + | ||
| 63 | + ok(!stderr.includes('must not call')); | ||
| 64 | + })); | ||
| 65 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + export function load () { | ||
| 2 | + let thenAlreadyAccessed = false; | ||
| 3 | + return { | ||
| 4 | + get then() { | ||
| 5 | + if (thenAlreadyAccessed) throw new Error('must not call'); | ||
| 6 | + thenAlreadyAccessed = true; | ||
| 7 | + return (_, reject) => reject(); | ||
| 8 | + } | ||
| 9 | + }; | ||
| 10 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + export function load () { | ||
| 2 | + let thenAlreadyAccessed = false; | ||
| 3 | + return { | ||
| 4 | + get then() { | ||
| 5 | + if (thenAlreadyAccessed) throw new Error('must not call'); | ||
| 6 | + thenAlreadyAccessed = true; | ||
| 7 | + return (_, reject) => reject(new Error('must crash the process')); | ||
| 8 | + } | ||
| 9 | + }; | ||
| 10 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + export function load(url, context, next) { | ||
| 2 | + let thenAlreadyAccessed = false; | ||
| 3 | + return { | ||
| 4 | + get then() { | ||
| 5 | + if (thenAlreadyAccessed) throw new Error('must not call'); | ||
| 6 | + thenAlreadyAccessed = true; | ||
| 7 | + return (resolve) => resolve(next(url, context)); | ||
| 8 | + } | ||
| 9 | + }; | ||
| 10 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments