correction, ajout gitignore

This commit is contained in:
Thibaud
2019-07-06 13:25:00 +02:00
commit 28d1936dee
182 changed files with 28900 additions and 0 deletions
+131
View File
@@ -0,0 +1,131 @@
/* eslint-env node */
/* eslint global-require: 0, func-names: 0, no-shadow: 0 */
"use strict";
const t = require("tap");
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("run config with one language", async function (t) {
const deHyphenator = await H9Y.config({"require": ["de"]});
t.test("return a function", function (t) {
t.equal(typeof deHyphenator, "function", typeof deHyphenator);
t.end();
});
t.test("hyphenate one word", function (t) {
t.equal(deHyphenator("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator("Silbentrennung"));
t.end();
});
t.test("hyphenate two words", function (t) {
t.equal(deHyphenator("Silbentrennung Algorithmus"), "Sil\u00ADben\u00ADtren\u00ADnung Al\u00ADgo\u00ADrith\u00ADmus", deHyphenator("Silbentrennung Algorithmus"));
t.end();
});
t.end();
});
t.test("run config with two languages", async function (t) {
const hyphenators = await H9Y.config({"require": ["de", "en-us"]});
t.test("return a Map", function (t) {
t.type(hyphenators, Map);
t.end();
});
t.test("get the hyphenator function promise for a language", function (t) {
const deHyphenator = hyphenators.get("de");
t.type(deHyphenator, Promise);
t.end();
});
t.test("get the hyphenator function for a language", async function (t) {
const deHyphenator = await hyphenators.get("de");
t.type(deHyphenator, Function);
t.end();
});
t.test("hyphenate one word of the first language", async function (t) {
const deHyphenator = await hyphenators.get("de");
t.equal(deHyphenator("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator("Silbentrennung"));
t.end();
});
t.test("hyphenate two words of the first language", async function (t) {
const deHyphenator = await hyphenators.get("de");
t.equal(deHyphenator("Silbentrennung Algorithmus"), "Sil\u00ADben\u00ADtren\u00ADnung Al\u00ADgo\u00ADrith\u00ADmus", deHyphenator("Silbentrennung Algorithmus"));
t.end();
});
t.test("hyphenate one word of the second language", async function (t) {
const enHyphenator = await hyphenators.get("en-us");
t.equal(enHyphenator("hyphenation"), "hy\u00ADphen\u00ADation", enHyphenator("hyphenation"));
t.end();
});
t.test("hyphenate two words of the second language", async function (t) {
const deHyphenator = await hyphenators.get("en-us");
t.equal(deHyphenator("hyphenation algorithm"), "hy\u00ADphen\u00ADation al\u00ADgo\u00ADrithm", deHyphenator("hyphenation algorithm"));
t.end();
});
t.end();
});
t.test("run config with two same languages", async function (t) {
const deHyphenator2 = await H9Y.config({"require": ["de", "de"]});
t.test("return a function", function (t) {
t.equal(typeof deHyphenator2, "function", typeof deHyphenator2);
t.end();
});
t.test("hyphenate one word", function (t) {
t.equal(deHyphenator2("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator2("Silbentrennung"));
t.end();
});
t.test("hyphenate two words", function (t) {
t.equal(deHyphenator2("Silbentrennung Algorithmus"), "Sil\u00ADben\u00ADtren\u00ADnung Al\u00ADgo\u00ADrith\u00ADmus", deHyphenator2("Silbentrennung Algorithmus"));
t.end();
});
t.end();
});
t.test("execute synchronically with one language", function (t) {
const deHyphenator = H9Y.config({
"require": ["de"],
"sync": true
});
t.test("return a function", function (t) {
t.equal(typeof deHyphenator, "function", typeof deHyphenator);
t.end();
});
t.test("hyphenate one word", function (t) {
t.equal(deHyphenator("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator("Silbentrennung"));
t.end();
});
t.test("hyphenate two words", function (t) {
t.equal(deHyphenator("Silbentrennung Algorithmus"), "Sil\u00ADben\u00ADtren\u00ADnung Al\u00ADgo\u00ADrith\u00ADmus", deHyphenator("Silbentrennung Algorithmus"));
t.end();
});
t.end();
});
t.test("execute synchronically with two languages", function (t) {
const hyphenators = H9Y.config({
"require": ["de", "en-us"],
"sync": true
});
t.test("return a Map", function (t) {
t.type(hyphenators, Map);
t.end();
});
t.test("get the hyphenator function for a language", function (t) {
const deHyphenator = hyphenators.get("de");
t.type(deHyphenator, Function);
t.end();
});
t.test("hyphenate one word of the first language", function (t) {
const deHyphenator = hyphenators.get("de");
t.equal(deHyphenator("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator("Silbentrennung"));
t.end();
});
t.end();
});
@@ -0,0 +1,306 @@
/* eslint-env node */
/* eslint global-require: 0, func-names: 0, no-shadow: 0 */
"use strict";
const t = require("tap");
t.test("set options: compound", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("compound: all", async function (t) {
const hyphenator = await H9Y.config({
"compound": "all",
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Silbentrennungs-Algorithmus"), "Sil•ben•tren•nungs-\u200BAl•go•rith•mus");
t.end();
});
t.test("compound: auto", async function (t) {
const hyphenator = await H9Y.config({
"compound": "auto",
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Silbentrennungs-Algorithmus"), "Sil•ben•tren•nungs-Al•go•rith•mus");
t.end();
});
t.test("compound: hyphen", async function (t) {
const hyphenator = await H9Y.config({
"compound": "hyphen",
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Silbentrennungs-Algorithmus"), "Silbentrennungs-\u200BAlgorithmus");
t.end();
});
t.test("compound: auto, one part too small", async function (t) {
const hyphenator = await H9Y.config({
"compound": "auto",
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Test-Algorithmus"), "Test-Al•go•rith•mus");
t.end();
});
t.test("compound: all, one part too small", async function (t) {
const hyphenator = await H9Y.config({
"compound": "all",
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Test-Algorithmus"), "Test-\u200BAl•go•rith•mus");
t.end();
});
t.end();
});
t.test("set options: exceptions", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("exceptions: global (only)", async function (t) {
const hyphenator = await H9Y.config({
"exceptions": {"global": "Silben-trennung"},
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Silbentrennung"), "Silben•trennung");
t.end();
});
t.test("exceptions: global and lang", async function (t) {
const hyphenator = await H9Y.config({
"exceptions": {
"de": "Algo-rithmus",
"global": "Silben-trennung"
},
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Silbentrennung Algorithmus"), "Silben•trennung Algo•rithmus");
t.end();
});
t.test("exceptions: double entry", async function (t) {
const hyphenator = await H9Y.config({
"exceptions": {"de": "Algo-rithmus, Algo-rithmus"},
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Algorithmus"), "Algo•rithmus");
t.end();
});
t.end();
});
t.test("set options: hyphen", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("hyphen: •", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Silbentrennung"), "Sil•ben•tren•nung");
t.end();
});
t.test("hyphen: |", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "|",
"require": ["de"]
});
t.equal(hyphenator("Silbentrennung"), "Sil|ben|tren|nung");
t.end();
});
t.end();
});
t.test("set options: left-/rightmin (patterns: 2/2)", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("left-/rightmin: 4, 5", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"leftmin": 4,
"require": ["de"],
"rightmin": 5
});
t.equal(hyphenator("Silbentrennung"), "Silben•trennung");
t.end();
});
t.end();
});
t.test("set options: left-/rightmin (patterns: 2/3)", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("left-/rightmin: 2, 2", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"leftmin": 2,
"require": ["pt"],
"rightmin": 2
});
t.equal(hyphenator("relativo"), "re•la•ti•vo");
t.end();
});
t.test("left-/rightmin: def, def", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"require": ["pt"]
});
t.equal(hyphenator("relativo"), "re•la•tivo");
t.end();
});
t.end();
});
t.test("set options: minWordLength", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("minWordLength: 7", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"minWordLength": 7,
"require": ["de"]
});
t.equal(hyphenator("Die Asse essen lieber gesunde Esswaren"), "Die Asse essen lieber ge•sun•de Ess•wa•ren");
t.end();
});
t.end();
});
t.test("set options: normalize", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("normalize: true", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"normalize": true,
"require": ["de"]
});
t.equal(hyphenator("Ba\u0308rento\u0308ter"), "Bä•ren•tö•ter");
t.end();
});
t.end();
});
t.test("set options: orphanControl", function (t) {
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("orphanControl: 1 (default)", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"require": ["de"]
});
t.equal(hyphenator("Die Asse essen lieber gesunde Esswaren"), "Die Asse essen lie•ber ge•sun•de Ess•wa•ren");
t.end();
});
t.test("orphanControl: 2", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"orphanControl": 2,
"require": ["de"]
});
t.equal(hyphenator("Die Asse essen lieber gesunde Esswaren"), "Die Asse essen lie•ber ge•sun•de Esswaren");
t.end();
});
t.test("orphanControl: 2, hyphen: |", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "|",
"orphanControl": 2,
"require": ["de"]
});
t.equal(hyphenator("Die Asse essen lieber gesunde Esswaren"), "Die Asse essen lie|ber ge|sun|de Esswaren");
t.end();
});
t.test("orphanControl: 3", async function (t) {
const hyphenator = await H9Y.config({
"hyphen": "•",
"orphanControl": 3,
"require": ["de"]
});
t.equal(hyphenator("Die Asse essen lieber gesunde Esswaren"), "Die Asse essen lie•ber ge•sun•de\u00A0Esswaren");
t.end();
});
t.end();
});
@@ -0,0 +1,86 @@
/* eslint-env node */
/* eslint global-require: 0, func-names: 0, no-shadow: 0 */
"use strict";
const t = require("tap");
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("path to maindir not resolvable", async function (t) {
await H9Y.config({
"paths": {
"maindir": "fail/",
"patterndir": "./patterns/"
},
"require": ["de"]
}).catch(
function (e) {
t.equal(e, "fail/hyphenEngine.wasm not found.");
t.end();
}
);
});
t.test("path to patternfile not resolvable", async function (t) {
await H9Y.config({
"paths": {
"maindir": "./",
"patterndir": "./patterns/"
},
"require": ["en"]
}).catch(
function (e) {
t.equal(e, "./patterns/en.hpb not found.");
t.end();
}
);
});
t.test("run config with two languages", async function (t) {
const hyphenators = await H9Y.config({"require": ["de", "en"]});
t.test("get the hyphenator function for a language", async function (t) {
await hyphenators.get("en").catch(
function (e) {
t.equal(e.slice(-27), "/patterns/en.hpb not found.");
}
);
t.end();
});
});
t.test("incomplete setup (forget require)", async function (t) {
const laHyphenator = await H9Y.config({});
t.test("get empty map", function (t) {
t.equal(laHyphenator.size, 0);
t.end();
});
t.end();
});
t.test("make hyphenEngine fail", async function (t) {
const laHyphenator = await H9Y.config({"require": ["la"]});
t.test("hyphenate one word", function (t) {
t.equal(laHyphenator("Helvetii"), "Helvetii");
t.end();
});
t.end();
});
t.test("fail when word is to long", async function (t) {
const nlHyphenator = await H9Y.config({"require": ["nl"]});
t.test("hyphenate one word", function (t) {
t.equal(nlHyphenator("Kindercarnavalsoptochtvoorbereidingswerkzaamhedenplankindercarnavals"), "Kindercarnavalsoptochtvoorbereidingswerkzaamhedenplankindercarnavals");
t.end();
});
t.end();
});
@@ -0,0 +1,70 @@
/* eslint-env node */
/* eslint global-require: 0, func-names: 0, no-shadow: 0 */
"use strict";
const t = require("tap");
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("set Event", async function (t) {
await H9Y.config({
"handleEvent": {
/**
* Prevents default event
* @param {Object} e Event
* @returns {undefined}
*/
"error": function (e) {
e.preventDefault();
}
},
"require": ["de"]
});
t.end();
});
t.test("set unknown event", async function (t) {
await H9Y.config({
"handleEvent": {
/**
* Prevents default event
* @param {Object} e Event
* @returns {undefined}
*/
"fantasy": function (e) {
e.preventDefault();
}
},
"require": ["de"]
});
t.end();
});
t.test("try to overwrite noncancellable event", async function (t) {
await H9Y.config({
"handleEvent": {
/**
* Prevents default event
* @param {Object} e Event
* @returns {undefined}
*/
"hpbLoaded": function (e) {
e.preventDefault();
}
},
"require": ["de"]
});
t.end();
});
@@ -0,0 +1,40 @@
/* eslint-env node */
/* eslint global-require: 0, func-names: 0, no-shadow: 0 */
"use strict";
const t = require("tap");
let H9Y = null;
t.beforeEach(function setup(done) {
H9Y = require("../hyphenopoly.module");
done();
});
t.afterEach(function tearDown(done) {
H9Y = null;
delete require.cache[require.resolve("../hyphenopoly.module")];
done();
});
t.test("run config with one language", async function (t) {
const deHyphenator = await H9Y.config({
"loader": "https",
"paths": {
"maindir": "https://unpkg.com/hyphenopoly@3.1.0/",
"patterndir": "https://unpkg.com/hyphenopoly@3.1.0/patterns/"
},
"require": ["de"]
});
t.test("return a function", function (t) {
t.equal(typeof deHyphenator, "function", typeof deHyphenator);
t.end();
});
t.test("hyphenate one word", function (t) {
t.equal(deHyphenator("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator("Silbentrennung"));
t.end();
});
t.test("hyphenate two words", function (t) {
t.equal(deHyphenator("Silbentrennung Algorithmus"), "Sil\u00ADben\u00ADtren\u00ADnung Al\u00ADgo\u00ADrith\u00ADmus", deHyphenator("Silbentrennung Algorithmus"));
t.end();
});
t.end();
});