diff options
author | Grigory Gorshkov <petralmazov100@gmail.com> | 2019-05-26 14:11:42 +0300 |
---|---|---|
committer | Ujjwal Sharma <usharma1998@gmail.com> | 2019-05-29 21:24:05 +0530 |
commit | ff66e08bceb25e0d00d8818fc603b9f2bf251b63 (patch) | |
tree | 890b63160b37f9fcf686f0f28a8bb6212f27e15d /test | |
parent | c31ac419a902560ce619c599e2352b83660eb8e0 (diff) | |
download | android-node-v8-ff66e08bceb25e0d00d8818fc603b9f2bf251b63.tar.gz android-node-v8-ff66e08bceb25e0d00d8818fc603b9f2bf251b63.tar.bz2 android-node-v8-ff66e08bceb25e0d00d8818fc603b9f2bf251b63.zip |
test: add testcase for SourceTextModule custom inspect
PR-URL: https://github.com/nodejs/node/pull/27889
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-vm-module-basic.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/parallel/test-vm-module-basic.js b/test/parallel/test-vm-module-basic.js index 8cf687c2bb..caf4be328d 100644 --- a/test/parallel/test-vm-module-basic.js +++ b/test/parallel/test-vm-module-basic.js @@ -5,6 +5,7 @@ const common = require('../common'); const assert = require('assert'); const { SourceTextModule, createContext } = require('vm'); +const util = require('util'); (async function test1() { const context = createContext({ @@ -63,3 +64,21 @@ const { SourceTextModule, createContext } = require('vm'); const m3 = new SourceTextModule('3', { context: context2 }); assert.strictEqual(m3.url, 'vm:module(0)'); })(); + +// Check inspection of the instance +{ + const context = createContext({ foo: 'bar' }); + const m = new SourceTextModule('1', { context }); + + assert.strictEqual( + util.inspect(m), + "SourceTextModule {\n status: 'uninstantiated',\n linkingStatus:" + + " 'unlinked',\n url: 'vm:module(0)',\n context: { foo: 'bar' }\n}" + ); + assert.strictEqual( + m[util.inspect.custom].call(Object.create(null)), + 'SourceTextModule {\n status: undefined,\n linkingStatus: undefined,' + + '\n url: undefined,\n context: undefined\n}' + ); + assert.strictEqual(util.inspect(m, { depth: -1 }), '[SourceTextModule]'); +} |