From 7df0cbdd1fd06abc069390a7a05d55cb7fee65cc Mon Sep 17 00:00:00 2001 From: afinch7 Date: Tue, 19 Nov 2019 16:36:56 -0500 Subject: [PATCH] added tests and fixed a issue with types --- cli/js/lib.deno_runtime.d.ts | 2 +- cli/tests/052_native_plugins.ts | 16 ++++++++++++++++ cli/tests/052_native_plugins.ts.out | 2 ++ cli/tests/integration_tests.rs | 14 ++++++++++++++ cli/tests/test_native_plugin/mod.ts | 6 ------ 5 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 cli/tests/052_native_plugins.ts create mode 100644 cli/tests/052_native_plugins.ts.out diff --git a/cli/js/lib.deno_runtime.d.ts b/cli/js/lib.deno_runtime.d.ts index b519381a6c901b..6205dc28d28332 100644 --- a/cli/js/lib.deno_runtime.d.ts +++ b/cli/js/lib.deno_runtime.d.ts @@ -978,7 +978,7 @@ declare namespace Deno { control: Uint8Array, zeroCopy?: ArrayBufferView | null ): Uint8Array | null; - setAsyncHandler(handler: MessageCallback): void; + setAsyncHandler(handler: AsyncHandler): void; } export interface NativePlugin { diff --git a/cli/tests/052_native_plugins.ts b/cli/tests/052_native_plugins.ts new file mode 100644 index 00000000000000..fd1e56f710caf3 --- /dev/null +++ b/cli/tests/052_native_plugins.ts @@ -0,0 +1,16 @@ +const plugin = Deno.openPlugin( + `./../../target/${Deno.args[1]}/libtest_native_plugin.so` +); + +// eslint-disable-next-line @typescript-eslint/camelcase +const test_io_sync = plugin.ops.test_io_sync; + +const textDecoder = new TextDecoder(); + +// eslint-disable-next-line @typescript-eslint/camelcase +const response = test_io_sync.dispatch( + new Uint8Array([116, 101, 115, 116]), + new Uint8Array([116, 101, 115, 116]) +); + +console.log(`Native Binding Response: ${textDecoder.decode(response)}`); diff --git a/cli/tests/052_native_plugins.ts.out b/cli/tests/052_native_plugins.ts.out new file mode 100644 index 00000000000000..b8cfcce4567f5f --- /dev/null +++ b/cli/tests/052_native_plugins.ts.out @@ -0,0 +1,2 @@ +Hello from native bindings. data: test | zero_copy: test +Native Binding Response: test diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 195202d49c0b87..cc45a5b3b98dd4 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -356,6 +356,20 @@ itest!(_051_wasm_import { http_server: true, }); +#[cfg(not(debug_assertions))] +itest!(_052_native_plugins_release { + args: "run --reload --allow-native 052_native_plugins.ts release", + output: "052_native_plugins.ts.out", + http_server: false, +}); + +#[cfg(debug_assertions)] +itest!(_052_native_plugins_debug { + args: "run --reload --allow-native 052_native_plugins.ts debug", + output: "052_native_plugins.ts.out", + http_server: false, +}); + itest!(lock_check_ok { args: "run --lock=lock_check_ok.json http://127.0.0.1:4545/cli/tests/003_relative_import.ts", output: "003_relative_import.ts.out", diff --git a/cli/tests/test_native_plugin/mod.ts b/cli/tests/test_native_plugin/mod.ts index fb181227541f1e..e69de29bb2d1d6 100644 --- a/cli/tests/test_native_plugin/mod.ts +++ b/cli/tests/test_native_plugin/mod.ts @@ -1,6 +0,0 @@ -const plugin = Deno.openPlugin( - "./../../../target/debug/libtest_native_plugin.so" -); -const op_test_io_async = plugin.ops.op_test_io_async; - -console.log(op_test_io_async);