summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2021-08-23 18:31:19 +0200
committerGitHub <noreply@github.com>2021-08-23 18:31:19 +0200
commitdf084b9f14e06f866f18206e8051c4721702fb44 (patch)
tree2b544f7106f8970b995fda53ba558bd20d2be414 /cli
parent2187c11e5d026733b4df1d675cfe5922302c8f4b (diff)
fix(ext/ffi): don't panic on invalid enum values (#11815)
Co-authored-by: Feng Yu <f3n67u@gmail.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/tests/unit/ffi_test.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/tests/unit/ffi_test.ts b/cli/tests/unit/ffi_test.ts
new file mode 100644
index 000000000..ab25df699
--- /dev/null
+++ b/cli/tests/unit/ffi_test.ts
@@ -0,0 +1,25 @@
+// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+
+import { assertThrows, unitTest } from "./test_util.ts";
+
+unitTest(function dlopenInvalidArguments() {
+ const filename = "/usr/lib/libc.so.6";
+ assertThrows(() => {
+ // @ts-expect-error: ForeignFunction cannot be null
+ Deno.dlopen(filename, { malloc: null });
+ }, TypeError);
+ assertThrows(() => {
+ Deno.dlopen(filename, {
+ // @ts-expect-error: invalid NativeType
+ malloc: { parameters: ["a"], result: "b" },
+ });
+ }, TypeError);
+ assertThrows(() => {
+ // @ts-expect-error: DynamicLibrary symbols cannot be null
+ Deno.dlopen(filename, null);
+ }, TypeError);
+ assertThrows(() => {
+ // @ts-expect-error: require 2 arguments
+ Deno.dlopen(filename);
+ }, TypeError);
+});