diff options
Diffstat (limited to 'test/deinflection/test.ts')
-rw-r--r-- | test/deinflection/test.ts | 16 |
1 files changed, 11 insertions, 5 deletions
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}`); }); }) |