mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
implement Module.prototype._compile (#5840)
This commit is contained in:
@@ -70,3 +70,20 @@ test("Overwriting _resolveFilename", () => {
|
||||
expect(stdout.toString().trim().endsWith("--pass--")).toBe(true);
|
||||
expect(exitCode).toBe(0);
|
||||
});
|
||||
|
||||
test("Module.prototype._compile", () => {
|
||||
const module = new Module("module id goes here");
|
||||
const starting_exports = module.exports;
|
||||
const r = module._compile(
|
||||
"module.exports = { module, exports, require, __filename, __dirname }",
|
||||
"/file/path/goes/here.js",
|
||||
);
|
||||
expect(r).toBe(undefined);
|
||||
expect(module.exports).not.toBe(starting_exports);
|
||||
const { module: m, exports: e, require: req, __filename: fn, __dirname: dn } = module.exports;
|
||||
expect(m).toBe(module);
|
||||
expect(e).toBe(starting_exports);
|
||||
expect(req).toBe(module.require);
|
||||
expect(fn).toBe("/file/path/goes/here.js");
|
||||
expect(dn).toBe("/file/path/goes");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user