diff options
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}`); }); }) |