-
Notifications
You must be signed in to change notification settings - Fork 3
/
message_test.ts
30 lines (28 loc) · 989 Bytes
/
message_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { assertNode, assertNodeThrows } from "./testutil.ts";
import { Message } from "./message.ts";
Deno.test("Message", async () => {
const tt: [string, Message][] = [
[`message foo {}`, new Message("foo", [], [1, 1], [1, 14])],
[`message foo.bar {}`, new Message("foo.bar", [], [1, 1], [1, 18])],
[`message foo_bar {}`, new Message("foo_bar", [], [1, 1], [1, 18])],
];
for (const t of tt) await assertNode(Message, ...t);
});
Deno.test("Message errors", async () => {
const tt: [string, string][] = [
[`message foo {`, "unexpected eof on line 1, column 13"],
[
`message _foo {}`,
"unexpected token (_) on line 1, column 9; expected identifier",
],
[
`message 1foo {}`,
"unexpected int (1) on line 1, column 9; expected identifier",
],
[
`message foo..bar {}`,
"unexpected token (.) on line 1, column 13; expected identifier",
],
];
for (const t of tt) await assertNodeThrows(Message, ...t);
});