diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-07-11 13:01:41 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-07-11 13:01:41 +0200 |
commit | e99ae80f7adc0f0e677381c3cc1549235d3877ab (patch) | |
tree | 57362ddfa0ee2704cf7042d72559c479283ea1df /test | |
parent | 479836dbf3c7cc6e5940abe698ccc5e1d7b440c7 (diff) |
small cleanup
Diffstat (limited to 'test')
-rw-r--r-- | test/deinflection/cases.ts | 3 | ||||
-rw-r--r-- | test/deinflection/test.ts | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/test/deinflection/cases.ts b/test/deinflection/cases.ts index e7a987e..df8d893 100644 --- a/test/deinflection/cases.ts +++ b/test/deinflection/cases.ts @@ -75,7 +75,8 @@ export default [ { input: "聞きなさい", mustHave: [ Inflection.Polite.Nasai ], mustNotHave: [], }, { input: "座りなさい", mustHave: [ Inflection.Polite.Nasai ], mustNotHave: [], }, { input: "食べさせられる", mustHave: [ Inflection.Passive, Inflection.Causative ], mustNotHave: [], }, - { input: "見極めなければならない", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Conditional.Ba, Inflection.Negative ] } + { input: "見極めなければならない", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Conditional.Ba, Inflection.Negative ] }, + { input: "ならなきゃいけない", mustHave: [ Inflection.Obligatory, Inflection.Affirmative ], mustNotHave: [ Inflection.Conditional.Ba, Inflection.Negative ] }, // TODO: りゃ for いることは // TODO: じゃ for では // and more! diff --git a/test/deinflection/test.ts b/test/deinflection/test.ts index 291ed83..fac757e 100644 --- a/test/deinflection/test.ts +++ b/test/deinflection/test.ts @@ -1,6 +1,7 @@ import cases from "./cases.ts"; import { core } from '../base.ts'; -import { TokenTag } from "../../search/tags.ts"; +import { Tag, TokenTag } from "../../search/tags.ts"; +import { recursiveValues } from "../../util/object.ts"; cases.forEach(({ input, mustHave, mustNotHave, force }) => { Deno.test(`deinflection - ${input}`, async () => { @@ -18,16 +19,21 @@ cases.forEach(({ input, mustHave, mustNotHave, force }) => { if (!result) throw new Error("No deconjugation found for input"); + function bail(msg: string) { + console.log(` wanted tags: ${mustHave.join(" + ")}`); + console.log(`unwanted tags: ${mustNotHave.join(" + ")}`); + console.log(`actual result: ${result.writing} + ${result.tags.filter(tag => recursiveValues(Tag.Inflection).includes(tag) && !recursiveValues(Tag.Inflection.Reason).includes(tag)).join(" + ")}`); + throw new Error(msg); + } + let tag: TokenTag; for (tag of mustHave) if (!result.tags.includes(tag)) - throw new Error(`Deconjugation doesn't include required tag ${tag}`); + return bail(`Deconjugation doesn't include required tag ${tag}`); for (tag of mustNotHave) if (result.tags.includes(tag)) - throw new Error(`Deconjugation includes unallowed tag ${tag}`); - - // console.log(result.writing + " + " + result.tags.filter(tag => tag.startsWith("infl:") && !tag.startsWith("infl:reason:")).join(" + ")); + return bail(`Deconjugation includes unallowed tag ${tag}`); }); }) |