feat(developer): create our own test.keylayout and use it in tests

This commit is contained in:
Sabine 2025-04-16 14:07:28 +02:00
parent 60f588e996
commit ca3697b7c2
3 changed files with 1042 additions and 250 deletions

View file

@ -21,7 +21,7 @@ export class KeylayoutToKmnConverter {
static readonly INPUT_FILE_EXTENSION = '.keylayout';
static readonly OUTPUT_FILE_EXTENSION = '.kmn';
static readonly USED_KEYS_COUNT = 51;
static readonly USED_KEYS_COUNT = 50; // we use key Nr 0 (A) -> key Nr 49 (Space)
static readonly MAX_CTRL_CHARACTER = 32;
static readonly SKIP_COMMENTED_LINES = false;
static readonly KMC_CONVERT_VERSION = "0.1";

View file

@ -0,0 +1,589 @@
<?xml version="1.1" encoding="UTF-8"?>
<!DOCTYPE keyboard SYSTEM "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--
Data generated April 15 2025
Generated by S. Schmitt
-->
<keyboard group="126" id="-1272" name="Test" maxout="1">
<layouts>
<layout first="0" last="0" mapSet="138" modifiers="30"/>
</layouts>
<modifierMap id="30" defaultIndex="0">
<keyMapSelect mapIndex="0">
<modifier keys=""/>
<modifier keys="shift? caps? "/>
</keyMapSelect>
<keyMapSelect mapIndex="1">
<modifier keys="caps"/>
</keyMapSelect>
<keyMapSelect mapIndex="2">
<modifier keys="shift? leftShift caps? "/>
<modifier keys="anyShift caps?"/>
<modifier keys="shift leftShift caps "/>
<modifier keys="shift? rightShift caps? "/>
</keyMapSelect>
<keyMapSelect mapIndex="3">
<modifier keys="anyShift? anyOption caps? anyControl"/>
<modifier keys="anyShift? anyOption? caps? anyControl"/>
</keyMapSelect>
<keyMapSelect mapIndex="4">
<modifier keys="anyShift caps? anyOption ?"/>
</keyMapSelect>
<keyMapSelect mapIndex="5">
<modifier keys="anyOption"/>
<modifier keys="caps"/>
</keyMapSelect>
<keyMapSelect mapIndex="6">
<modifier keys="anyOption "/>
</keyMapSelect>
<keyMapSelect mapIndex="7">
<modifier keys="caps anyOption ?"/>
</keyMapSelect>
</modifierMap>
<keyMapSet id="ANSI">
<keyMap index="0">
<key code="0" action="A_9"/>
<key code="1" output="s"/>
<key code="2" output="d"/>
<key code="3" output="f"/>
<key code="4" output="h"/>
<key code="5" output="g"/>
<key code="6" output="z"/>
<key code="7" output="x"/>
<key code="8" output="c"/>
<key code="9" output="v"/>
<key code="10" output="\"/>
<key code="11" output="b"/>
<key code="12" output="q"/>
<key code="13" output="w"/>
<key code="14" action="A_10"/>
<key code="15" output="r"/>
<key code="16" action="A_15"/>
<key code="17" output="t"/>
<key code="18" output="1"/>
<key code="19" output="2"/>
<key code="20" output="3"/>
<key code="21" output="4"/>
<key code="22" output="6"/>
<key code="23" output="5"/>
<key code="24" action="A_18"/>
<key code="25" output="9"/>
<key code="26" output="7"/>
<key code="27" output="&#x0027;"/>
<key code="28" output="8"/>
<key code="29" output="0"/>
<key code="30" output="+"/>
<key code="31" action="A_13"/>
<key code="32" action="A_14"/>
<key code="33" output="è"/>
<key code="34" action="A_11"/>
<key code="35" output="p"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="l"/>
<key code="38" output="j"/>
<key code="39" output="à"/>
<key code="40" output="k"/>
<key code="41" output="ò"/>
<key code="42" output="ù"/>
<key code="43" output=","/>
<key code="44" output="-"/>
<key code="45" action="A_12"/>
<key code="46" output="m"/>
<key code="47" output="."/>
<key code="48" output="&#x0009;"/>
<key code="49" action="A_0"/>
</keyMap>
<keyMap index="1">
<key code="0" action="A_1"/>
<key code="1" output="S"/>
<key code="2" output="D"/>
<key code="3" output="F"/>
<key code="4" output="@"/>
<key code="5" output="G"/>
<key code="6" output="Z"/>
<key code="7" output="X"/>
<key code="8" output="C"/>
<key code="9" output="V"/>
<key code="10" output="\"/>
<key code="11" output="B"/>
<key code="12" output="Q"/>
<key code="13" output="W"/>
<key code="14" action="A_2"/>
<key code="15" output="R"/>
<key code="16" action="A_7"/>
<key code="17" output="T"/>
<key code="18" output="1"/>
<key code="19" output="2"/>
<key code="20" output="3"/>
<key code="21" output="4"/>
<key code="22" output="6"/>
<key code="23" output="5"/>
<key code="24" output="ì"/>
<key code="25" output="9"/>
<key code="26" output="7"/>
<key code="27" output="&#x0027;"/>
<key code="28" output="8"/>
<key code="29" output="0"/>
<key code="30" output="+"/>
<key code="31" action="A_5"/>
<key code="32" action="A_6"/>
<key code="33" output="è"/>
<key code="34" action="A_3"/>
<key code="35" output="P"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="L"/>
<key code="38" output="J"/>
<key code="39" output="à"/>
<key code="40" output="K"/>
<key code="41" output="ò"/>
<key code="42" output="ù"/>
<key code="43" output=","/>
<key code="44" output="-"/>
<key code="45" action="A_4"/>
<key code="46" output="M"/>
<key code="47" output="."/>
<key code="48" output="&#x0009;"/>
<key code="49" action="A_0"/>
</keyMap>
<keyMap index="2">
<key code="0" action="A_1"/>
<key code="1" output="S"/>
<key code="2" output="D"/>
<key code="3" output="F"/>
<key code="4" output="H"/>
<key code="5" output="G"/>
<key code="6" output="Z"/>
<key code="7" output="X"/>
<key code="8" output="C"/>
<key code="9" output="V"/>
<key code="10" output="|"/>
<key code="11" output="B"/>
<key code="12" output="Q"/>
<key code="13" output="W"/>
<key code="14" action="A_2"/>
<key code="15" output="R"/>
<key code="16" action="A_7"/>
<key code="17" output="T"/>
<key code="18" output="!"/>
<key code="19" output="&#x0022;"/>
<key code="20" output="£"/>
<key code="21" output="$"/>
<key code="22" output="&#x0026;"/>
<key code="23" output="%"/>
<key code="24" output="^"/>
<key code="25" output=")"/>
<key code="26" output="/"/>
<key code="27" output="?"/>
<key code="28" output="("/>
<key code="29" output="="/>
<key code="30" output="*"/>
<key code="31" action="A_5"/>
<key code="32" action="A_6"/>
<key code="33" output="é"/>
<key code="34" action="A_3"/>
<key code="35" output="P"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="L"/>
<key code="38" output="J"/>
<key code="39" output="°"/>
<key code="40" output="K"/>
<key code="41" output="ç"/>
<key code="42" output="§"/>
<key code="43" output=";"/>
<key code="44" output="_"/>
<key code="45" action="A_4"/>
<key code="46" output="M"/>
<key code="47" output=":"/>
<key code="48" output="&#x0009;"/>
<key code="49" action="A_0"/>
</keyMap>
<keyMap index="3">
<key code="0" output="U+1F600"/>
<key code="1" output="&#x1F601;"/>
<key code="2" output="&#x1234;"/>
<key code="3" output="ሴ"/>
<key code="4" output="😎"/>
<key code="5" output="&#x0007;"/>
<key code="6" output="&#x0017;"/>
<key code="7" output="&#x0018;"/>
<key code="8" output="&#x0003;"/>
<key code="9" output="&#x0016;"/>
<key code="10" output="&#x001C;"/>
<key code="11" output="&#x0002;"/>
<key code="12" output="&#x0011;"/>
<key code="13" output="&#x001A;"/>
<key code="14" output="&#x0005;"/>
<key code="15" output="&#x0012;"/>
<key code="16" output="&#x0019;"/>
<key code="17" output="&#x0014;"/>
<key code="18" output="1"/>
<key code="19" output="2"/>
<key code="20" output="3"/>
<key code="21" output="4"/>
<key code="22" output="6"/>
<key code="23" output="5"/>
<key code="24" output="="/>
<key code="25" output="9"/>
<key code="26" output="7"/>
<key code="27" output="&#x001F;"/>
<key code="28" output="8"/>
<key code="29" output="0"/>
<key code="30" output="&#x001D;"/>
<key code="31" output="&#x000F;"/>
<key code="32" output="&#x0015;"/>
<key code="33" output="&#x001E;"/>
<key code="34" output="&#x0009;"/>
<key code="35" output="&#x0010;"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="&#x000C;"/>
<key code="38" output="&#x000A;"/>
<key code="39" output="%"/>
<key code="40" output="&#x000B;"/>
<key code="41" output="&#x000D;"/>
<key code="42" output="°"/>
<key code="43" output="."/>
<key code="44" output="!"/>
<key code="45" output="&#x000E;"/>
<key code="46" output="?"/>
<key code="47" output="/"/>
<key code="48" output="&#x0009;"/>
<key code="49" action="A_0"/>
</keyMap>
<keyMap index="4">
<key code="0" output="Å"/>
<key code="1" output="¯"/>
<key code="2" output="˘"/>
<key code="3" output="˙"/>
<key code="4" output="¸"/>
<key code="5" output="˚"/>
<key code="6" action="A_0"/>
<key code="7" output="‡"/>
<key code="8" output="Á"/>
<key code="9" output="É"/>
<key code="10" output="ı"/>
<key code="11" output="Í"/>
<key code="12" output=""/>
<key code="13" output="À"/>
<key code="14" output="È"/>
<key code="15" output="Ì"/>
<key code="16" output="Æ"/>
<key code="17" output="Ò"/>
<key code="18" output="»"/>
<key code="19" output="”"/>
<key code="20" output=""/>
<key code="21" output="¢"/>
<key code="22" output=""/>
<key code="23" output="‰"/>
<key code="24" output="±"/>
<key code="25" action="A_0"/>
<key code="26" output=""/>
<key code="27" output="¿"/>
<key code="28" output=""/>
<key code="29" output="≈"/>
<key code="30" output="}"/>
<key code="31" output="Ø"/>
<key code="32" output="Ù"/>
<key code="33" output="{"/>
<key code="34" output="Œ"/>
<key code="35" output="∏"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="ˇ"/>
<key code="38" output="˝"/>
<key code="39" output="∞"/>
<key code="40" output="˛"/>
<key code="41" output="Ç"/>
<key code="42" output="◊"/>
<key code="43" action="A_0"/>
<key code="44" output="—"/>
<key code="45" output="Ó"/>
<key code="46" output="Ú"/>
<key code="47" output="·"/>
<key code="48" output="&#x0009;"/>
<key code="49" output=" "/>
</keyMap>
<keyMap index="5">
<key code="0" output="å"/>
<key code="1" output="ß"/>
<key code="2" output="∂"/>
<key code="3" output="ƒ"/>
<key code="4" output="∆"/>
<key code="5" output="∞"/>
<key code="6" output="∑"/>
<key code="7" output="†"/>
<key code="8" output="©"/>
<key code="9" output="√"/>
<key code="10" output="`"/>
<key code="11" output="∫"/>
<key code="12" output="„"/>
<key code="13" output="Ω"/>
<key code="14" output="€"/>
<key code="15" output="®"/>
<key code="16" output="æ"/>
<key code="17" output="™"/>
<key code="18" output="«"/>
<key code="19" output="“"/>
<key code="20" output=""/>
<key code="21" output="¥"/>
<key code="22" output=""/>
<key code="23" output="~"/>
<key code="24" action="A_18"/>
<key code="25" action="A_8"/>
<key code="26" output="÷"/>
<key code="27" output="¡"/>
<key code="28" action="A_17"/>
<key code="29" output="≠"/>
<key code="30" output="]"/>
<key code="31" output="ø"/>
<key code="32" action="A_16"/>
<key code="33" output="["/>
<key code="34" output="œ"/>
<key code="35" output="π"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="¬"/>
<key code="38" output="ª"/>
<key code="39" output="#"/>
<key code="40" output="º"/>
<key code="41" output="@"/>
<key code="42" output="¶"/>
<key code="43" output="…"/>
<key code="44" output=""/>
<key code="45" action="A_19"/>
<key code="46" output="µ"/>
<key code="47" output="•"/>
<key code="48" output="&#x0009;"/>
<key code="49" output=" "/>
</keyMap>
<keyMap index="6">
<key code="0" output="å"/>
<key code="1" output="ß"/>
<key code="2" output="∂"/>
<key code="3" output="ƒ"/>
<key code="4" output="ẞ"/>
<key code="5" output="∞"/>
<key code="6" output="∑"/>
<key code="7" output="†"/>
<key code="8" output="©"/>
<key code="9" output="√"/>
<key code="10" output="`"/>
<key code="11" output="∫"/>
<key code="12" output="„"/>
<key code="13" output="Ω"/>
<key code="14" output="€"/>
<key code="15" output="®"/>
<key code="16" output="æ"/>
<key code="17" output="™"/>
<key code="18" output="«"/>
<key code="19" output="“"/>
<key code="20" output=""/>
<key code="21" output="¥"/>
<key code="22" output=""/>
<key code="23" output="~"/>
<key code="24" output="ˆ"/>
<key code="25" output="`"/>
<key code="26" output="÷"/>
<key code="27" output="¡"/>
<key code="28" output="´"/>
<key code="29" output="≠"/>
<key code="30" output="]"/>
<key code="31" output="ø"/>
<key code="32" output="¨"/>
<key code="33" output="["/>
<key code="34" output="œ"/>
<key code="35" output="π"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="¬"/>
<key code="38" output="ª"/>
<key code="39" output="#"/>
<key code="40" output="º"/>
<key code="41" output="@"/>
<key code="42" output="¶"/>
<key code="43" output="…"/>
<key code="44" output=""/>
<key code="45" output="˜"/>
<key code="46" output="µ"/>
<key code="47" output="•"/>
<key code="48" output="&#x0009;"/>
<key code="49" output=" "/>
<key code="50" output="≤"/>
</keyMap>
<keyMap index="7">
<key code="0" output="Å"/>
<key code="1" output="ß"/>
<key code="2" output="∂"/>
<key code="3" output="ƒ"/>
<key code="4" output="€"/>
<key code="5" output="∞"/>
<key code="6" output="∑"/>
<key code="7" output="†"/>
<key code="8" output="©"/>
<key code="9" output="√"/>
<key code="10" output="`"/>
<key code="11" output="∫"/>
<key code="12" output="„"/>
<key code="13" output="Ω"/>
<key code="14" output="€"/>
<key code="15" output="®"/>
<key code="16" output="Æ"/>
<key code="17" output="™"/>
<key code="18" output="«"/>
<key code="19" output="“"/>
<key code="20" output=""/>
<key code="21" output="¥"/>
<key code="22" output=""/>
<key code="23" output="~"/>
<key code="24" output="ˆ"/>
<key code="25" output="`"/>
<key code="26" output="÷"/>
<key code="27" output="¡"/>
<key code="28" output="´"/>
<key code="29" output="≠"/>
<key code="30" output="]"/>
<key code="31" output="Ø"/>
<key code="32" output="¨"/>
<key code="33" output="["/>
<key code="34" output="Œ"/>
<key code="35" output="∏"/>
<key code="36" output="&#x000D;"/>
<key code="37" output="¬"/>
<key code="38" output="ª"/>
<key code="39" output="#"/>
<key code="40" output="º"/>
<key code="41" output="@"/>
<key code="42" output="¶"/>
<key code="43" output="…"/>
<key code="44" output=""/>
<key code="45" output="˜"/>
<key code="46" output="µ"/>
<key code="47" output="•"/>
<key code="48" output="&#x0009;"/>
<key code="49" output=" "/>
<key code="50" output="≤"/>
</keyMap>
</keyMapSet>
<actions>
<action id="A_0">
<when state="none" output=" "/>
<when state="1" output="ˆ"/>
<when state="2" output="`"/>
<when state="3" output="´"/>
<when state="4" output="¨"/>
<when state="5" output="˜"/>
</action>
<action id="A_1">
<when state="none" output="A"/>
<when state="1" output="Â"/>
<when state="2" output="À"/>
<when state="3" output="Á"/>
<when state="4" output="Ä"/>
<when state="5" output="Ã"/>
</action>
<action id="A_10">
<when state="none" output="e"/>
<when state="1" output="ê"/>
<when state="2" output="è"/>
<when state="3" output="é"/>
<when state="4" output="ë"/>
</action>
<action id="A_11">
<when state="none" output="i"/>
<when state="1" output="î"/>
<when state="2" output="ì"/>
<when state="3" output="í"/>
<when state="4" output="ï"/>
</action>
<action id="A_12">
<when state="none" output="n"/>
<when state="5" output="ñ"/>
</action>
<action id="A_13">
<when state="none" output="o"/>
<when state="1" output="ô"/>
<when state="2" output="ò"/>
<when state="3" output="ó"/>
<when state="4" output="ö"/>
<when state="5" output="õ"/>
</action>
<action id="A_14">
<when state="none" output="u"/>
<when state="1" output="û"/>
<when state="2" output="ù"/>
<when state="3" output="ú"/>
<when state="4" output="ü"/>
</action>
<action id="A_15">
<when state="none" output="y"/>
<when state="4" output="ÿ"/>
</action>
<action id="A_16">
<when state="none" next="4"/>
<when state="3" next="1"/>
</action>
<action id="A_17">
<when state="none" next="3"/>
</action>
<action id="A_18">
<when state="none" next="1"/>
</action>
<action id="A_19">
<when state="none" next="5"/>
</action>
<action id="A_2">
<when state="none" output="E"/>
<when state="1" output="Ê"/>
<when state="2" output="È"/>
<when state="3" output="É"/>
<when state="4" output="Ë"/>
</action>
<action id="A_3">
<when state="none" output="I"/>
<when state="1" output="Î"/>
<when state="2" output="Ì"/>
<when state="3" output="Í"/>
<when state="4" output="Ï"/>
</action>
<action id="A_4">
<when state="none" output="N"/>
<when state="5" output="Ñ"/>
</action>
<action id="A_5">
<when state="none" output="O"/>
<when state="1" output="Ô"/>
<when state="2" output="Ò"/>
<when state="3" output="Ó"/>
<when state="4" output="Ö"/>
<when state="5" output="Õ"/>
</action>
<action id="A_6">
<when state="none" output="U"/>
<when state="1" output="Û"/>
<when state="2" output="Ù"/>
<when state="3" output="Ú"/>
<when state="4" output="Ü"/>
</action>
<action id="A_7">
<when state="none" output="Y"/>
<when state="4" output="Ÿ"/>
</action>
<action id="A_8">
<when state="none" next="2"/>
</action>
<action id="A_9">
<when state="none" output="A"/>
<when state="1" output="â"/>
<when state="2" output="à"/>
<when state="3" output="á"/>
<when state="4" output="ä"/>
<when state="5" output="ã"/>
</action>
</actions>
<terminators>
<when state="1" output="ˆ"/>
<when state="2" output="`"/>
<when state="3" output="´"/>
<when state="4" output="¨"/>
<when state="5" output="˜"/>
</terminators>
</keyboard>

View file

@ -27,11 +27,11 @@ describe('KeylayoutToKmnConverter', function () {
});
it('run() should throw on null input file name and empty output file name', async function () {
await NodeAssert.rejects(async () => sut.run(null, ""));
await NodeAssert.rejects(async () => sut.run(null, ''));
});
it('run() should throw on null input file name and unknown output file name', async function () {
await NodeAssert.rejects(async () => sut.run(null, "X"));
await NodeAssert.rejects(async () => sut.run(null, 'X'));
});
it('run() should throw on unavailable input file name and null output file name', async function () {
@ -40,17 +40,17 @@ describe('KeylayoutToKmnConverter', function () {
});
it('run() should return on correct input file name and empty output file name ', async function () {
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
await NodeAssert.doesNotReject(async () => sut.run(inputFilename, ""));
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
await NodeAssert.doesNotReject(async () => sut.run(inputFilename, ''));
});
it('run() should return on correct input file name and null output file name', async function () {
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
await NodeAssert.doesNotReject(async () => sut.run(inputFilename, null));
});
it('run() should return on correct input file name and given output file name ', async function () {
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const outputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/OutputName.kmn');
await NodeAssert.doesNotReject(async () => sut.run(inputFilename, outputFilename));
});
@ -62,16 +62,16 @@ describe('KeylayoutToKmnConverter', function () {
});
it('run() return on correct input file extention and unsupperted output file extention', async function () {
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const outputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/OutputXName.B');
await NodeAssert.doesNotReject(async () => sut.run(inputFilename, outputFilename));
});
});
describe("convert() ", function () {
describe('convert() ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
const converted = sut.convert(read);
@ -116,7 +116,7 @@ describe('KeylayoutToKmnConverter', function () {
const converted_rule = sut.convert({
keylayout_filename: '',
arrayOf_Modifiers: [],
arrayOf_Rules: [["C0", "", "", 0, 0, "", "", 0, 0, "CAPS", "K_A", "A"]]
arrayOf_Rules: [['C0', '', '', 0, 0, '', '', 0, 0, 'CAPS', 'K_A', 'A']]
});
assert.isTrue((converted_rule.keylayout_filename === ''
&& converted_rule.arrayOf_Modifiers.length === 0
@ -162,22 +162,22 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("isAcceptableKeymanModifier ", function () {
describe('isAcceptableKeymanModifier ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
[
["NCAPS", true],
["NxCAPS", false],
["SHIFT", true],
["ALT", true],
["RALT", true],
["LALT", true],
["CTRL", true],
["LCTRL", true],
["RCTRL", true],
["LCTRL CAPS", true],
["LCTRL X", false],
["", true],
['NCAPS', true],
['NxCAPS', false],
['SHIFT', true],
['ALT', true],
['RALT', true],
['LALT', true],
['CTRL', true],
['LCTRL', true],
['RCTRL', true],
['LCTRL CAPS', true],
['LCTRL X', false],
['', true],
[null, false],
].forEach(function (values) {
it(("isAcceptableKeymanModifier(" + values[0] + ")").padEnd(38, " ") + ' should return ' + values[1], async function () {
@ -187,19 +187,19 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("map_UkeleleKC_To_VK ", function () {
describe('map_UkeleleKC_To_VK ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
[
[0x00, "K_A"],
[0x31, "K_SPACE"],
[0x18, "K_EQUAL"],
[0x10, "K_Y"],
[0x18, "K_EQUAL"],
[0x21, "K_LBRKT"],
[0x999, ""],
[-1, ""],
[null, ""],
[0x00, 'K_A'],
[0x31, 'K_SPACE'],
[0x18, 'K_EQUAL'],
[0x10, 'K_Y'],
[0x18, 'K_EQUAL'],
[0x21, 'K_LBRKT'],
[0x999, ''],
[-1, ''],
[null, ''],
].forEach(function (values) {
it(("map_UkeleleKC_To_VK(" + values[0] + ")").padEnd(26, " ") + "should return " + "'" + values[1] + "'", async function () {
const result = sut.map_UkeleleKC_To_VK(values[0] as number);
@ -208,7 +208,7 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("checkIfCapsIsUsed ", function () {
describe('checkIfCapsIsUsed ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
[
@ -228,19 +228,24 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_Modifier_array__From__KeyModifier_array ", function () {
describe('get_Modifier_array__From__KeyModifier_array ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
const converted = sut.convert(read);
[[[['0', 0]], [['', 'shift? caps? ']]],
[[['0', 1]], [['anyShift caps?', 'shift? rightShift caps? ', 'shift? leftShift caps? ', 'shift leftShift caps ']]],
[[['0', 999]], [null]],
[[['999',]], [null]],
[[['0', -999]], [null]],
[[['0']], [null]],
[
[[['0', 0]], [['', 'shift? caps? ']]],
// Italian: [[['0', 1]], [['anyShift caps?', 'shift? rightShift caps? ', 'shift? leftShift caps? ', 'shift leftShift caps ']]],
[[['0', 2]], [['shift? leftShift caps? ', 'anyShift caps?', 'shift leftShift caps ', 'shift? rightShift caps? ']]],
[[['0', 999]], [null]],
[[['999',]], [null]],
[[['0', -999]], [null]],
[[['0']], [null]],
].forEach(function (values) {
it((values[1][0] !== null) ?
("get_Modifier_array__From__KeyModifier_array(['" + values[0][0][0] + "', '" + values[0][0][1] + "'])").padEnd(68, " ") + " should return ['" + values[1][0][0] + "', '" + values[1][0][1] + "']" :
@ -261,24 +266,28 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_KeyModifier_array__From__ActionID ", function () {
describe('get_KeyModifier_array__From__ActionID ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
[
["a16", [['32', 3]]],
["a19", [['45', 3]]],
["a18", [['24', 0], ['24', 3]]],
["unknown", []],
// Italian: ['a16', [['32', 3]]],
// Italian: ['a19', [['45', 3]]],
// Italian: ['a18', [['24', 0], ['24', 3]]],
['A_16', [['32', 5]]],
['A_19', [['45', 5]]],
['A_18', [['24', 0], ['24', 5]]],
['unknown', []],
[undefined, []],
[null, []],
[" ", []],
["", []],
[' ', []],
['', []],
].forEach(function (values) {
let outstring = "[ ";
let outstring = '[ ';
for (let i = 0; i < values[1].length; i++) {
outstring = outstring + "[ '" + values[1][i][0] + "', " + values[1][i][1].toString() + "], ";
}
@ -290,25 +299,31 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_ActionID__From__ActionNext ", function () {
describe('get_ActionID__From__ActionNext ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
[
["none", ""],
["a18", ""],
["0", ""],
["1", "a16"],
["2", "a8"],
["3", "a17"],
["", ""],
[" ", ""],
["99", ""],
[null, ""],
[undefined, ""],
["unknown", ""],
['none', ''],
// Italian: ['a18', ''],
['0', ''],
// Italian: ['1', 'a16'],
// Italian: // Italian: ['2', 'a8'],
// Italian: ['3', 'a17'],
['A_18', ''],
['1', 'A_16'],
['2', 'A_8'],
['3', 'A_17'],
['', ''],
[' ', ''],
['99', ''],
[null, ''],
[undefined, ''],
['unknown', ''],
].forEach(function (values) {
it(("get_ActionID__From__ActionNext('" + values[0] + "')").padEnd(49, " ") + ' should return ' + "'" + values[1] + "'", async function () {
const result = sut.get_ActionID__From__ActionNext(read, String(values[0]));
@ -317,23 +332,26 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_ActionIndex__From__ActionId ", function () {
describe('get_ActionIndex__From__ActionId ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
[
["none", 0],
["a16", 8],
["a18", 10],
["a19", 11],
["0", 0],
["", 0],
[" ", 0],
['none', 0],
// Italian: ['a16', 8],
// Italian: ['a18', 10],
// Italian: ['a19', 11],
['A_16', 8],
['A_18', 10],
['A_19', 11],
['0', 0],
['', 0],
[' ', 0],
[null, 0],
[undefined, 0],
["unknown", 0],
['unknown', 0],
].forEach(function (values) {
it(("get_ActionIndex__From__ActionId('" + values[0] + "')").padEnd(50, " ") + ' should return ' + values[1], async function () {
const result = sut.get_ActionIndex__From__ActionId(read, String(values[0]));
@ -342,17 +360,20 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_Output__From__ActionId_None ", function () {
describe('get_Output__From__ActionId_None ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
[["a14", "u"],
["", ""],
[" ", ""],
["a18", undefined],
["unknown", ""],
[
// Italian: ['a14', 'u'],
['A_14', 'u'],
['', ''],
[' ', ''],
// Italian: ['a18', undefined],
['A_18', undefined],
['unknown', ''],
].forEach(function (values) {
it(
("get_Output__From__ActionId_None('" + values[0] + "')").padEnd(56, " ") + ' should return ' + "'" + values[1] + "'", async function () {
@ -361,9 +382,9 @@ describe('KeylayoutToKmnConverter', function () {
});
});
[[null, ""],
[undefined, ""],
[99, ""],
[[null, ''],
[undefined, ''],
[99, ''],
].forEach(function (values) {
it(("get_Output__From__ActionId_None('" + values[0] + "')").padEnd(56, " ") + ' should return ' + values[1], async function () {
const result = sut.get_Output__From__ActionId_None(read, String(values[0]));
@ -372,76 +393,144 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array ", function () {
describe('get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
/*Italian:
const b1_keycode_arr = [
['49', 'K_SPACE', 'a0', '0', 'ˆ'],
['49', 'K_SPACE', 'a0', '1', 'ˆ'],
['49', 'K_SPACE', 'a0', '2', 'ˆ'],
['6', 'K_Z', 'a0', '4', 'ˆ'],
['25', 'K_9', 'a0', '4', 'ˆ'],
['43', 'K_COMMA', 'a0', '4', 'ˆ'],
['49', 'K_SPACE', 'a0', '7', 'ˆ'],
['0', 'K_A', 'a1', '1', 'Â'],
['0', 'K_A', 'a1', '2', 'Â'],
['14', 'K_E', 'a10', '0', 'ê'],
['34', 'K_I', 'a11', '0', 'î'],
['31', 'K_O', 'a13', '0', 'ô'],
['32', 'K_U', 'a14', '0', 'û'],
['14', 'K_E', 'a2', '1', 'Ê'],
['14', 'K_E', 'a2', '2', 'Ê'],
['34', 'K_I', 'a3', '1', 'Î'],
['34', 'K_I', 'a3', '2', 'Î'],
['31', 'K_O', 'a5', '1', 'Ô'],
['31', 'K_O', 'a5', '2', 'Ô'],
['32', 'K_U', 'a6', '1', 'Û'],
['32', 'K_U', 'a6', '2', 'Û'],
['0', 'K_A', 'a9', '0', 'â']
];
const b1_modifierKey_arr = [
['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ'],
['K_SPACE', 'a0', '1', 'NCAPS SHIFT', 'ˆ'],
['K_SPACE', 'a0', '1', 'SHIFT CAPS', 'ˆ'],
['K_SPACE', 'a0', '2', 'CAPS', 'ˆ'],
['K_Z', 'a0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_9', 'a0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_COMMA', 'a0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_SPACE', 'a0', '7', 'NCAPS CTRL', 'ˆ'],
['K_SPACE', 'a0', '7', 'NCAPS RALT CTRL', 'ˆ'],
['K_A', 'a1', '1', 'NCAPS SHIFT', 'Â'],
['K_A', 'a1', '1', 'SHIFT CAPS', 'Â'],
['K_A', 'a1', '2', 'CAPS', 'Â'],
['K_E', 'a10', '0', 'NCAPS', 'ê'],
['K_I', 'a11', '0', 'NCAPS', 'î'],
['K_O', 'a13', '0', 'NCAPS', 'ô'],
['K_U', 'a14', '0', 'NCAPS', 'û'],
['K_E', 'a2', '1', 'NCAPS SHIFT', 'Ê'],
['K_E', 'a2', '1', 'SHIFT CAPS', 'Ê'],
['K_E', 'a2', '2', 'CAPS', 'Ê'],
['K_I', 'a3', '1', 'NCAPS SHIFT', 'Î'],
['K_I', 'a3', '1', 'SHIFT CAPS', 'Î'],
['K_I', 'a3', '2', 'CAPS', 'Î'],
['K_O', 'a5', '1', 'NCAPS SHIFT', 'Ô'],
['K_O', 'a5', '1', 'SHIFT CAPS', 'Ô'],
['K_O', 'a5', '2', 'CAPS', 'Ô'],
['K_U', 'a6', '1', 'NCAPS SHIFT', 'Û'],
['K_U', 'a6', '1', 'SHIFT CAPS', 'Û'],
['K_U', 'a6', '2', 'CAPS', 'Û'],
['K_A', 'a9', '0', 'NCAPS', 'â']
];
[[b1_keycode_arr, b1_modifierKey_arr],
[[['49', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['49', 'K_SPACE', 'a0', '0', '']], [['K_SPACE', 'a0', '0', 'NCAPS', '']]],
[[['49', 'K_SPACE', 'a0', '', 'ˆ']], [['K_SPACE', 'a0', '', 'NCAPS', 'ˆ']]],
[[['49', 'K_SPACE', '', '0', 'ˆ']], [['K_SPACE', '', '0', 'NCAPS', 'ˆ']]],
[[['49', '', 'a0', '0', 'ˆ']], [['', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['', '', '', '', '']], [['', '', '', 'NCAPS', '']]],
*/
const b1_keycode_arr = [
['49', 'K_SPACE', 'a0', '0', 'ˆ'],
['49', 'K_SPACE', 'a0', '1', 'ˆ'],
['49', 'K_SPACE', 'a0', '2', 'ˆ'],
['6', 'K_Z', 'a0', '4', 'ˆ'],
['25', 'K_9', 'a0', '4', 'ˆ'],
['43', 'K_COMMA', 'a0', '4', 'ˆ'],
['49', 'K_SPACE', 'a0', '7', 'ˆ'],
['0', 'K_A', 'a1', '1', 'Â'],
['0', 'K_A', 'a1', '2', 'Â'],
['14', 'K_E', 'a10', '0', 'ê'],
['34', 'K_I', 'a11', '0', 'î'],
['31', 'K_O', 'a13', '0', 'ô'],
['32', 'K_U', 'a14', '0', 'û'],
['14', 'K_E', 'a2', '1', 'Ê'],
['14', 'K_E', 'a2', '2', 'Ê'],
['34', 'K_I', 'a3', '1', 'Î'],
['34', 'K_I', 'a3', '2', 'Î'],
['31', 'K_O', 'a5', '1', 'Ô'],
['31', 'K_O', 'a5', '2', 'Ô'],
['32', 'K_U', 'a6', '1', 'Û'],
['32', 'K_U', 'a6', '2', 'Û'],
['0', 'K_A', 'a9', '0', 'â']
['49', 'K_SPACE', 'A_0', '0', 'ˆ'],
['49', 'K_SPACE', 'A_0', '1', 'ˆ'],
['49', 'K_SPACE', 'A_0', '2', 'ˆ'],
['6', 'K_Z', 'A_0', '4', 'ˆ'],
['25', 'K_9', 'A_0', '4', 'ˆ'],
['43', 'K_COMMA', 'A_0', '4', 'ˆ'],
['49', 'K_SPACE', 'A_0', '3', 'ˆ'],
['0', 'K_A', 'A_1', '2', 'Â'],
['0', 'K_A', 'A_1', '1', 'Â'],
['14', 'K_E', 'A_10', '0', 'ê'],
['34', 'K_I', 'A_11', '0', 'î'],
['31', 'K_O', 'A_13', '0', 'ô'],
['32', 'K_U', 'A_14', '0', 'û'],
['14', 'K_E', 'A_2', '2', 'Ê'],
['14', 'K_E', 'A_2', '1', 'Ê'],
['34', 'K_I', 'A_3', '2', 'Î'],
['34', 'K_I', 'A_3', '1', 'Î'],
['31', 'K_O', 'A_5', '2', 'Ô'],
['31', 'K_O', 'A_5', '1', 'Ô'],
['32', 'K_U', 'A_6', '2', 'Û'],
['32', 'K_U', 'A_6', '1', 'Û'],
['0', 'K_A', 'A_9', '0', 'â']/**/
];
const b1_modifierKey_arr = [
['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ'],
['K_SPACE', 'a0', '1', 'NCAPS SHIFT', 'ˆ'],
['K_SPACE', 'a0', '1', 'SHIFT CAPS', 'ˆ'],
['K_SPACE', 'a0', '2', 'CAPS', 'ˆ'],
['K_Z', 'a0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_9', 'a0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_COMMA', 'a0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_SPACE', 'a0', '7', 'NCAPS CTRL', 'ˆ'],
['K_SPACE', 'a0', '7', 'NCAPS RALT CTRL', 'ˆ'],
['K_A', 'a1', '1', 'NCAPS SHIFT', 'Â'],
['K_A', 'a1', '1', 'SHIFT CAPS', 'Â'],
['K_A', 'a1', '2', 'CAPS', 'Â'],
['K_E', 'a10', '0', 'NCAPS', 'ê'],
['K_I', 'a11', '0', 'NCAPS', 'î'],
['K_O', 'a13', '0', 'NCAPS', 'ô'],
['K_U', 'a14', '0', 'NCAPS', 'û'],
['K_E', 'a2', '1', 'NCAPS SHIFT', 'Ê'],
['K_E', 'a2', '1', 'SHIFT CAPS', 'Ê'],
['K_E', 'a2', '2', 'CAPS', 'Ê'],
['K_I', 'a3', '1', 'NCAPS SHIFT', 'Î'],
['K_I', 'a3', '1', 'SHIFT CAPS', 'Î'],
['K_I', 'a3', '2', 'CAPS', 'Î'],
['K_O', 'a5', '1', 'NCAPS SHIFT', 'Ô'],
['K_O', 'a5', '1', 'SHIFT CAPS', 'Ô'],
['K_O', 'a5', '2', 'CAPS', 'Ô'],
['K_U', 'a6', '1', 'NCAPS SHIFT', 'Û'],
['K_U', 'a6', '1', 'SHIFT CAPS', 'Û'],
['K_U', 'a6', '2', 'CAPS', 'Û'],
['K_A', 'a9', '0', 'NCAPS', 'â']
['K_SPACE', 'A_0', '0', 'NCAPS', 'ˆ'],
['K_SPACE', 'A_0', '1', 'CAPS', 'ˆ'],
['K_SPACE', 'A_0', '2', 'NCAPS SHIFT', 'ˆ'],
['K_SPACE', 'A_0', '2', 'SHIFT CAPS', 'ˆ'],
['K_Z', 'A_0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_9', 'A_0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_COMMA', 'A_0', '4', 'NCAPS SHIFT RALT', 'ˆ'],
['K_SPACE', 'A_0', '3', 'NCAPS RALT CTRL', 'ˆ'],
['K_SPACE', 'A_0', '3', 'NCAPS CTRL', 'ˆ'],
['K_A', 'A_1', '2', 'NCAPS SHIFT', 'Â'],
['K_A', 'A_1', '2', 'SHIFT CAPS', 'Â'],
['K_A', 'A_1', '1', 'CAPS', 'Â'],
['K_E', 'A_10', '0', 'NCAPS', 'ê'],
['K_I', 'A_11', '0', 'NCAPS', 'î'],
['K_O', 'A_13', '0', 'NCAPS', 'ô'],
['K_U', 'A_14', '0', 'NCAPS', 'û'],
['K_E', 'A_2', '2', 'NCAPS SHIFT', 'Ê'],
['K_E', 'A_2', '2', 'SHIFT CAPS', 'Ê'],
['K_E', 'A_2', '1', 'CAPS', 'Ê'],
['K_I', 'A_3', '2', 'NCAPS SHIFT', 'Î'],
['K_I', 'A_3', '2', 'SHIFT CAPS', 'Î'],
['K_I', 'A_3', '1', 'CAPS', 'Î'],
['K_O', 'A_5', '2', 'NCAPS SHIFT', 'Ô'],
['K_O', 'A_5', '2', 'SHIFT CAPS', 'Ô'],
['K_O', 'A_5', '1', 'CAPS', 'Ô'],
['K_U', 'A_6', '2', 'NCAPS SHIFT', 'Û'],
['K_U', 'A_6', '2', 'SHIFT CAPS', 'Û'],
['K_U', 'A_6', '1', 'CAPS', 'Û'],
['K_A', 'A_9', '0', 'NCAPS', 'â']/**/
];
[[b1_keycode_arr, b1_modifierKey_arr],
[[['49', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['49', 'K_SPACE', 'a0', '0', '']], [['K_SPACE', 'a0', '0', 'NCAPS', '']]],
[[['49', 'K_SPACE', 'a0', '', 'ˆ']], [['K_SPACE', 'a0', '', 'NCAPS', 'ˆ']]],
[[['49', 'K_SPACE', 'A_0', '0', 'ˆ']], [['K_SPACE', 'A_0', '0', 'NCAPS', 'ˆ']]],
[[['49', 'K_SPACE', 'A_0', '0', '']], [['K_SPACE', 'A_0', '0', 'NCAPS', '']]],
[[['49', 'K_SPACE', 'A_0', '', 'ˆ']], [['K_SPACE', 'A_0', '', 'NCAPS', 'ˆ']]],
[[['49', 'K_SPACE', '', '0', 'ˆ']], [['K_SPACE', '', '0', 'NCAPS', 'ˆ']]],
[[['49', '', 'a0', '0', 'ˆ']], [['', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', 'NCAPS', 'ˆ']]],
[[['49', '', 'A_0', '0', 'ˆ']], [['', 'A_0', '0', 'NCAPS', 'ˆ']]],
[[['', 'K_SPACE', 'A_0', '0', 'ˆ']], [['K_SPACE', 'A_0', '0', 'NCAPS', 'ˆ']]],
[[['', 'K_SPACE', 'A_0', '0', 'ˆ']], [['K_SPACE', 'A_0', '0', 'NCAPS', 'ˆ']]],
[[['', '', '', '', '']], [['', '', '', 'NCAPS', '']]],
].forEach(function (values) {
@ -449,16 +538,22 @@ describe('KeylayoutToKmnConverter', function () {
const string_in = "get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(['" + "', '" + values[0][0][0] + "', '" + values[0][0][1] + "', '" + values[0][0][2] + "', '" + values[0][0][3] + "', '" + values[0][0][4] + "'])";
const string_out = "['" + "', '" + values[1][0][0] + "', '" + values[1][0][1] + "', '" + values[1][0][2] + "', '" + values[1][0][3] + "', '" + values[1][0][4] + "']";
it((JSON.stringify(values[1]).length > 60) ? 'an array of objects should return an array of objectss' :
it((JSON.stringify(values[1]).length > 60) ? 'an array of objects should return an array of objects' :
string_in.padEnd(74, " ") + ' should return ' + string_out, async function () {
const result = sut.get_KeyMBehaviourModOutputArray__from__KeyActionBehaviourOutput_array(read, values[0], isCaps_used);
assert.equal(JSON.stringify(result), JSON.stringify(values[1]));
});
});
[[[['49', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', '', 'ˆ']]],
[[['49', 'K_SPACE', 'a0', '0', '']], [['K_SPACE', 'a0', '0', '', '']]],
[[['', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', '', 'ˆ']]],
/* Italian: [[[['49', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', '', 'ˆ']]],
[[['49', 'K_SPACE', 'a0', '0', '']], [['K_SPACE', 'a0', '0', '', '']]],
[[['', 'K_SPACE', 'a0', '0', 'ˆ']], [['K_SPACE', 'a0', '0', '', 'ˆ']]],
[[['', '', '', '', '']], [['', '', '', '', '']]],
].forEach(function (values) { */
[[[['49', 'K_SPACE', 'A_0', '0', 'ˆ']], [['K_SPACE', 'A_0', '0', '', 'ˆ']]],
[[['49', 'K_SPACE', 'A_0', '0', '']], [['K_SPACE', 'A_0', '0', '', '']]],
[[['', 'K_SPACE', 'A_0', '0', 'ˆ']], [['K_SPACE', 'A_0', '0', '', 'ˆ']]],
[[['', '', '', '', '']], [['', '', '', '', '']]],
].forEach(function (values) {
@ -484,39 +579,65 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_ActionStateOutput_array__From__ActionState ", function () {
describe('get_ActionStateOutput_array__From__ActionState ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
[["1", [
['a0', '1', 'ˆ'],
['a1', '1', 'Â'],
['a10', '1', 'ê'],
['a11', '1', 'î'],
['a13', '1', 'ô'],
['a14', '1', 'û'],
['a2', '1', 'Ê'],
['a3', '1', 'Î'],
['a5', '1', 'Ô'],
['a6', '1', 'Û'],
['a9', '1', 'â']],],
["2", [
['a0', '2', '`'],
['a1', '2', 'À'],
['a10', '2', 'è'],
['a11', '2', 'ì'],
['a13', '2', 'ò'],
['a14', '2', 'ù'],
['a2', '2', 'È'],
['a3', '2', 'Ì'],
['a5', '2', 'Ò'],
['a6', '2', 'Ù'],
['a9', '2', 'à']],],
["789", [],],
["", [],],
[" ", [],],
/*
Italian:[['1', [
['a0', '1', 'ˆ'],
['a1', '1', 'Â'],
['a10', '1', 'ê'],
['a11', '1', 'î'],
['a13', '1', 'ô'],
['a14', '1', 'û'],
['a2', '1', 'Ê'],
['a3', '1', 'Î'],
['a5', '1', 'Ô'],
['a6', '1', 'Û'],
['a9', '1', 'â']],],
['2', [
['a0', '2', '`'],
['a1', '2', 'À'],
['a10', '2', 'è'],
['a11', '2', 'ì'],
['a13', '2', 'ò'],
['a14', '2', 'ù'],
['a2', '2', 'È'],
['a3', '2', 'Ì'],
['a5', '2', 'Ò'],
['a6', '2', 'Ù'],
['a9', '2', 'à']],],
*/
[['1', [
['A_0', '1', 'ˆ'],
['A_1', '1', 'Â'],
['A_10', '1', 'ê'],
['A_11', '1', 'î'],
['A_13', '1', 'ô'],
['A_14', '1', 'û'],
['A_2', '1', 'Ê'],
['A_3', '1', 'Î'],
['A_5', '1', 'Ô'],
['A_6', '1', 'Û'],
['A_9', '1', 'â']],],
['2', [
['A_0', '2', '`'],
['A_1', '2', 'À'],
['A_10', '2', 'è'],
['A_11', '2', 'ì'],
['A_13', '2', 'ò'],
['A_14', '2', 'ù'],
['A_2', '2', 'È'],
['A_3', '2', 'Ì'],
['A_5', '2', 'Ò'],
['A_6', '2', 'Ù'],
['A_9', '2', 'à']],],
['789', [],],
['', [],],
[' ', [],],
[123, [],],
[null, [],],
[undefined, [],],
@ -530,32 +651,53 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_ActionOutputBehaviourKeyModi_From__ActionIDStateOutput ", function () {
describe('get_ActionOutputBehaviourKeyModi_From__ActionIDStateOutput ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
const converted = sut.convert(read);
/* Italian: [
['a1', 'A', true, [
['a1', 'A', 'a1', '1', 'K_A', 'NCAPS SHIFT'],
['a1', 'A', 'a1', '1', 'K_A', 'SHIFT CAPS'],
['a1', 'A', 'a1', '2', 'K_A', 'CAPS']]
],
['a1', 'A', false, [
['a1', 'A', 'a1', '1', 'K_A', 'SHIFT'],
['a1', 'A', 'a1', '1', 'K_A', 'SHIFT CAPS'],
['a1', 'A', 'a1', '2', 'K_A', 'CAPS']]
],
['a9', 'a', true, [['a9', 'a', 'a9', '0', 'K_A', 'NCAPS']]],
['a9', 'a', false, [['a9', 'a', 'a9', '0', 'K_A', '']]],
['a9', 'a', , [['a9', 'a', 'a9', '0', 'K_A', '']]],
['a9', '', true, [['a9', '', 'a9', '0', 'K_A', 'NCAPS']]],
['a9', '', false, [['a9', '', 'a9', '0', 'K_A', '']]],
['', 'a', true, []],
['', 'a', false, []],
['', '', , []],
*/
[
["a1", "A", true, [
['a1', 'A', 'a1', '1', 'K_A', 'NCAPS SHIFT'],
['a1', 'A', 'a1', '1', 'K_A', 'SHIFT CAPS'],
['a1', 'A', 'a1', '2', 'K_A', 'CAPS']]
['A_1', 'A', true, [
['A_1', 'A', 'A_1', '1', 'K_A', 'CAPS'],
['A_1', 'A', 'A_1', '2', 'K_A', 'NCAPS SHIFT'],
['A_1', 'A', 'A_1', '2', 'K_A', 'SHIFT CAPS'],
]
],
["a1", "A", false, [
['a1', 'A', 'a1', '1', 'K_A', 'SHIFT'],
['a1', 'A', 'a1', '1', 'K_A', 'SHIFT CAPS'],
['a1', 'A', 'a1', '2', 'K_A', 'CAPS']]
['A_1', 'A', false, [
['A_1', 'A', 'A_1', '1', 'K_A', 'CAPS'],
['A_1', 'A', 'A_1', '2', 'K_A', 'SHIFT'],
['A_1', 'A', 'A_1', '2', 'K_A', 'SHIFT CAPS']]
],
["a9", "a", true, [['a9', 'a', 'a9', '0', 'K_A', 'NCAPS']]],
["a9", "a", false, [['a9', 'a', 'a9', '0', 'K_A', '']]],
["a9", "a", , [['a9', 'a', 'a9', '0', 'K_A', '']]],
["a9", "", true, [["a9", "", "a9", "0", "K_A", "NCAPS"]]],
["a9", "", false, [["a9", "", "a9", "0", "K_A", ""]]],
["", "a", true, []],
["", "a", false, []],
["", "", , []],
['A_9', 'a', true, [['A_9', 'a', 'A_9', '0', 'K_A', 'NCAPS']]],
['A_9', 'a', false, [['A_9', 'a', 'A_9', '0', 'K_A', '']]],
['A_9', 'a', , [['A_9', 'a', 'A_9', '0', 'K_A', '']]],
['A_9', '', true, [['A_9', '', 'A_9', '0', 'K_A', 'NCAPS']]],
['A_9', '', false, [['A_9', '', 'A_9', '0', 'K_A', '']]],
['', 'a', true, []],
['', 'a', false, []],
['', '', , []],
].forEach(function (values) {
it((JSON.stringify(values[3]).length > 35) ?
@ -567,83 +709,144 @@ describe('KeylayoutToKmnConverter', function () {
});
});
describe("get_KeyActionOutput_array__From__ActionStateOutput_array ", function () {
describe('get_KeyActionOutput_array__From__ActionStateOutput_array ', function () {
const sut = new KeylayoutToKmnConverter(compilerTestCallbacks, compilerTestOptions);
const sut_r = new KeylayoutFileReader(compilerTestCallbacks);
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Italian.keylayout');
const inputFilename = makePathToFixture('../' + KeylayoutToKmnConverter.DATA_SUBFOLDER + '/Test.keylayout');
const read = sut_r.read(inputFilename);
/* Italian: const b6_actionId_arr = [
['a0', '1', 'ˆ'],
['a1', '1', 'Â'],
['a10', '1', 'ê'],
['a11', '1', 'î'],
['a13', '1', 'ô'],
['a14', '1', 'û'],
['a2', '1', 'Ê'],
['a3', '1', 'Î'],
['a5', '1', 'Ô'],
['a6', '1', 'Û'],
['a9', '1', 'â']
];
const b1_keycode_arr = [
['49', 'K_SPACE', 'a0', '0', 'ˆ'],
['49', 'K_SPACE', 'a0', '1', 'ˆ'],
['49', 'K_SPACE', 'a0', '2', 'ˆ'],
['6', 'K_Z', 'a0', '4', 'ˆ'],
['25', 'K_9', 'a0', '4', 'ˆ'],
['43', 'K_COMMA', 'a0', '4', 'ˆ'],
['49', 'K_SPACE', 'a0', '7', 'ˆ'],
['0', 'K_A', 'a1', '1', 'Â'],
['0', 'K_A', 'a1', '2', 'Â'],
['14', 'K_E', 'a10', '0', 'ê'],
['34', 'K_I', 'a11', '0', 'î'],
['31', 'K_O', 'a13', '0', 'ô'],
['32', 'K_U', 'a14', '0', 'û'],
['14', 'K_E', 'a2', '1', 'Ê'],
['14', 'K_E', 'a2', '2', 'Ê'],
['34', 'K_I', 'a3', '1', 'Î'],
['34', 'K_I', 'a3', '2', 'Î'],
['31', 'K_O', 'a5', '1', 'Ô'],
['31', 'K_O', 'a5', '2', 'Ô'],
['32', 'K_U', 'a6', '1', 'Û'],
['32', 'K_U', 'a6', '2', 'Û'],
['0', 'K_A', 'a9', '0', 'â']
];
*/
const b6_actionId_arr = [
['a0', '1', 'ˆ'],
['a1', '1', 'Â'],
['a10', '1', 'ê'],
['a11', '1', 'î'],
['a13', '1', 'ô'],
['a14', '1', 'û'],
['a2', '1', 'Ê'],
['a3', '1', 'Î'],
['a5', '1', 'Ô'],
['a6', '1', 'Û'],
['a9', '1', 'â']
['A_0', '1', 'ˆ'],
['A_1', '1', 'Â'],
['A_10', '1', 'ê'],
['A_11', '1', 'î'],
['A_13', '1', 'ô'],
['A_14', '1', 'û'],
['A_2', '1', 'Ê'],
['A_3', '1', 'Î'],
['A_5', '1', 'Ô'],
['A_6', '1', 'Û'],
['A_9', '1', 'â']
];
const b1_keycode_arr = [
['49', 'K_SPACE', 'a0', '0', 'ˆ'],
['49', 'K_SPACE', 'a0', '1', 'ˆ'],
['49', 'K_SPACE', 'a0', '2', 'ˆ'],
['6', 'K_Z', 'a0', '4', 'ˆ'],
['25', 'K_9', 'a0', '4', 'ˆ'],
['43', 'K_COMMA', 'a0', '4', 'ˆ'],
['49', 'K_SPACE', 'a0', '7', 'ˆ'],
['0', 'K_A', 'a1', '1', 'Â'],
['0', 'K_A', 'a1', '2', 'Â'],
['14', 'K_E', 'a10', '0', 'ê'],
['34', 'K_I', 'a11', '0', 'î'],
['31', 'K_O', 'a13', '0', 'ô'],
['32', 'K_U', 'a14', '0', 'û'],
['14', 'K_E', 'a2', '1', 'Ê'],
['14', 'K_E', 'a2', '2', 'Ê'],
['34', 'K_I', 'a3', '1', 'Î'],
['34', 'K_I', 'a3', '2', 'Î'],
['31', 'K_O', 'a5', '1', 'Ô'],
['31', 'K_O', 'a5', '2', 'Ô'],
['32', 'K_U', 'a6', '1', 'Û'],
['32', 'K_U', 'a6', '2', 'Û'],
['0', 'K_A', 'a9', '0', 'â']
['49', 'K_SPACE', 'A_0', '0', 'ˆ'],
['49', 'K_SPACE', 'A_0', '1', 'ˆ'],
['49', 'K_SPACE', 'A_0', '2', 'ˆ'],
['49', 'K_SPACE', 'A_0', '3', 'ˆ'],
['6', 'K_Z', 'A_0', '4', 'ˆ'],
['25', 'K_9', 'A_0', '4', 'ˆ'],
['43', 'K_COMMA', 'A_0', '4', 'ˆ'],
['0', 'K_A', 'A_1', '1', 'Â'],
['0', 'K_A', 'A_1', '2', 'Â'],
['14', 'K_E', 'A_10', '0', 'ê'],
['34', 'K_I', 'A_11', '0', 'î'],
['31', 'K_O', 'A_13', '0', 'ô'],
['32', 'K_U', 'A_14', '0', 'û'],
['14', 'K_E', 'A_2', '1', 'Ê'],
['14', 'K_E', 'A_2', '2', 'Ê'],
['34', 'K_I', 'A_3', '1', 'Î'],
['34', 'K_I', 'A_3', '2', 'Î'],
['31', 'K_O', 'A_5', '1', 'Ô'],
['31', 'K_O', 'A_5', '2', 'Ô'],
['32', 'K_U', 'A_6', '1', 'Û'],
['32', 'K_U', 'A_6', '2', 'Û'],
['0', 'K_A', 'A_9', '0', 'â']
];
[[b6_actionId_arr, b1_keycode_arr],
].forEach(function (values) {
it(("get_KeyActionOutput_array__From__ActionStateOutput_array([['" + values[0][0][0] + "', '" + values[0][0][1] + "', '" + values[0][0][2] + "'],..])").padEnd(73, " ") + ' should return an array of objects', async function () {
it(("get_KeyActionOutput_array__From__ActionStateOutput_array([['" + values[0][0][0] + "', '" + values[0][0][1] + "', '" + values[0][0][2] + "'],..])").padEnd(73, " ") + '1 should return an array of objects', async function () {
const result = sut.get_KeyActionOutput_array__From__ActionStateOutput_array(read, values[0]);
assert.equal(JSON.stringify(result), JSON.stringify(values[1]));
});
});
//-----------------
/* Italian: const oneEntryResult = [
['49', 'K_SPACE', 'a0', '0', 'ˆ'],
['49', 'K_SPACE', 'a0', '1', 'ˆ'],
['49', 'K_SPACE', 'a0', '2', 'ˆ'],
['6', 'K_Z', 'a0', '4', 'ˆ'],
['25', 'K_9', 'a0', '4', 'ˆ'],
['43', 'K_COMMA', 'a0', '4', 'ˆ'],
['49', 'K_SPACE', 'a0', '7', 'ˆ']
];
const oneEntryResultNoOutput = [
['49', 'K_SPACE', 'a0', '0', ''],
['49', 'K_SPACE', 'a0', '1', ''],
['49', 'K_SPACE', 'a0', '2', ''],
['6', 'K_Z', 'a0', '4', ''],
['25', 'K_9', 'a0', '4', ''],
['43', 'K_COMMA', 'a0', '4', ''],
['49', 'K_SPACE', 'a0', '7', '']
] ;
*/
const oneEntryResult = [
["49", "K_SPACE", "a0", "0", "ˆ"],
["49", "K_SPACE", "a0", "1", "ˆ"],
["49", "K_SPACE", "a0", "2", "ˆ"],
["6", "K_Z", "a0", "4", "ˆ"],
["25", "K_9", "a0", "4", "ˆ"],
["43", "K_COMMA", "a0", "4", "ˆ"],
["49", "K_SPACE", "a0", "7", "ˆ"]
['49', 'K_SPACE', 'A_0', '0', 'ˆ'],
['49', 'K_SPACE', 'A_0', '1', 'ˆ'],
['49', 'K_SPACE', 'A_0', '2', 'ˆ'],
['49', 'K_SPACE', 'A_0', '3', 'ˆ'],
['6', 'K_Z', 'A_0', '4', 'ˆ'],
['25', 'K_9', 'A_0', '4', 'ˆ'],
['43', 'K_COMMA', 'A_0', '4', 'ˆ']
];
const oneEntryResultNoOutput = [
["49", "K_SPACE", "a0", "0", ""],
["49", "K_SPACE", "a0", "1", ""],
["49", "K_SPACE", "a0", "2", ""],
["6", "K_Z", "a0", "4", ""],
["25", "K_9", "a0", "4", ""],
["43", "K_COMMA", "a0", "4", ""],
["49", "K_SPACE", "a0", "7", ""]
['49', 'K_SPACE', 'A_0', '0', ''],
['49', 'K_SPACE', 'A_0', '1', ''],
['49', 'K_SPACE', 'A_0', '2', ''],
['49', 'K_SPACE', 'A_0', '3', ''],
['6', 'K_Z', 'A_0', '4', ''],
['25', 'K_9', 'A_0', '4', ''],
['43', 'K_COMMA', 'A_0', '4', '']
];
[[[['a0', '1', 'ˆ']], oneEntryResult],
[[['a0', '1', '']], oneEntryResultNoOutput],
[[['a0', '', 'ˆ']], oneEntryResult],
[[[['A_0', '1', 'ˆ']], oneEntryResult],
[[['A_0', '1', '']], oneEntryResultNoOutput],
[[['A_0', '', 'ˆ']], oneEntryResult],
].forEach(function (values) {
it(("get_KeyActionOutput_array__From__ActionStateOutput_array(['" + values[0][0][0] + "', '" + values[0][0][1] + "', '" + values[0][0][2] + "'])").padEnd(73, " ") + ' should return an array of objects', async function () {
it(("get_KeyActionOutput_array__From__ActionStateOutput_array(['" + values[0][0][0] + "', '" + values[0][0][1] + "', '" + values[0][0][2] + "'])").padEnd(73, " ") + '2 should return an array of objects', async function () {
const result = sut.get_KeyActionOutput_array__From__ActionStateOutput_array(read, values[0]);
assert.equal(JSON.stringify(result), JSON.stringify(values[1]));
});