| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3c9e435 commit e5980a1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | 5 | const common = require('../common'); | |
| 6 | 6 | const assert = require('assert'); | |
| 7 | - const { SourceTextModule, SyntheticModule, createContext } = require('vm'); | ||
| 7 | + const { | ||
| 8 | + Module, | ||
| 9 | + SourceTextModule, | ||
| 10 | + SyntheticModule, | ||
| 11 | + createContext | ||
| 12 | + } = require('vm'); | ||
| 8 | 13 | const util = require('util'); | |
| 9 | 14 | ||
| 10 | 15 | (async function test1() { | |
@@ -107,3 +112,38 @@ const util = require('util'); | |||
| 107 | 112 | assert.notStrictEqual(dep, undefined); | |
| 108 | 113 | assert.strictEqual(dep, m.dependencySpecifiers); | |
| 109 | 114 | } | |
| 115 | + | ||
| 116 | + // Check the impossibility of creating an abstract instance of the Module. | ||
| 117 | + { | ||
| 118 | + common.expectsError(() => new Module(), { | ||
| 119 | + message: 'Module is not a constructor', | ||
| 120 | + type: TypeError | ||
| 121 | + }); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + // Check to throws invalid exportNames | ||
| 125 | + { | ||
| 126 | + common.expectsError(() => new SyntheticModule(undefined, () => {}, {}), { | ||
| 127 | + message: 'The "exportNames" argument must be an Array of strings.' + | ||
| 128 | + ' Received undefined', | ||
| 129 | + type: TypeError | ||
| 130 | + }); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + // Check to throws invalid evaluateCallback | ||
| 134 | + { | ||
| 135 | + common.expectsError(() => new SyntheticModule([], undefined, {}), { | ||
| 136 | + message: 'The "evaluateCallback" argument must be of type function.' + | ||
| 137 | + ' Received undefined', | ||
| 138 | + type: TypeError | ||
| 139 | + }); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + // Check to throws invalid options | ||
| 143 | + { | ||
| 144 | + common.expectsError(() => new SyntheticModule([], () => {}, null), { | ||
| 145 | + message: 'The "options" argument must be of type object.' + | ||
| 146 | + ' Received null', | ||
| 147 | + type: TypeError | ||
| 148 | + }); | ||
| 149 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments