diff options
Diffstat (limited to 'test/reading/test.ts')
-rw-r--r-- | test/reading/test.ts | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/test/reading/test.ts b/test/reading/test.ts index 051cfc6..6a82b3f 100644 --- a/test/reading/test.ts +++ b/test/reading/test.ts @@ -1,35 +1,18 @@ -import * as path from 'https://deno.land/std@0.102.0/path/mod.ts'; - -import { assertEquals } from "https://deno.land/std@0.192.0/testing/asserts.ts"; +import { assertEquals } from "../base.ts"; +import cases from "./cases.ts"; +import Yomikun from "../../api/yomikun.ts"; import DirectCoreClient from '../../core/direct/client.ts'; var core = new DirectCoreClient(); await core.ready; - -interface Test { - test: { - input: string; - reading: string; - }; - _original: string; - tags: Array<string>; -}; - -const here = path.dirname(path.fromFileUrl(import.meta.url)); -const tests = JSON.parse(await Deno.readTextFile(path.resolve(here, 'cases.json'))) as Test[]; - -var timeStart = performance.now(); -for (var { test } of tests) { - var result = await core.parseSentence(test.input); - // TODO: add reading back into conjugated verb to complete this test -} -var timeEnd = performance.now(); -var duration = timeEnd - timeStart; -var averageLength = tests.map(t => t.test.input.length).reduce((a, b) => a + b) / tests.length; - -console.log(` amount of sentences: ${tests.length}`); -console.log(`average sentence length: ${averageLength.toFixed(1)} characters`); -console.log(` test duration: ${duration.toFixed(0)} ms`); -console.log(` average throughput: ${(tests.length / (duration / 1e3)).toFixed(1)} sentence/second`); +var api = new Yomikun(core); + +cases.forEach(({input, output}) => { + Deno.test(`Sentence reading - ${input}`, async () => { + // TODO: use sentence reading and tags + var sentence = await api.sentence(input); + assertEquals(sentence.furigana("refold-tools"), output); + }); +}); |