()
| 49 | |
| 50 | // Check methods/properties can only be used under a specific state. |
| 51 | async function checkModuleState() { |
| 52 | await assert.rejects(async () => { |
| 53 | const m = new SourceTextModule(''); |
| 54 | await m.link(common.mustNotCall()); |
| 55 | assert.strictEqual(m.status, 'linked'); |
| 56 | await m.link(common.mustNotCall()); |
| 57 | }, { |
| 58 | code: 'ERR_VM_MODULE_ALREADY_LINKED' |
| 59 | }); |
| 60 | |
| 61 | await assert.rejects(async () => { |
| 62 | const m = new SourceTextModule(''); |
| 63 | m.link(common.mustNotCall()); |
| 64 | assert.strictEqual(m.status, 'linking'); |
| 65 | await m.link(common.mustNotCall()); |
| 66 | }, { |
| 67 | code: 'ERR_VM_MODULE_STATUS' |
| 68 | }); |
| 69 | |
| 70 | await assert.rejects(async () => { |
| 71 | const m = new SourceTextModule(''); |
| 72 | await m.evaluate(); |
| 73 | }, { |
| 74 | code: 'ERR_VM_MODULE_STATUS', |
| 75 | message: 'Module status must be one of linked, evaluated, or errored' |
| 76 | }); |
| 77 | |
| 78 | await assert.rejects(async () => { |
| 79 | const m = new SourceTextModule(''); |
| 80 | await m.evaluate(false); |
| 81 | }, { |
| 82 | code: 'ERR_INVALID_ARG_TYPE', |
| 83 | message: 'The "options" argument must be of type object. ' + |
| 84 | 'Received type boolean (false)' |
| 85 | }); |
| 86 | |
| 87 | assert.throws(() => { |
| 88 | const m = new SourceTextModule(''); |
| 89 | m.error; // eslint-disable-line no-unused-expressions |
| 90 | }, { |
| 91 | code: 'ERR_VM_MODULE_STATUS', |
| 92 | message: 'Module status must be errored' |
| 93 | }); |
| 94 | |
| 95 | await assert.rejects(async () => { |
| 96 | const m = await createEmptyLinkedModule(); |
| 97 | await m.evaluate(); |
| 98 | m.error; // eslint-disable-line no-unused-expressions |
| 99 | }, { |
| 100 | code: 'ERR_VM_MODULE_STATUS', |
| 101 | message: 'Module status must be errored' |
| 102 | }); |
| 103 | |
| 104 | assert.throws(() => { |
| 105 | const m = new SourceTextModule(''); |
| 106 | m.namespace; // eslint-disable-line no-unused-expressions |
| 107 | }, { |
| 108 | code: 'ERR_VM_MODULE_STATUS', |
no test coverage detected
searching dependent graphs…