|
1 | 1 | // This code is Deno only
|
2 | 2 |
|
3 |
| -import { assertArrayIncludes } from "@std/assert/array-includes"; |
4 | 3 | import { assertEquals } from "@std/assert/equals";
|
5 | 4 | import { assertLess } from "@std/assert/less";
|
6 | 5 | import { assertNotEquals } from "@std/assert/not-equals";
|
7 | 6 | import { assertThrows } from "@std/assert/throws";
|
8 | 7 | import { EXAMPLE_SENTENCES, MALFORMED_SENTENCES } from "../examples.ts";
|
9 | 8 | import { parse } from "./parser.ts";
|
10 |
| -import { end, match, matchString, sequence } from "./parser_lib.ts"; |
| 9 | +import { all, end, many, match, matchString, sequence } from "./parser_lib.ts"; |
11 | 10 | import { KU_LILI, KU_SULI, PU } from "./ucsur.ts";
|
12 | 11 |
|
13 | 12 | Deno.test("AST all distinct", () => {
|
@@ -60,5 +59,19 @@ Deno.test("small parser", () => {
|
60 | 59 | match(/a/, '"a"').skip(end),
|
61 | 60 | )
|
62 | 61 | .generateParser();
|
63 |
| - assertArrayIncludes(parser("toki pona a").unwrap(), [["toki", "pona", "a"]]); |
| 62 | + assertEquals(parser("toki pona a").unwrap(), [["toki", "pona", "a"]]); |
| 63 | +}); |
| 64 | + |
| 65 | +Deno.test("many", () => { |
| 66 | + const space = match(/\s*/, "space"); |
| 67 | + const parser = many(matchString("a").skip(space)).skip(end) |
| 68 | + .generateParser(); |
| 69 | + assertEquals(parser("a a a").unwrap(), [["a", "a", "a"]]); |
| 70 | +}); |
| 71 | + |
| 72 | +Deno.test("all", () => { |
| 73 | + const space = match(/\s*/, "space"); |
| 74 | + const parser = all(matchString("a").skip(space)).skip(end) |
| 75 | + .generateParser(); |
| 76 | + assertEquals(parser("a a a").unwrap(), [["a", "a", "a"]]); |
64 | 77 | });
|
0 commit comments