mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-24 00:27:40 +00:00
Test compiling with an explicit word breaker property.
This commit is contained in:
parent
1514af710a
commit
0d3fc7bbf6
3 changed files with 6 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
const source: LexicalModelSource = {
|
||||
format: 'trie-1.0',
|
||||
sources: ['wordlist.tsv'],
|
||||
wordBreaker: 'default',
|
||||
};
|
||||
export default source;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export function compileModelSourceCode(code: string) {
|
|||
|
||||
let module: ModuleType | null = null;
|
||||
try {
|
||||
module = new Function('LMLayerWorker', 'models', code) as ModuleType;
|
||||
module = new Function('LMLayerWorker', 'models', 'wordBreakers', code) as ModuleType;
|
||||
} catch (err) {
|
||||
if (err instanceof SyntaxError) {
|
||||
hasSyntaxError = true;
|
||||
|
|
@ -88,7 +88,7 @@ export function compileModelSourceCode(code: string) {
|
|||
});
|
||||
|
||||
try {
|
||||
module(fakeLMLayerWorker, modelsNamespace);
|
||||
module(fakeLMLayerWorker, modelsNamespace, {});
|
||||
} catch (err) {
|
||||
error = err;
|
||||
}
|
||||
|
|
@ -98,8 +98,9 @@ export function compileModelSourceCode(code: string) {
|
|||
};
|
||||
}
|
||||
|
||||
type ModuleType = (a: LMLayerWorker, b: ModelsNamespace) => any;
|
||||
type ModuleType = (a: LMLayerWorker, b: ModelsNamespace, c: WordBreakersNamespace) => any;
|
||||
interface LMLayerWorker {
|
||||
loadModel(model: object): void;
|
||||
}
|
||||
type ModelsNamespace = object;
|
||||
type WordBreakersNamespace = object;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ describe('compileModel', function () {
|
|||
let compilation = r as CompilationResult;
|
||||
|
||||
assert.isFalse(compilation.hasSyntaxError);
|
||||
assert.isNull(compilation.error);
|
||||
assert.equal(compilation.modelConstructorName, 'TrieModel');
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue