aboutsummaryrefslogtreecommitdiff
path: root/test/deinflection/test.ts
blob: 3faa6f8424ca2af6fc0a426a492cc3ebea72f536 (plain)
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
import cases from "./cases.ts";
import { core } from '../base.ts';
import { TokenTag } from '../../language/tags.ts';

cases.forEach(({ input, mustHave, mustNotHave }) => {
	Deno.test(`deinflection - ${input}`, async () => {
		var { tokens } = await core.parseSentence(input);

		if (tokens.length == 0)
			throw new Error("No parsed tokens for input");

		// console.log(tokens);
		var result = tokens.find(t => t.source == input);
		if (!result)
			throw new Error("No deconjugation found for input");

		let tag: TokenTag;
		for (tag of mustHave)
			if (!result.tags.includes(tag))
				throw new Error(`Deconjugation doesn't include required tag ${tag}`);

		for (tag of mustNotHave)
			if (result.tags.includes(tag))
				throw new Error(`Deconjugation includes unallowed tag ${tag}`);
	});
})