-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: package should work normal (#14)
* fix: dynamic import should work * test: fallback vm test * feat: vm capture should skip underscore * fix: typesVersion only exports url * feat: add debug * docs: update document * chore: exmaple add debug mode
- Loading branch information
Showing
15 changed files
with
93 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import test from 'ava' | ||
import { MAX_CONCURRENT, createConcurrentQueue, createVM } from '../src/vm' | ||
|
||
test('native vm', async (t) => { | ||
const vm = createVM() | ||
await vm.run('var nonzzz = \'test plugin\'', { name: 'nonzzz' } as any, (err) => err) | ||
t.is(vm.bindings.has('nonzzz'), true) | ||
}) | ||
|
||
test('shadow vm', async (t) => { | ||
const vm = createVM() | ||
await vm.run('window.nonzzz = 123', { name: 'nonzzz' } as any, (err) => err) | ||
t.is(vm.bindings.has('nonzzz'), true) | ||
}) | ||
|
||
test('throw error in vm', async (t) => { | ||
const vm = createVM() | ||
await vm.run('throw new Error(\'error\')', { name: 'nonzzz' } as any, (err) => { | ||
t.is(err?.message, 'nonzzz') | ||
}) | ||
}) | ||
|
||
test('task queue', async (t) => { | ||
const tasks = [() => Promise.resolve(), () => Promise.resolve(), () => Promise.reject(new Error('3'))] | ||
|
||
const queue = createConcurrentQueue(MAX_CONCURRENT) | ||
for (const task of tasks) { | ||
queue.enqueue(task) | ||
} | ||
const err = await t.throwsAsync(queue.wait()) | ||
t.is(err?.message, '3') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters