Skip to content

Commit

Permalink
Merge pull request #426 from vim-denops/fix-for-v2
Browse files Browse the repository at this point in the history
Fix for Deno v2
  • Loading branch information
lambdalisue authored Nov 8, 2024
2 parents 3a38e08 + 5b23d4d commit 0c72261
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
verbose:
type: boolean
required: false
description: 'Enable verbose output'
description: "Enable verbose output"
default: false

defaults:
Expand All @@ -34,6 +34,7 @@ jobs:
- ubuntu-latest
version:
- "1.x"
- "2.x"
runs-on: ${{ matrix.runner }}
steps:
- run: git config --global core.autocrlf false
Expand Down Expand Up @@ -68,6 +69,7 @@ jobs:
deno_version:
- "1.45.0"
- "1.x"
- "2.x"
host_version:
- vim: "v9.1.0448"
nvim: "v0.10.0"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ can ask questions in English.
### YouTube
[![Revolutionizing Vim/Neovim Plugin Development ~ An In-Depth Look into Denops
](http://img.youtube.com/vi/hu9EN7jl2kA/0.jpg)](https://www.youtube.com/watch?v=hu9EN7jl2kA)<br>
[English slide](https://bit.ly/4eQ8LH5) in a talk at [VimConf 2023 Tiny](https://vimconf.org/2023/) (with Japanese)
[![Revolutionizing Vim/Neovim Plugin Development ~ An In-Depth Look into Denops](http://img.youtube.com/vi/hu9EN7jl2kA/0.jpg)](https://www.youtube.com/watch?v=hu9EN7jl2kA)<br>
[English slide](https://bit.ly/4eQ8LH5) in a talk at
[VimConf 2023 Tiny](https://vimconf.org/2023/) (with Japanese)
## Misc.
Expand Down
2 changes: 1 addition & 1 deletion denops/@denops-private/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class Plugin {
try {
return await this.#denops.dispatcher[fn](...args);
} catch (err) {
const errMsg = err.message ?? err;
const errMsg = err instanceof Error ? err.message : String(err);
throw new Error(
`Failed to call '${fn}' API in '${this.name}': ${errMsg}`,
);
Expand Down
6 changes: 4 additions & 2 deletions tests/denops/testutil/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export function pendingPromise(): Promise<never> {
}

/** Returns a fake `TcpListener` instance. */
export function createFakeTcpListener(): Deno.TcpListener {
// NOTE: 'rid' is removed from Deno v2
export function createFakeTcpListener(): { rid: unknown } & Deno.TcpListener {
let closeWaiter: PromiseWithResolvers<never> | undefined = Promise
.withResolvers();
closeWaiter.promise.catch(() => {});
Expand Down Expand Up @@ -54,7 +55,8 @@ export function createFakeTcpListener(): Deno.TcpListener {
}

/** Returns a fake `TcpConn` instance. */
export function createFakeTcpConn(): Deno.TcpConn {
// NOTE: 'rid' is removed from Deno v2
export function createFakeTcpConn(): { rid: unknown } & Deno.TcpConn {
return {
get localAddr() {
return unimplemented();
Expand Down
22 changes: 18 additions & 4 deletions tests/denops/testutil/mock_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ Deno.test("createFakeTcpListener()", async (t) => {
close: 0,
[Symbol.asyncIterator]: 0,
[Symbol.dispose]: 0,
} as const satisfies Record<keyof Deno.TcpListener, 0>,
} as const satisfies Record<
// NOTE: 'rid' is removed from Deno v2
keyof { rid: unknown } & Deno.TcpListener,
0
>,
);
for (const key of keys) {
await t.step(key.toString(), () => {
Expand All @@ -70,7 +74,10 @@ Deno.test("createFakeTcpListener()", async (t) => {
const unimplementedProps = [
"addr",
"rid",
] as const satisfies readonly GetterKeyOf<Deno.TcpListener>[];
] as const satisfies readonly GetterKeyOf<
// NOTE: 'rid' is removed from Deno v2
{ rid: unknown } & Deno.TcpListener
>[];
for (const key of unimplementedProps) {
await t.step(`.${key}`, () => {
assertThrows(() => listener[key], Error, "Unimplemented");
Expand Down Expand Up @@ -230,7 +237,11 @@ Deno.test("createFakeTcpConn()", async (t) => {
close: 0,
closeWrite: 0,
[Symbol.dispose]: 0,
} as const satisfies Record<keyof Deno.TcpConn, 0>,
} as const satisfies Record<
// NOTE: 'rid' is removed from Deno v2
keyof { rid: unknown } & Deno.TcpConn,
0
>,
);
for (const key of keys) {
await t.step(key.toString(), () => {
Expand All @@ -246,7 +257,10 @@ Deno.test("createFakeTcpConn()", async (t) => {
"rid",
"readable",
"writable",
] as const satisfies readonly GetterKeyOf<Deno.TcpConn>[];
] as const satisfies readonly GetterKeyOf<
// NOTE: 'rid' is removed from Deno v2
{ rid: unknown } & Deno.TcpConn
>[];
for (const key of unimplementedProps) {
await t.step(`.${key}`, () => {
assertThrows(() => conn[key], Error, "Unimplemented");
Expand Down

0 comments on commit 0c72261

Please sign in to comment.