1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-14 16:33:45 -05:00
denoland-deno/cli/tests/unit/ffi_test.ts

26 lines
808 B
TypeScript
Raw Normal View History

2022-01-20 02:10:16 -05:00
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { assertThrows } from "./test_util.ts";
Deno.test({ permissions: { ffi: true } }, 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);
});