diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-04-20 10:27:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 10:27:15 -0400 |
commit | 6e5f3453f806d6007b8f724837b5dd7d9eb17be9 (patch) | |
tree | 12d683562ae59856c81aca683541b0239290c41a /test_plugin/tests/test.js | |
parent | 437e35ca52227337588148a6896040d3fc3f2d54 (diff) |
Remove core/plugin.rs (#4824)
This simplifies the plugin interface in order to deliver op crates with a similar API
Diffstat (limited to 'test_plugin/tests/test.js')
-rw-r--r-- | test_plugin/tests/test.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/test_plugin/tests/test.js b/test_plugin/tests/test.js index d34624f09..3661e1078 100644 --- a/test_plugin/tests/test.js +++ b/test_plugin/tests/test.js @@ -17,14 +17,21 @@ const filename = `../target/${Deno.args[0]}/${filenamePrefix}${filenameBase}${fi // in runTestClose() below. const resourcesPre = Deno.resources(); -const plugin = Deno.openPlugin(filename); +const rid = Deno.openPlugin(filename); -const { testSync, testAsync } = plugin.ops; +const { testSync, testAsync } = Deno.core.ops(); +if (!(testSync > 0)) { + throw "bad op id for testSync"; +} +if (!(testAsync > 0)) { + throw "bad op id for testAsync"; +} const textDecoder = new TextDecoder(); function runTestSync() { - const response = testSync.dispatch( + const response = Deno.core.dispatch( + testSync, new Uint8Array([116, 101, 115, 116]), new Uint8Array([116, 101, 115, 116]) ); @@ -32,12 +39,13 @@ function runTestSync() { console.log(`Plugin Sync Response: ${textDecoder.decode(response)}`); } -testAsync.setAsyncHandler((response) => { +Deno.core.setAsyncHandler(testAsync, (response) => { console.log(`Plugin Async Response: ${textDecoder.decode(response)}`); }); function runTestAsync() { - const response = testAsync.dispatch( + const response = Deno.core.dispatch( + testAsync, new Uint8Array([116, 101, 115, 116]), new Uint8Array([116, 101, 115, 116]) ); @@ -50,22 +58,22 @@ function runTestAsync() { function runTestOpCount() { const start = Deno.metrics(); - testSync.dispatch(new Uint8Array([116, 101, 115, 116])); + Deno.core.dispatch(testSync, new Uint8Array([116, 101, 115, 116])); const end = Deno.metrics(); - if (end.opsCompleted - start.opsCompleted !== 2) { + if (end.opsCompleted - start.opsCompleted !== 1) { // one op for the plugin and one for Deno.metrics throw new Error("The opsCompleted metric is not correct!"); } - if (end.opsDispatched - start.opsDispatched !== 2) { + if (end.opsDispatched - start.opsDispatched !== 1) { // one op for the plugin and one for Deno.metrics throw new Error("The opsDispatched metric is not correct!"); } } function runTestPluginClose() { - plugin.close(); + Deno.close(rid); const resourcesPost = Deno.resources(); |