diff --git a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_character_range_too_long.kmn b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_character_range_too_long.kmn index e19e3ab9f87..8b8c0e402fd 100644 --- a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_character_range_too_long.kmn +++ b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_character_range_too_long.kmn @@ -8,7 +8,6 @@ group(main) using keys c maximum store length is 4096 UTF-16 code units, including U+0000 terminator c #define GLOBAL_BUFSIZE 4096 // compfile.h c so we need 0x101E - 0x0020 + 1 = 0x0FFF --> 4095 words -c See #11136 for calculation adjustment TODO store(x) U+0020 .. U+101E diff --git a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn index fcae6a5d758..18974124aa2 100644 --- a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn +++ b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_extended_string_too_long.kmn @@ -8,8 +8,7 @@ group(main) using keys c c maximum store length is 4096 UTF-16 code units, including U+0000 terminator c #define GLOBAL_BUFSIZE 4096 // compfile.h -c so we need 0x101B - 0x0020 + 1 = 0x0FFD --> 4092 words, + 4 = 4096 = too long -c See #11136 for calculation adjustment TODO +c so we need 0x101B - 0x0020 + 1 = 0x0FFC --> 4092 words, + 4 = 4096 = too long store(x) U+0020 .. U+101B diff --git a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn index 750e45d3bad..cbd22204152 100644 --- a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn +++ b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_outs_too_long.kmn @@ -7,12 +7,11 @@ group(main) using keys c maximum store length is 4096 UTF-16 code units, including U+0000 terminator c #define GLOBAL_BUFSIZE 4096 // compfile.h -c so we need 0x101C - 0x0020 + 1 = 0x0FFD --> 4093 words -c + 1, for 'a' in the rule below = 4094, which triggers the buffer boundary check. -c Noting that this is conservative and losing 2 possible chars, but not fixing +c so we need 0x101D - 0x0020 + 1 = 0x0FFE --> 4094 words +c + 1, for 'a' in the rule below = 4095, which triggers the buffer boundary check. +c Noting that this is conservative and losing 1 possible char, but not fixing c in compiler.cpp at this time. -c See #11136 for calculation adjustment TODO -store(x) U+0020 .. U+101C +store(x) U+0020 .. U+101D 'a' outs(x) + 'x' > 'x' context diff --git a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_virtual_key_expansion_too_long.kmn b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_virtual_key_expansion_too_long.kmn index a617f294349..8646f65019a 100644 --- a/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_virtual_key_expansion_too_long.kmn +++ b/developer/src/kmc-kmn/test/fixtures/invalid-keyboards/error_virtual_key_expansion_too_long.kmn @@ -7,11 +7,10 @@ group(main) using keys c maximum store length is 4096 UTF-16 code units, including U+0000 terminator c #define GLOBAL_BUFSIZE 4096 // compfile.h -c so we need 0x101E - 0x0020 + 1 = 0x0FFF --> 4095 words -c each vk is 5 words long UC_SENTINEL CODE_EXTENDED shift key CODE_EXTENDEDEND (some long history here!) -c we start filling the buffer with 4066 words and then the remaining 30 bytes = 6 VKs A-F -c See #11136 for calculation adjustment TODO +c so we need 0x101D - 0x0020 + 1 = 0x0FFE --> 4094 words +c each VK is 5 words long UC_SENTINEL CODE_EXTENDED shift key CODE_EXTENDEDEND (some long history here!) +c we start filling the buffer with 4064 words (0x0FFF - 0x0020 + 1) and then the remaining 30 bytes = 6 VKs A-F -store(x) U+0020 .. U+1000 [K_A] .. [K_F] +store(x) U+0020 .. U+0FFF [K_A] .. [K_F] any(x) + 'x' > 'x' context diff --git a/developer/src/kmc-kmn/test/test-messages.ts b/developer/src/kmc-kmn/test/test-messages.ts index e338cbe521f..1ba46033d8c 100644 --- a/developer/src/kmc-kmn/test/test-messages.ts +++ b/developer/src/kmc-kmn/test/test-messages.ts @@ -53,23 +53,20 @@ describe('KmnCompilerMessages', function () { // ERROR_DuplicateGroup - it('should generate CERR_DuplicateGroup if the kmn contains two groups with the same name', async function() { + it('should generate ERROR_DuplicateGroup if the kmn contains two groups with the same name', async function() { await testForMessage(this, ['invalid-keyboards', 'error_duplicate_group.kmn'], KmnCompilerMessages.ERROR_DuplicateGroup); - assert.equal(callbacks.messages[0].message, "A group with this name has already been defined. Group 'ខ្មែរ' declared on line 9"); }); // ERROR_DuplicateStore - it('should generate CERR_DuplicateStore if the kmn contains two stores with the same name', async function() { + it('should generate ERROR_DuplicateStore if the kmn contains two stores with the same name', async function() { await testForMessage(this, ['invalid-keyboards', 'error_duplicate_store.kmn'], KmnCompilerMessages.ERROR_DuplicateStore); - assert.equal(callbacks.messages[0].message, "A store with this name has already been defined. Store 'ខ្មែរ' declared on line 11"); }); // ERROR_VirtualKeyInContext it('should generate ERROR_VirtualKeyInContext if a virtual key is found in the context part of a rule', async function() { await testForMessage(this, ['invalid-keyboards', 'error_virtual_key_in_context.kmn'], KmnCompilerMessages.ERROR_VirtualKeyInContext); - assert.equal(callbacks.messages[0].message, "Virtual keys are not permitted in context"); }); // WARN_TouchLayoutUnidentifiedKey @@ -77,49 +74,42 @@ describe('KmnCompilerMessages', function () { it('should generate WARN_TouchLayoutUnidentifiedKey if a key has no identifier in the touch layout', async function() { await testForMessage(this, ['invalid-keyboards', 'warn_touch_layout_unidentified_key.kmn'], KmnCompilerMessages.WARN_TouchLayoutUnidentifiedKey); // TODO(lowpri): that message could be slightly more helpful! - assert.equal(callbacks.messages[0].message, "A key on layer \"default\" has no identifier."); }); // ERROR_NotSupportedInKeymanWebOutput it('should generate ERROR_NotSupportedInKeymanWebOutput if a rule has `return` in the output', async function() { await testForMessage(this, ['invalid-keyboards', 'error_not_supported_in_keyman_web_output.kmn'], KmnCompilerMessages.ERROR_NotSupportedInKeymanWebOutput); - assert.equal(callbacks.messages[0].message, "Statement 'return' is not currently supported in output for web and touch targets"); }); // WARN_VirtualKeyInOutput it('should generate WARN_VirtualKeyInOutput if a virtual key is found in the output part of a rule', async function() { await testForMessage(this, ['invalid-keyboards', 'warn_virtual_key_in_output.kmn'], KmnCompilerMessages.WARN_VirtualKeyInOutput); - assert.equal(callbacks.messages[0].message, "Virtual keys are not supported in output"); }); // ERROR_OutsTooLong - it('should generate ERROR_OutsTooLong if a store referenced in outs() is too long (more than GLOBAL_BUFSIZE elements)', async function() { + it('should generate ERROR_OutsTooLong if a store referenced in outs() is too long and would overflow the buffer', async function() { await testForMessage(this, ['invalid-keyboards', 'error_outs_too_long.kmn'], KmnCompilerMessages.ERROR_OutsTooLong); - // callbacks.printMessages(); }); // ERROR_ExtendedStringTooLong - it('should generate ERROR_ExtendedStringTooLong if an extended string is too long (more than GLOBAL_BUFSIZE elements)', async function() { + it('should generate ERROR_ExtendedStringTooLong if an extended string is too long and would overflow the buffer', async function() { await testForMessage(this, ['invalid-keyboards', 'error_extended_string_too_long.kmn'], KmnCompilerMessages.ERROR_ExtendedStringTooLong); - // callbacks.printMessages(); }); // ERROR_VirtualKeyExpansionTooLong - it('should generate ERROR_VirtualKeyExpansionTooLong if a virtual key expansion is too long (more than GLOBAL_BUFSIZE elements)', async function() { + it('should generate ERROR_VirtualKeyExpansionTooLong if a virtual key expansion is too long and would overflow the buffer', async function() { await testForMessage(this, ['invalid-keyboards', 'error_virtual_key_expansion_too_long.kmn'], KmnCompilerMessages.ERROR_VirtualKeyExpansionTooLong); - // callbacks.printMessages(); }); // ERROR_CharacterRangeTooLong - it('should generate ERROR_CharacterRangeTooLong if a character range would expand to be too long (more than GLOBAL_BUFSIZE elements)', async function() { + it('should generate ERROR_CharacterRangeTooLong if a character range would expand to be too long and would overflow the buffer', async function() { await testForMessage(this, ['invalid-keyboards', 'error_character_range_too_long.kmn'], KmnCompilerMessages.ERROR_CharacterRangeTooLong); - // callbacks.printMessages(); }); });