diff options
author | Gus Caplan <me@gus.host> | 2019-10-04 20:08:00 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-10-14 14:25:38 -0700 |
commit | f9caee986cae09cd4cb47e0a02a5b8672ab2c16d (patch) | |
tree | 5f5171ac3a976dfe81ee0667bc2f49afc1921ec1 /test/parallel/test-vm-module-basic.js | |
parent | 7991b57cfdba96ddcd6553c8233cd6392e16a42a (diff) | |
download | android-node-v8-f9caee986cae09cd4cb47e0a02a5b8672ab2c16d.tar.gz android-node-v8-f9caee986cae09cd4cb47e0a02a5b8672ab2c16d.tar.bz2 android-node-v8-f9caee986cae09cd4cb47e0a02a5b8672ab2c16d.zip |
vm: add Synthetic modules
- Refactor vm.SourceTextModule (again)
- Add vm.Module abstract superclass
- Add vm.SyntheticModule
Refs: https://heycam.github.io/webidl/#synthetic-module-records
PR-URL: https://github.com/nodejs/node/pull/29864
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Diffstat (limited to 'test/parallel/test-vm-module-basic.js')
-rw-r--r-- | test/parallel/test-vm-module-basic.js | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/test/parallel/test-vm-module-basic.js b/test/parallel/test-vm-module-basic.js index cbe5e29d3c..30c666b6c2 100644 --- a/test/parallel/test-vm-module-basic.js +++ b/test/parallel/test-vm-module-basic.js @@ -4,7 +4,7 @@ const common = require('../common'); const assert = require('assert'); -const { SourceTextModule, createContext } = require('vm'); +const { SourceTextModule, SyntheticModule, createContext } = require('vm'); const util = require('util'); (async function test1() { @@ -75,15 +75,29 @@ const util = require('util'); context: { foo: 'bar' } }` ); + + assert.strictEqual(util.inspect(m, { depth: -1 }), '[SourceTextModule]'); + assert.strictEqual( m[util.inspect.custom].call(Object.create(null)), - `SourceTextModule { - status: undefined, - identifier: undefined, - context: undefined -}`, + 'Module { status: undefined, identifier: undefined, context: undefined }', ); - assert.strictEqual(util.inspect(m, { depth: -1 }), '[SourceTextModule]'); +} + +{ + const context = createContext({ foo: 'bar' }); + const m = new SyntheticModule([], () => {}, { context }); + + assert.strictEqual( + util.inspect(m), + `SyntheticModule { + status: 'unlinked', + identifier: 'vm:module(0)', + context: { foo: 'bar' } +}` + ); + + assert.strictEqual(util.inspect(m, { depth: -1 }), '[SyntheticModule]'); } // Check dependencies getter returns same object every time |