chore(developer): boost code coverage 🙀

- delete a file which is unused - ordr
- delete a file that was moved to common/web/types - pattern-parser
- update other lines to increase coverage

#7377
This commit is contained in:
Steven R. Loomis 2023-06-07 14:14:41 -05:00
parent e5d7b3f835
commit c4e050e1f9
4 changed files with 2 additions and 164 deletions

View file

@ -159,6 +159,7 @@ export class LdmlKeyboardCompiler {
Object.keys(constants.section).forEach((sectstr : string) => {
const sectid : SectionIdent = constants.section[<SectionIdent>sectstr];
if (dependencies.has(sectid)) {
/* istanbul ignore if */
if (!kmx.kmxplus[sectid]) {
throw new Error(`Internal error: section ${section.id} depends on uninitialized dependency ${sectid}`);
}

View file

@ -1,47 +0,0 @@
// import { constants } from "@keymanapp/ldml-keyboard-constants";
// import { KMXPlus, LDMLKeyboard } from '@keymanapp/common-types';
// import { SectionCompiler } from "./section-compiler.js";
// import DependencySections = KMXPlus.DependencySections;
// // import Ordr = KMXPlus.Ordr;
// // import OrdrItem = KMXPlus.OrdrItem;
// import LKReorder = LDMLKeyboard.LKReorder;
// import LKReorders = LDMLKeyboard.LKReorders;
// export class OrdrCompiler extends SectionCompiler {
// public get id() {
// // return constants.section.ordr;
// return null;
// }
// public validate(): boolean {
// let valid = true;
// // TODO-LDML: linting here should check for identical before+from, but this involves a double-parse which is ugly
// // TODO-LDML: unicodesets means that either we fully parse them and verify conflicting rules or the linting is imperfect
// return valid;
// }
// private compileReorder(sections: DependencySections, reorder: LKReorder): OrdrItem {
// let result = new OrdrItem();
// result.elements = sections.elem.allocElementString(sections.strs, reorder.from, reorder.order, reorder.tertiary, reorder.tertiary_base, reorder.prebase);
// result.before = sections.elem.allocElementString(sections.strs, reorder.before);
// return result;
// }
// private compileReorders(sections: DependencySections, reorders: LKReorders): Ordr {
// let result = new Ordr();
// if(reorders?.reorder) {
// for(let reorder of reorders.reorder) {
// result.items.push(this.compileReorder(sections, reorder));
// }
// }
// return result;
// }
// public compile(sections: DependencySections): Ordr {
// return this.compileReorders(sections, this.keyboard.reorders);
// }
// }

View file

@ -1,116 +0,0 @@
/**
* Utilities for transform and marker processing
*/
/**
* Helper function for extracting matched items
* @param str input string
* @param match global RegEx to use
* @returns array of matched values
*/
function matchArray(str: string, match: RegExp) : string[] {
const refs = (str || '').matchAll(match);
return Array.from(refs).map(r => r[1]);
}
/**
* Class for helping with markers
*/
export class MarkerParser {
/**
* A marker id has the same constraint as a key id. TODO-LDML: Needs to be reflected in the spec
*/
public static readonly ID = /^[0-9A-Za-z_]{1,32}$/;
/**
* Special marker reference referring to any marker
*/
public static readonly ANY_MARKER = '\\m{.}';
/**
* id of the 'any' marker
*/
public static readonly ANY_MARKER_ID = '.';
/**
* Pattern for matching a marker reference, OR the special marker \m{.}
*/
public static readonly REFERENCE = /\\m{([0-9A-Za-z_]{1,32}|\.)}/g;
/**
* parse a string into marker references
* @param str input string such as "\m{a} … \m{.}"
* @returns `[]` or an array of all markers referenced
*/
public static allReferences(str: string): string[] {
return matchArray(str, this.REFERENCE);
}
}
/**
* Class for helping with markers
*/
export class VariableParser {
/**
* A marker id has the same constraint as a key id. TODO-LDML: Needs to be reflected in the spec
*/
public static readonly ID = /^[0-9A-Za-z_]{1,32}$/;
/**
* Pattern for matching a string reference `$(str)`
*/
public static readonly STRING_REFERENCE = /\${([0-9A-Za-z_]{1,32})}/g;
/**
* Pattern for matching a set reference `$[set]`
*/
public static readonly SET_REFERENCE = /\$\[([0-9A-Za-z_]{1,32})\]/g;
/**
* Pattern for matching a capture set reference `($[set])`
*/
public static readonly CAPTURE_SET_REFERENCE = /\(\$\[([0-9A-Za-z_]{1,32})\]\)/g;
/**
* `$[1:variable]`
* This regex matches the whole string.
*/
public static readonly MAPPED_SET_REFERENCE = /^\$\[1:([0-9A-Za-z_]{1,32})\]$/;
/**
* parse a string into references
* @param str input string
* @returns `[]` or an array of all string references referenced
*/
public static allStringReferences(str: string): string[] {
return matchArray(str, this.STRING_REFERENCE);
}
/**
* parse a string into references
* @param str input string
* @returns `[]` or an array of all string references referenced
*/
public static allSetReferences(str: string): string[] {
return matchArray(str, this.SET_REFERENCE);
}
/**
* parse a string into references
* @param str input string
* @returns `[]` or an array of all string references referenced
*/
public static allCaptureSetReferences(str: string): string[] {
return matchArray(str, this.CAPTURE_SET_REFERENCE);
}
/**
* Split an input string into a proper set
* @param str input string
* @returns
*/
public static setSplitter(str: string): string[] {
return str.trim().split(/\s+/);
}
}

View file

@ -6,7 +6,7 @@ import * as path from 'path';
import { fileURLToPath } from 'url';
import { SectionCompiler } from '../../src/compiler/section-compiler.js';
import { KMXPlus, LDMLKeyboardXMLSourceFileReader, VisualKeyboard, CompilerEvent, LDMLKeyboardTestDataXMLSourceFile, compilerEventFormat, LDMLKeyboard } from '@keymanapp/common-types';
import { LdmlKeyboardCompiler } from '../../src/compiler/compiler.js';
import { LdmlKeyboardCompiler } from '../../src/main.js'; // make sure main.js compiles
import { assert } from 'chai';
import { KMXPlusMetadataCompiler } from '../../src/compiler/metadata-compiler.js';
import { CompilerOptions } from '../../src/compiler/compiler-options.js';