Skip to content

Commit 4a598a6

Browse files
authored
Merge pull request #215 from vim-denops/new-unknownutil
📦 Upgrade dependencies and follow up `unknownutil` v3
2 parents db7ac3f + ef32620 commit 4a598a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+109
-121
lines changed

denops_std/argument/flags_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
22
import { parseFlags } from "./flags.ts";
33

44
Deno.test("parseFlags", () => {

denops_std/argument/mod_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
22
import { parse } from "./mod.ts";
33

44
Deno.test("parse", () => {

denops_std/argument/opts_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
22
import { parseOpts } from "./opts.ts";
33

44
Deno.test("parseOpts", () => {

denops_std/autocmd/common_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
2-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
2+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
33
import { globals } from "../variable/mod.ts";
44
import { define, emit, emitAll, list, remove } from "./common.ts";
55

denops_std/autocmd/group_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
2-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
2+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
33
import { globals } from "../variable/mod.ts";
44
import { group } from "./group.ts";
55

denops_std/batch/batch_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
22
import {
33
assertSpyCall,
44
assertSpyCalls,
55
spy,
6-
} from "https://deno.land/std@0.188.0/testing/mock.ts";
7-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
6+
} from "https://deno.land/std@0.192.0/testing/mock.ts";
7+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
88
import { batch, BatchHelper } from "./batch.ts";
99

1010
test({

denops_std/batch/collect_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
assertEquals,
33
assertRejects,
4-
} from "https://deno.land/std@0.188.0/testing/asserts.ts";
5-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
4+
} from "https://deno.land/std@0.192.0/testing/asserts.ts";
5+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
66
import type { Denops } from "https://deno.land/x/denops_core@v5.0.0/mod.ts";
77
import { collect } from "./collect.ts";
88

denops_std/buffer/buffer_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
assertEquals,
33
assertRejects,
4-
} from "https://deno.land/std@0.188.0/testing/asserts.ts";
5-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
4+
} from "https://deno.land/std@0.192.0/testing/asserts.ts";
5+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
66
import { default as Encoding } from "https://cdn.skypack.dev/encoding-japanese@2.0.0/";
77
import * as fn from "../function/mod.ts";
88
import {

denops_std/buffer/decoration_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
2-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
2+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
33
import * as fn from "../function/mod.ts";
44
import * as vimFn from "../function/vim/mod.ts";
55
import * as nvimFn from "../function/nvim/mod.ts";

denops_std/buffer/fileencoding_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
22
import { default as Encoding } from "https://cdn.skypack.dev/encoding-japanese@2.0.0/";
33
import { tryDecode } from "./fileencoding.ts";
44

denops_std/buffer/fileformat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as unknownutil from "https://deno.land/x/unknownutil@v2.1.1/mod.ts";
1+
import { is } from "https://deno.land/x/unknownutil@v3.0.0/mod.ts#^";
22

33
export type FileFormat = "unix" | "dos" | "mac";
44

@@ -9,7 +9,7 @@ const fileFormatDelimiters = {
99
};
1010

1111
export function isFileFormat(v: unknown): v is FileFormat {
12-
return unknownutil.isString(v) && v in fileFormatDelimiters;
12+
return is.String(v) && v in fileFormatDelimiters;
1313
}
1414

1515
export function assertFileFormat(v: unknown): asserts v is FileFormat {

denops_std/buffer/fileformat_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
22
import { FileFormat, findFileFormat, splitText } from "./fileformat.ts";
33

44
Deno.test("splitText", async (t) => {

denops_std/bufname/bufname.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const exprPattern = /^(.*?)(?:;(.*?))?(?:#(.*))?$/;
7878
* percent-encoded characters. It's required to distinguish `params` and or `fragment`.
7979
*
8080
* ```typescript
81-
* import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
81+
* import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
8282
* import { format } from "../bufname/mod.ts";
8383
*
8484
* assertEquals(
@@ -130,7 +130,7 @@ const exprPattern = /^(.*?)(?:;(.*?))?(?:#(.*))?$/;
130130
* constructing a buffer name from a real path. For example
131131
*
132132
* ```typescript
133-
* import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
133+
* import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
134134
* import * as path from "https://deno.land/std/path/mod.ts";
135135
* import { format } from "../bufname/mod.ts";
136136
*
@@ -170,7 +170,7 @@ export function format(
170170
* For example, if it contains unusable characters ("<>|?*).
171171
*
172172
* ```typescript
173-
* import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
173+
* import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
174174
* import { parse } from "../bufname/mod.ts";
175175
*
176176
* assertEquals(
@@ -224,7 +224,7 @@ export function format(
224224
* was constructed from a real path. For example
225225
*
226226
* ```typescript
227-
* import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
227+
* import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
228228
* import * as path from "https://deno.land/std/path/mod.ts";
229229
* import { parse } from "../bufname/mod.ts";
230230
*

denops_std/bufname/bufname_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
assertEquals,
33
assertThrows,
4-
} from "https://deno.land/std@0.188.0/testing/asserts.ts";
5-
import * as path from "https://deno.land/std@0.188.0/path/mod.ts";
4+
} from "https://deno.land/std@0.192.0/testing/asserts.ts";
5+
import * as path from "https://deno.land/std@0.192.0/path/mod.ts";
66
import { format, parse } from "./bufname.ts";
77

88
Deno.test("format throws exception when 'scheme' contains unusable characters", () => {

denops_std/bufname/utils_test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
22
import { decode, encode } from "./utils.ts";
33

44
Deno.test("encode does nothing on alphabet characters", () => {

denops_std/function/buffer_test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
2-
import {
3-
assertArray,
4-
isObject,
5-
} from "https://deno.land/x/unknownutil@v2.1.1/mod.ts";
6-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
2+
import { assert, is } from "https://deno.land/x/unknownutil@v3.0.0/mod.ts#^";
3+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
74
import { BufInfo } from "./types.ts";
85
import * as buffer from "./buffer.ts";
96

@@ -23,7 +20,7 @@ test({
2320
await denops.cmd("bunload!");
2421

2522
const actual = await buffer.getbufinfo(denops);
26-
assertArray(actual, (x): x is BufInfo => isObject(x));
23+
assert(actual, is.ArrayOf((x): x is BufInfo => is.Record(x)));
2724
assertEquals(actual.length, 4);
2825
assertEquals(
2926
actual.map(({ changed, hidden, listed, loaded }) => (

denops_std/function/cursor_test.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
2-
import { assertNumber } from "https://deno.land/x/unknownutil@v2.1.1/mod.ts";
3-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
2+
import { assert, is } from "https://deno.land/x/unknownutil@v3.0.0/mod.ts#^";
3+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
44
import * as cursor from "./cursor.ts";
55
import { assertPosition, assertScreenPos, isScreenPos } from "./types.ts";
66

@@ -15,7 +15,7 @@ test({
1515
await denops.call("setline", 1, "abcdef");
1616
await denops.cmd("norm gg4|mx6|mY2|");
1717

18-
assertNumber(await cursor.col(denops, "."));
18+
assert(await cursor.col(denops, "."), is.Number);
1919
assertEquals(await cursor.col(denops, "."), 2);
2020
assertEquals(await cursor.col(denops, [1, 2]), 2);
2121
assertEquals(await cursor.col(denops, [1, "$"]), 7);
@@ -28,7 +28,7 @@ test({
2828
await denops.cmd("enew!");
2929
await denops.call("setline", 1, "\tab");
3030

31-
assertNumber(await cursor.virtcol(denops, "."));
31+
assert(await cursor.virtcol(denops, "."), is.Number);
3232
assertEquals(await cursor.virtcol(denops, "."), 8);
3333
assertEquals(await cursor.virtcol(denops, [1, 1]), 8);
3434
assertEquals(await cursor.virtcol(denops, [1, "$"]), 11);
@@ -45,10 +45,10 @@ test({
4545
const winid = await denops.call("bufwinid", "%") as number;
4646
await denops.call("setline", 1, ["a", "b", "c"]);
4747

48-
assertNumber(await cursor.line(denops, "."));
48+
assert(await cursor.line(denops, "."), is.Number);
4949
assertEquals(await cursor.line(denops, "."), 1);
5050
assertEquals(await cursor.line(denops, "$"), 3);
51-
assertNumber(await cursor.line(denops, ".", winid));
51+
assert(await cursor.line(denops, ".", winid), is.Number);
5252
assertEquals(await cursor.line(denops, ".", winid), 1);
5353
},
5454
});
@@ -57,26 +57,26 @@ test({
5757
name: "wincol()",
5858
fn: async () => {
5959
await denops.cmd("enew!");
60-
assertNumber(await cursor.wincol(denops));
60+
assert(await cursor.wincol(denops), is.Number);
6161
},
6262
});
6363

6464
await t.step({
6565
name: "winline()",
6666
fn: async () => {
6767
await denops.cmd("enew!");
68-
assertNumber(await cursor.winline(denops));
68+
assert(await cursor.winline(denops), is.Number);
6969
},
7070
});
7171

7272
await t.step({
7373
name: "cursor()",
7474
fn: async () => {
7575
await denops.cmd("enew!");
76-
assertNumber(await cursor.cursor(denops, 1, 2));
77-
assertNumber(await cursor.cursor(denops, 1, 2, 3));
78-
assertNumber(await cursor.cursor(denops, [1, 2, 3]));
79-
assertNumber(await cursor.cursor(denops, [1, 2, 3, 4]));
76+
assert(await cursor.cursor(denops, 1, 2), is.Number);
77+
assert(await cursor.cursor(denops, 1, 2, 3), is.Number);
78+
assert(await cursor.cursor(denops, [1, 2, 3]), is.Number);
79+
assert(await cursor.cursor(denops, [1, 2, 3, 4]), is.Number);
8080
},
8181
});
8282

@@ -123,11 +123,13 @@ test({
123123
name: "setpos",
124124
fn: async () => {
125125
await denops.cmd("enew!");
126-
assertNumber(
126+
assert(
127127
await cursor.setpos(denops, "'b", await cursor.getpos(denops, "'a")),
128+
is.Number,
128129
);
129-
assertNumber(
130+
assert(
130131
await cursor.setpos(denops, "'b", await cursor.getcurpos(denops)),
132+
is.Number,
131133
);
132134
},
133135
});
@@ -136,24 +138,24 @@ test({
136138
name: "byte2line",
137139
fn: async () => {
138140
await denops.cmd("enew!");
139-
assertNumber(await cursor.byte2line(denops, 1));
141+
assert(await cursor.byte2line(denops, 1), is.Number);
140142
},
141143
});
142144

143145
await t.step({
144146
name: "line2byte",
145147
fn: async () => {
146148
await denops.cmd("enew!");
147-
assertNumber(await cursor.line2byte(denops, 1));
149+
assert(await cursor.line2byte(denops, 1), is.Number);
148150
},
149151
});
150152

151153
await t.step({
152154
name: "diff_filler()",
153155
fn: async () => {
154156
await denops.cmd("enew!");
155-
assertNumber(await cursor.diff_filler(denops, 1));
156-
assertNumber(await cursor.diff_filler(denops, "."));
157+
assert(await cursor.diff_filler(denops, 1), is.Number);
158+
assert(await cursor.diff_filler(denops, "."), is.Number);
157159
},
158160
});
159161
},

denops_std/function/getreginfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Denops } from "https://deno.land/x/denops_core@v5.0.0/mod.ts";
2-
import { lt } from "https://deno.land/std@0.188.0/semver/mod.ts";
2+
import { lt } from "https://deno.land/std@0.192.0/semver/mod.ts";
33
import { execute } from "../helper/mod.ts";
44
import { generateUniqueString } from "../util.ts";
55

denops_std/function/input_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
22
assertEquals,
33
assertRejects,
4-
} from "https://deno.land/std@0.188.0/testing/asserts.ts";
5-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
4+
} from "https://deno.land/std@0.192.0/testing/asserts.ts";
5+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
66
import { input, inputlist, inputsecret } from "./input.ts";
77
import * as autocmd from "../autocmd/mod.ts";
88
import { execute } from "../helper/execute.ts";

denops_std/function/types.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
AssertError,
3-
isLike,
4-
} from "https://deno.land/x/unknownutil@v2.1.1/mod.ts";
1+
import { assert, is } from "https://deno.land/x/unknownutil@v3.0.0/mod.ts#^";
52

63
/**
74
* Type of `screenpos()` result.
@@ -13,30 +10,24 @@ export type ScreenPos = {
1310
curscol: number;
1411
};
1512

16-
/**
17-
* Reference ScreenPos struct for isLike.
18-
*/
19-
const refScreenPos: ScreenPos = {
20-
row: 0,
21-
col: 0,
22-
endcol: 0,
23-
curscol: 0,
24-
};
25-
2613
/**
2714
* Return true if the value is ScreenPos.
2815
*/
2916
export function isScreenPos(x: unknown): x is ScreenPos {
30-
return isLike(refScreenPos, x);
17+
const predObj = {
18+
row: is.Number,
19+
col: is.Number,
20+
endcol: is.Number,
21+
curscol: is.Number,
22+
};
23+
return is.ObjectOf(predObj)(x);
3124
}
3225

3326
/**
3427
* Assert if `x` is ScreenPos by raising an `AssertError` when it's not.
3528
*/
3629
export function assertScreenPos(x: unknown): asserts x is ScreenPos {
37-
if (!isScreenPos(x)) {
38-
throw new AssertError("The value must be ScreenPos");
39-
}
30+
assert(x, isScreenPos, { message: "The value must be ScreenPos" });
4031
}
4132

4233
/**
@@ -54,17 +45,18 @@ export type Position = [
5445
* Return true if the value is Position.
5546
*/
5647
export function isPosition(x: unknown): x is Position {
57-
return Array.isArray(x) && (x.length === 4 || x.length === 5) &&
58-
x.every((x) => typeof x === "number");
48+
const pred = is.OneOf([
49+
is.TupleOf([is.Number, is.Number, is.Number, is.Number]),
50+
is.TupleOf([is.Number, is.Number, is.Number, is.Number, is.Number]),
51+
]);
52+
return pred(x);
5953
}
6054

6155
/**
6256
* Assert if `x` is Position by raising an `AssertError` when it's not.
6357
*/
6458
export function assertPosition(x: unknown): asserts x is Position {
65-
if (!isPosition(x)) {
66-
throw new AssertError("The value must be Position");
67-
}
59+
assert(x, isPosition, { message: "The value must be Position" });
6860
}
6961

7062
const validBuiltinCompletions = [

denops_std/function/various_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { assertEquals } from "https://deno.land/std@0.188.0/testing/asserts.ts";
2-
import { test } from "https://deno.land/x/denops_test@v1.3.1/mod.ts";
1+
import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts";
2+
import { test } from "https://deno.land/x/denops_test@v1.4.0/mod.ts";
33
import * as various from "./various.ts";
44

55
test({

0 commit comments

Comments
 (0)