diff options
Diffstat (limited to 'test/deinflection')
-rw-r--r-- | test/deinflection/cases.ts | 31 | ||||
-rw-r--r-- | test/deinflection/test.ts | 24 |
2 files changed, 55 insertions, 0 deletions
diff --git a/test/deinflection/cases.ts b/test/deinflection/cases.ts new file mode 100644 index 0000000..04df2bd --- /dev/null +++ b/test/deinflection/cases.ts @@ -0,0 +1,31 @@ +import { TokenTags, Tag } from "../../language/tags.ts"; +const { Inflection } = Tag; + +interface Test { + input: string; + tags: TokenTags; +}; + +export default [ + { input: "取る", tags: [], }, + { input: "取らない", tags: [ Inflection.Negative ], }, + { input: "取ります", tags: [ Inflection.Polite.Masu ], }, + { input: "取りません", tags: [ Inflection.Negative, Inflection.Polite.Masu ], }, + { input: "取った", tags: [ Inflection.Tense.Past ], }, + { input: "取らなかった", tags: [ Inflection.Negative, Inflection.Tense.Past ], }, + { input: "取りました", tags: [ Inflection.Polite.Masu, Inflection.Tense.Past ], }, + { input: "取りませんでした", tags: [ Inflection.Negative, Inflection.Polite.Masu, Inflection.Tense.Past ], }, + { input: "取って", tags: [ Inflection.Suffix.Te ], }, + { input: "取らなくて", tags: [ Inflection.Negative, Inflection.Suffix.Te ], }, + { input: "取れる", tags: [ Inflection.Potential ], }, + { input: "取れない", tags: [ Inflection.Negative, Inflection.Potential ], }, + { input: "取られる", tags: [ Inflection.Passive ], }, + { input: "取られない", tags: [ Inflection.Negative, Inflection.Passive ], }, + { input: "取らせる", tags: [ Inflection.Causative ], }, + { input: "取らせない", tags: [ Inflection.Negative, Inflection.Causative ], }, + { input: "取らせられる", tags: [ Inflection.Causative, Inflection.Passive ], }, + { input: "取らせられない", tags: [ Inflection.Negative, Inflection.Causative, Inflection.Passive ], }, + { input: "取れ", tags: [ Inflection.Imperative ], }, + { input: "取るな", tags: [ Inflection.Negative, Inflection.Imperative ], }, +] satisfies Test[]; + diff --git a/test/deinflection/test.ts b/test/deinflection/test.ts new file mode 100644 index 0000000..3dc702b --- /dev/null +++ b/test/deinflection/test.ts @@ -0,0 +1,24 @@ +import DirectCoreClient from '../../core/direct/client.ts'; +import cases from "./cases.ts"; + +var core = new DirectCoreClient(); +await core.ready; + +cases.forEach(({ input, tags }) => { + 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"); + + for (var tag of tags) + if (!result.tags.includes(tag)) + throw new Error(`Deconjugation doesn't include tag ${tag}`); + }); +}) + |