Skip to content

Commit 1dd064a

Browse files
committed
🌿 use core/asyncutil instead lambdalisue/async
1 parent aed70a1 commit 1dd064a

File tree

6 files changed

+48
-40
lines changed

6 files changed

+48
-40
lines changed

denops/@denops-private/cli_test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from "jsr:@std/testing@^1.0.0/mock";
2020
import { FakeTime } from "jsr:@std/testing@^1.0.0/time";
2121
import { delay } from "jsr:@std/async@^1.0.1/delay";
22-
import { promiseState } from "jsr:@lambdalisue/async@^2.1.1";
22+
import { flushPromises, peekPromiseState } from "jsr:@core/asyncutil@^1.1.1";
2323
import {
2424
createFakeTcpConn,
2525
createFakeTcpListener,
@@ -263,7 +263,7 @@ Deno.test("main()", async (t) => {
263263
});
264264

265265
await t.step("pendings main() Promise", async () => {
266-
assertEquals(await promiseState(p), "pending");
266+
assertEquals(await peekPromiseState(p), "pending");
267267
});
268268
});
269269

@@ -276,7 +276,7 @@ Deno.test("main()", async (t) => {
276276
});
277277

278278
await t.step("pendings main() Promise", async () => {
279-
assertEquals(await promiseState(p), "pending");
279+
assertEquals(await peekPromiseState(p), "pending");
280280
});
281281

282282
await t.step(
@@ -296,7 +296,7 @@ Deno.test("main()", async (t) => {
296296
});
297297

298298
await t.step("resolves main() Promise", async () => {
299-
assertEquals(await promiseState(p), "fulfilled");
299+
assertEquals(await peekPromiseState(p), "fulfilled");
300300
});
301301
});
302302

@@ -384,14 +384,15 @@ Deno.test("main()", async (t) => {
384384
});
385385

386386
await t.step("pendings main() Promise", async () => {
387-
assertEquals(await promiseState(p), "pending");
387+
assertEquals(await peekPromiseState(p), "pending");
388388
});
389389

390390
await t.step("and the listner is closed", async (t) => {
391391
fakeTcpListener.close();
392+
await flushPromises();
392393

393394
await t.step("resolves main() Promise", async () => {
394-
assertEquals(await promiseState(p), "fulfilled");
395+
assertEquals(await peekPromiseState(p), "fulfilled");
395396
});
396397
});
397398
});
@@ -460,7 +461,7 @@ Deno.test("main()", async (t) => {
460461
});
461462

462463
await t.step("resolves main() Promise", async () => {
463-
assertEquals(await promiseState(p), "fulfilled");
464+
assertEquals(await peekPromiseState(p), "fulfilled");
464465
});
465466

466467
await t.step("does not outputs error logs", () => {
@@ -604,7 +605,7 @@ Deno.test("main()", async (t) => {
604605
});
605606

606607
await t.step("resolves main() Promise", async () => {
607-
assertEquals(await promiseState(mainPromise), "fulfilled");
608+
assertEquals(await peekPromiseState(mainPromise), "fulfilled");
608609
});
609610
});
610611
});

denops/@denops-private/denops_test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
resolvesNext,
1313
stub,
1414
} from "jsr:@std/testing@^1.0.0/mock";
15-
import { promiseState } from "jsr:@lambdalisue/async@^2.1.1";
15+
import { flushPromises, peekPromiseState } from "jsr:@core/asyncutil@^1.1.1";
1616
import { DenopsImpl, type Host, type Service } from "./denops.ts";
1717

1818
type BatchReturn = [results: unknown[], errmsg: string];
@@ -360,11 +360,14 @@ Deno.test("DenopsImpl", async (t) => {
360360

361361
const dispatchPromise = denops.dispatch("dummy", "fn", "args");
362362

363-
assertEquals(await promiseState(dispatchPromise), "pending");
363+
assertEquals(await peekPromiseState(dispatchPromise), "pending");
364364
assertSpyCalls(service_waitLoaded, 1);
365365
assertSpyCalls(service_dispatch, 0);
366+
366367
waiter.resolve();
367-
assertEquals(await promiseState(dispatchPromise), "fulfilled");
368+
await flushPromises();
369+
370+
assertEquals(await peekPromiseState(dispatchPromise), "fulfilled");
368371
assertSpyCalls(service_waitLoaded, 1);
369372
assertSpyCalls(service_dispatch, 1);
370373
});

denops/@denops-private/host/nvim_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
stub,
1212
} from "jsr:@std/testing@^1.0.0/mock";
1313
import { delay } from "jsr:@std/async@^1.0.1/delay";
14-
import { promiseState } from "jsr:@lambdalisue/async@^2.1.1";
14+
import { peekPromiseState } from "jsr:@core/asyncutil@^1.1.1";
1515
import { unimplemented } from "jsr:@lambdalisue/errorutil@^1.1.0";
1616
import { Client } from "jsr:@lambdalisue/messagepack-rpc@^2.4.0";
1717
import { withNeovim } from "/denops-testutil/with.ts";
@@ -400,14 +400,14 @@ Deno.test("Neovim", async (t) => {
400400
const waitClosedPromise = host.waitClosed();
401401

402402
await t.step("pendings before the session closes", async () => {
403-
assertEquals(await promiseState(waitClosedPromise), "pending");
403+
assertEquals(await peekPromiseState(waitClosedPromise), "pending");
404404
});
405405

406406
// NOTE: Close the session of the host.
407407
await host[Symbol.asyncDispose]();
408408

409409
await t.step("fulfilled when the session closes", async () => {
410-
assertEquals(await promiseState(waitClosedPromise), "fulfilled");
410+
assertEquals(await peekPromiseState(waitClosedPromise), "fulfilled");
411411
});
412412
});
413413
},

denops/@denops-private/host/vim_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
stub,
1111
} from "jsr:@std/testing@^1.0.0/mock";
1212
import { delay } from "jsr:@std/async@^1.0.1/delay";
13-
import { promiseState } from "jsr:@lambdalisue/async@^2.1.1";
13+
import { peekPromiseState } from "jsr:@core/asyncutil@^1.1.1";
1414
import { unimplemented } from "jsr:@lambdalisue/errorutil@^1.1.0";
1515
import { Client, Session } from "jsr:@denops/vim-channel-command@^4.0.2";
1616
import { withVim } from "/denops-testutil/with.ts";
@@ -378,14 +378,14 @@ Deno.test("Vim", async (t) => {
378378
const waitClosedPromise = host.waitClosed();
379379

380380
await t.step("pendings before the session closes", async () => {
381-
assertEquals(await promiseState(waitClosedPromise), "pending");
381+
assertEquals(await peekPromiseState(waitClosedPromise), "pending");
382382
});
383383

384384
// NOTE: Close the session of the host.
385385
await host[Symbol.asyncDispose]();
386386

387387
await t.step("fulfilled when the session closes", async () => {
388-
assertEquals(await promiseState(waitClosedPromise), "fulfilled");
388+
assertEquals(await peekPromiseState(waitClosedPromise), "fulfilled");
389389
});
390390
});
391391
},

denops/@denops-private/service_test.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from "jsr:@std/testing@^1.0.0/mock";
2020
import { toFileUrl } from "jsr:@std/path@^1.0.2/to-file-url";
2121
import type { Meta } from "jsr:@denops/core@^7.0.0";
22-
import { promiseState } from "jsr:@lambdalisue/async@^2.1.1";
22+
import { flushPromises, peekPromiseState } from "jsr:@core/asyncutil@^1.1.1";
2323
import { unimplemented } from "jsr:@lambdalisue/errorutil@^1.1.0";
2424
import { resolveTestDataURL } from "/denops-testdata/resolve.ts";
2525
import type { Host } from "./denops.ts";
@@ -621,7 +621,7 @@ Deno.test("Service", async (t) => {
621621
});
622622

623623
await t.step("previous `load()` was resolved", async () => {
624-
assertEquals(await promiseState(prevLoadPromise), "fulfilled");
624+
assertEquals(await peekPromiseState(prevLoadPromise), "fulfilled");
625625
});
626626

627627
await t.step("emits `load()` and `unload()` events", () => {
@@ -668,7 +668,7 @@ Deno.test("Service", async (t) => {
668668
});
669669

670670
await t.step("previous `load()` was resolved", async () => {
671-
assertEquals(await promiseState(prevLoadPromise), "fulfilled");
671+
assertEquals(await peekPromiseState(prevLoadPromise), "fulfilled");
672672
});
673673

674674
await t.step("outputs an error message", () => {
@@ -712,7 +712,7 @@ Deno.test("Service", async (t) => {
712712
});
713713

714714
await t.step("previous `unload()` was resolved", async () => {
715-
assertEquals(await promiseState(prevUnloadPromise), "fulfilled");
715+
assertEquals(await peekPromiseState(prevUnloadPromise), "fulfilled");
716716
});
717717

718718
await t.step("emits `unload()` events", () => {
@@ -887,7 +887,7 @@ Deno.test("Service", async (t) => {
887887
});
888888

889889
await t.step("previous `load()` was resolved", async () => {
890-
assertEquals(await promiseState(prevLoadPromise), "fulfilled");
890+
assertEquals(await peekPromiseState(prevLoadPromise), "fulfilled");
891891
});
892892

893893
await t.step("emits `load()` and `reload()` events", () => {
@@ -950,7 +950,7 @@ Deno.test("Service", async (t) => {
950950
});
951951

952952
await t.step("previous `unload()` was resolved", async () => {
953-
assertEquals(await promiseState(prevUnloadPromise), "fulfilled");
953+
assertEquals(await peekPromiseState(prevUnloadPromise), "fulfilled");
954954
});
955955

956956
await t.step("emits `reload()` events", () => {
@@ -1069,7 +1069,7 @@ Deno.test("Service", async (t) => {
10691069

10701070
const actual = service.waitLoaded("dummy");
10711071

1072-
assertEquals(await promiseState(actual), "pending");
1072+
assertEquals(await peekPromiseState(actual), "pending");
10731073
});
10741074

10751075
await t.step("pendings if the plugin is already unloaded", async () => {
@@ -1081,7 +1081,7 @@ Deno.test("Service", async (t) => {
10811081

10821082
const actual = service.waitLoaded("dummy");
10831083

1084-
assertEquals(await promiseState(actual), "pending");
1084+
assertEquals(await peekPromiseState(actual), "pending");
10851085
});
10861086

10871087
await t.step("resolves if the plugin is already loaded", async () => {
@@ -1092,7 +1092,7 @@ Deno.test("Service", async (t) => {
10921092

10931093
const actual = service.waitLoaded("dummy");
10941094

1095-
assertEquals(await promiseState(actual), "fulfilled");
1095+
assertEquals(await peekPromiseState(actual), "fulfilled");
10961096
});
10971097

10981098
await t.step("resolves when the plugin is loaded", async () => {
@@ -1103,7 +1103,7 @@ Deno.test("Service", async (t) => {
11031103
const actual = service.waitLoaded("dummy");
11041104
await service.load("dummy", scriptValid);
11051105

1106-
assertEquals(await promiseState(actual), "fulfilled");
1106+
assertEquals(await peekPromiseState(actual), "fulfilled");
11071107
});
11081108

11091109
await t.step(
@@ -1118,7 +1118,7 @@ Deno.test("Service", async (t) => {
11181118
const unloadPromise = service.unload("dummy");
11191119
await Promise.all([loadPromise, unloadPromise]);
11201120

1121-
assertEquals(await promiseState(actual), "fulfilled");
1121+
assertEquals(await peekPromiseState(actual), "fulfilled");
11221122
},
11231123
);
11241124

@@ -1131,7 +1131,7 @@ Deno.test("Service", async (t) => {
11311131
const actual = service.waitLoaded("dummy");
11321132
actual.catch(NOOP);
11331133

1134-
assertEquals(await promiseState(actual), "rejected");
1134+
assertEquals(await peekPromiseState(actual), "rejected");
11351135
await assertRejects(
11361136
() => actual,
11371137
Error,
@@ -1147,7 +1147,7 @@ Deno.test("Service", async (t) => {
11471147
const actual = service.waitLoaded("dummy");
11481148
await service.close();
11491149

1150-
assertEquals(await promiseState(actual), "rejected");
1150+
assertEquals(await peekPromiseState(actual), "rejected");
11511151
await assertRejects(
11521152
() => actual,
11531153
Error,
@@ -1586,18 +1586,19 @@ Deno.test("Service", async (t) => {
15861586

15871587
const actual = service.waitClosed();
15881588

1589-
assertEquals(await promiseState(actual), "pending");
1589+
assertEquals(await peekPromiseState(actual), "pending");
15901590
});
15911591

15921592
await t.step("resolves if the service is already closed", async () => {
15931593
using _host_call = stub(host, "call");
15941594
const service = new Service(meta);
15951595
service.bind(host);
15961596
service.close();
1597+
await flushPromises();
15971598

15981599
const actual = service.waitClosed();
15991600

1600-
assertEquals(await promiseState(actual), "fulfilled");
1601+
assertEquals(await peekPromiseState(actual), "fulfilled");
16011602
});
16021603

16031604
await t.step("resolves when the service is closed", async () => {
@@ -1607,8 +1608,9 @@ Deno.test("Service", async (t) => {
16071608

16081609
const actual = service.waitClosed();
16091610
service.close();
1611+
await flushPromises();
16101612

1611-
assertEquals(await promiseState(actual), "fulfilled");
1613+
assertEquals(await peekPromiseState(actual), "fulfilled");
16121614
});
16131615
});
16141616

tests/denops/testutil/mock_test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
assertInstanceOf,
55
assertRejects,
66
} from "jsr:@std/assert@^1.0.1";
7-
import { promiseState } from "jsr:@lambdalisue/async@^2.1.1";
7+
import { flushPromises, peekPromiseState } from "jsr:@core/asyncutil@^1.1.1";
88
import {
99
createFakeTcpConn,
1010
createFakeTcpListener,
@@ -38,7 +38,7 @@ Deno.test("pendingPromise()", async (t) => {
3838
const actual = pendingPromise();
3939

4040
assertInstanceOf(actual, Promise);
41-
assertEquals(await promiseState(actual), "pending");
41+
assertEquals(await peekPromiseState(actual), "pending");
4242
});
4343
});
4444

@@ -93,7 +93,7 @@ Deno.test("createFakeTcpListener()", async (t) => {
9393
const promise = listener.accept();
9494

9595
assertInstanceOf(promise, Promise);
96-
assertEquals(await promiseState(promise), "pending");
96+
assertEquals(await peekPromiseState(promise), "pending");
9797
});
9898
});
9999

@@ -102,11 +102,12 @@ Deno.test("createFakeTcpListener()", async (t) => {
102102
const resultPromise = iterator.next();
103103

104104
await t.step("closes the conn iterator", async () => {
105-
assertEquals(await promiseState(resultPromise), "pending");
105+
assertEquals(await peekPromiseState(resultPromise), "pending");
106106

107107
listener.close();
108+
await flushPromises();
108109

109-
assertEquals(await promiseState(resultPromise), "fulfilled");
110+
assertEquals(await peekPromiseState(resultPromise), "fulfilled");
110111
assertEquals(await resultPromise, {
111112
done: true,
112113
value: undefined,
@@ -142,11 +143,12 @@ Deno.test("createFakeTcpListener()", async (t) => {
142143
const resultPromise = iterator.next();
143144

144145
assertSpyCalls(listener_accept, 1);
145-
assertEquals(await promiseState(resultPromise), "pending");
146+
assertEquals(await peekPromiseState(resultPromise), "pending");
146147

147148
firstAcceptWaiter.resolve("fake-tcp-conn");
149+
await flushPromises();
148150

149-
assertEquals(await promiseState(resultPromise), "fulfilled");
151+
assertEquals(await peekPromiseState(resultPromise), "fulfilled");
150152
assertEquals(await resultPromise, {
151153
done: false,
152154
// deno-lint-ignore no-explicit-any

0 commit comments

Comments
 (0)