diff options
author | 2023-09-20 21:31:57 -0400 | |
---|---|---|
committer | 2023-09-20 18:31:57 -0700 | |
commit | 365fc0d39ddfaed8683eb6ee75013a0fe3adcae2 (patch) | |
tree | 1647bf44082454f51d6a3e3ceaeeb7032d6c7930 /test/js/node/module/node-module-module.test.js | |
parent | 34d191be67e821284e6e2a241a17731f2d646e2f (diff) | |
download | bun-365fc0d39ddfaed8683eb6ee75013a0fe3adcae2.tar.gz bun-365fc0d39ddfaed8683eb6ee75013a0fe3adcae2.tar.zst bun-365fc0d39ddfaed8683eb6ee75013a0fe3adcae2.zip |
implement `Module.prototype._compile` (#5840)
Diffstat (limited to 'test/js/node/module/node-module-module.test.js')
-rw-r--r-- | test/js/node/module/node-module-module.test.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/js/node/module/node-module-module.test.js b/test/js/node/module/node-module-module.test.js index e5e21c981..1363636ac 100644 --- a/test/js/node/module/node-module-module.test.js +++ b/test/js/node/module/node-module-module.test.js @@ -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"); +}); |