aboutsummaryrefslogtreecommitdiff
path: root/test/language-transformer-cycles.test.js
diff options
context:
space:
mode:
authorStefanVukovic99 <stefanvukovic44@gmail.com>2024-02-27 13:16:21 +0100
committerGitHub <noreply@github.com>2024-02-27 12:16:21 +0000
commit0792954e345925b3e3b2ebb733367e138375978e (patch)
treea9f169cf7dc2de396d6e46c9d8c418f9870d9301 /test/language-transformer-cycles.test.js
parentc4fea2251606fb0b3d0d761a544dac578f3d9048 (diff)
make deinflections language-specific (#720)
* abstract deinflections * undo redundant changes * remove cast * MultiLanguageTransformer * comments * comments
Diffstat (limited to 'test/language-transformer-cycles.test.js')
-rw-r--r--test/language-transformer-cycles.test.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/test/language-transformer-cycles.test.js b/test/language-transformer-cycles.test.js
index b778c188..751f65a6 100644
--- a/test/language-transformer-cycles.test.js
+++ b/test/language-transformer-cycles.test.js
@@ -21,6 +21,7 @@ import {fileURLToPath} from 'url';
import {describe, test} from 'vitest';
import {parseJson} from '../dev/json.js';
import {LanguageTransformer} from '../ext/js/language/language-transformer.js';
+import {getLanguageSummaries} from '../ext/js/language/languages.js';
class DeinflectionNode {
/**
@@ -103,12 +104,18 @@ function arraysAreEqual(rules1, rules2) {
return true;
}
-describe('Deinflection data', () => {
- test('Check for cycles', ({expect}) => {
- const dirname = pathDirname(fileURLToPath(import.meta.url));
+const dirname = pathDirname(fileURLToPath(import.meta.url));
+const descriptors = [];
+const languageSummaries = getLanguageSummaries();
+for (const {languageTransformsFile} of languageSummaries) {
+ if (!languageTransformsFile) { continue; }
+ /** @type {import('language-transformer').LanguageTransformDescriptor} */
+ const descriptor = parseJson(readFileSync(join(dirname, `../ext/${languageTransformsFile}`), {encoding: 'utf8'}));
+ descriptors.push(descriptor);
+}
- /** @type {import('language-transformer').LanguageTransformDescriptor} */
- const descriptor = parseJson(readFileSync(join(dirname, '../ext/data/language/japanese-transforms.json'), {encoding: 'utf8'}));
+describe.each(descriptors)('Cycles Test $language', (descriptor) => {
+ test('Check for cycles', ({expect}) => {
const languageTransformer = new LanguageTransformer();
languageTransformer.addDescriptor(descriptor);