Skip to content

Commit 64ee337

Browse files
committed
merge test codes
1 parent d93b51b commit 64ee337

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

src/translator/number_test.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/translator/test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,40 @@
22

33
import { assertArrayIncludes } from "@std/assert/array-includes";
44
import { translate } from "./translator.ts";
5+
import { assert } from "@std/assert/assert";
6+
import { number } from "./number.ts";
57

68
Deno.test("verb with adverb", () => {
79
const translations = translate("mi toki pona").unwrap();
810
assertArrayIncludes(translations, ["I nicely communicate"]);
911
});
12+
13+
const NUMBER_TESTS = new Map(Object.entries({
14+
"tu tu tu wan": 7,
15+
"luka tu": 7,
16+
"mute mute mute luka luka luka tu wan": 78,
17+
"wan": 1,
18+
"tu": 2,
19+
"tu wan": 3,
20+
"tu tu": 4,
21+
"luka": 5,
22+
"tu tu wan": 5,
23+
"luka wan": 6,
24+
"mute": 20,
25+
"luka luka luka luka": 20,
26+
"mute luka luka luka wan": 36,
27+
"ale": 100,
28+
"mute mute mute mute mute": 100,
29+
"ale ale ale": 300,
30+
"wan ale": 100,
31+
"tu wan ale": 300,
32+
"luka luka ale": 1000,
33+
"wan ale ale": 10000,
34+
"mute ale mute tu tu": 2024,
35+
}));
36+
Deno.test("numeral translation", () => {
37+
for (const [tokiPona, expected] of NUMBER_TESTS) {
38+
const numbers = number(tokiPona.trim().split(" ")).unwrap();
39+
assert(numbers.includes(expected), `Error at "${tokiPona}"`);
40+
}
41+
});

0 commit comments

Comments
 (0)