-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(developer): kmc code generation for context(n) in context
Fixes #9930. * Fixes the index offset calculation, with +1 for >=v10.0 keyboards and -1 for <v10.0 keyboards (difference is because older version keyboards have context offsets calculated in the opposite direction). Note that this happened because the `CODE_CONTEXTEX` index is stored in memory as 0-based in kmc, but was 1-based in kmcomp. * Adds unit tests for v9.0 and v10.0 keyboards for `context(n)` in context. * Adds unit tests for v9.0 and v10.0 keyboards for `context(n)` in output. These were already correct but now we can be assured that they are being tested. * Enables code coverage for kmw-compiler, and sets a lower threshold for pass because coverage is still just over 70%.
- Loading branch information
Showing
12 changed files
with
270 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,6 @@ | |
"exclude-after-remap": true, | ||
"exclude": [ | ||
"src/import/", | ||
"src/kmw-compiler", | ||
"test/" | ||
] | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
developer/src/kmc-kmn/test/fixtures/kmw/test_context_in_context.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
if(typeof keyman === 'undefined') { | ||
console.log('Keyboard requires KeymanWeb 10.0 or later'); | ||
if(typeof tavultesoft !== 'undefined') tavultesoft.keymanweb.util.alert("This keyboard requires KeymanWeb 10.0 or later"); | ||
} else { | ||
KeymanWeb.KR(new Keyboard_test_context_in_context()); | ||
} | ||
function Keyboard_test_context_in_context() | ||
{ | ||
var modCodes = keyman.osk.modifierCodes; | ||
var keyCodes = keyman.osk.keyCodes; | ||
|
||
this._v=(typeof keyman!="undefined"&&typeof keyman.version=="string")?parseInt(keyman.version,10):9; | ||
this.KI="Keyboard_test_context_in_context"; | ||
this.KN="test context(n) in context, #9930"; | ||
this.KMINVER="10.0"; | ||
this.KV=null; | ||
this.KDU=0; | ||
this.KH=''; | ||
this.KM=0; | ||
this.KBVER="1.0"; | ||
this.KMBM=modCodes.SHIFT /* 0x0010 */; | ||
this.s_liveQwerty_6="qwerty"; | ||
this.s_deadQwerty_7=[{t:'d',d:0},{t:'d',d:1},{t:'d',d:2},{t:'d',d:3},{t:'d',d:4},{t:'d',d:5}]; | ||
this.KVS=[]; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.g_main_0=function(t,e) { | ||
var k=KeymanWeb,r=0,m=0; | ||
if(k.KKM(e, modCodes.SHIFT | modCodes.VIRTUAL_KEY /* 0x4010 */, keyCodes.K_1 /* 0x31 */)) { | ||
if(k.KFCM(1,t,[{t:'a',a:this.s_liveQwerty_6}])){ | ||
r=m=1; // Line 13 | ||
k.KDC(1,t); | ||
k.KO(-1,t,"?"); | ||
k.KIO(-1,this.s_deadQwerty_7,1,t); | ||
k.KIO(-1,this.s_deadQwerty_7,1,t); | ||
} | ||
} | ||
else if(k.KKM(e, modCodes.VIRTUAL_KEY /* 0x4000 */, keyCodes.K_PERIOD /* 0xBE */)) { | ||
if(k.KFCM(3,t,['?',{t:'a',a:this.s_deadQwerty_7},{t:'c',c:2}])){ | ||
r=m=1; // Line 17 | ||
k.KDC(3,t); | ||
k.KO(-1,t,"("); | ||
k.KIO(-1,this.s_liveQwerty_6,2,t); | ||
k.KIO(-1,this.s_liveQwerty_6,2,t); | ||
k.KO(-1,t,")"); | ||
} | ||
} | ||
return r; | ||
}; | ||
} |
17 changes: 17 additions & 0 deletions
17
developer/src/kmc-kmn/test/fixtures/kmw/test_context_in_context.kmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
store(&VERSION) "10.0" | ||
store(&TARGETS) 'web' | ||
store(&NAME) 'test context(n) in context, #9930' | ||
|
||
begin Unicode > use(main) | ||
|
||
group(main) using keys | ||
|
||
store(liveQwerty) 'qwerty' | ||
store(deadQwerty) dk(q) dk(w) dk(e) dk(r) dk(t) dk(y) | ||
|
||
c any/index with deadkeys in stores. | ||
any(liveQwerty) + '!' > '?' index(deadQwerty, 1) index(deadQwerty, 1) | ||
|
||
c The rule below is misgenerated by kmc-17.0.205-alpha on `context(2)` statement; | ||
c see https://github.com/keymanapp/keyman/issues/9930 | ||
'?' any(deadQwerty) context(2) + '.' > '(' index(liveQwerty, 2) index(liveQwerty, 2) ')' |
47 changes: 47 additions & 0 deletions
47
developer/src/kmc-kmn/test/fixtures/kmw/test_context_in_context_9.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
KeymanWeb.KR(new Keyboard_test_context_in_context_9()); | ||
|
||
function Keyboard_test_context_in_context_9() | ||
{ | ||
|
||
this._v=(typeof keyman!="undefined"&&typeof keyman.version=="string")?parseInt(keyman.version,10):9; | ||
this.KI="Keyboard_test_context_in_context_9"; | ||
this.KN="test context(n) in context, #9930, v9.0"; | ||
this.KMINVER="9.0"; | ||
this.KV=null; | ||
this.KDU=0; | ||
this.KH=''; | ||
this.KM=0; | ||
this.KBVER="1.0"; | ||
this.KMBM=0x0010; | ||
this.s_liveQwerty_6="qwerty"; | ||
this.s_deadQwerty_7="123456"; | ||
this.KVS=[]; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.g_main_0=function(t,e) { | ||
var k=KeymanWeb,r=0,m=0; | ||
if(k.KKM(e, 0x4010, 0x31)) { | ||
if(k.KA(0,k.KC(1,1,t),this.s_liveQwerty_6)){ | ||
r=m=1; // Line 13 | ||
k.KO(1,t,"?"); | ||
k.KIO(-1,this.s_deadQwerty_7,1,t); | ||
k.KIO(-1,this.s_deadQwerty_7,1,t); | ||
} | ||
} | ||
else if(k.KKM(e, 0x4000, 0xBE)) { | ||
if(k.KCM(3,t,"?",1)&&k.KA(1,k.KC(2,1,t),this.s_deadQwerty_7)&&k.KCCM(1,2,t)){ | ||
r=m=1; // Line 17 | ||
k.KO(3,t,"("); | ||
k.KIO(-1,this.s_liveQwerty_6,2,t); | ||
k.KIO(-1,this.s_liveQwerty_6,2,t); | ||
k.KO(-1,t,")"); | ||
} | ||
} | ||
return r; | ||
}; | ||
} |
17 changes: 17 additions & 0 deletions
17
developer/src/kmc-kmn/test/fixtures/kmw/test_context_in_context_9.kmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
store(&VERSION) "9.0" | ||
store(&TARGETS) 'web' | ||
store(&NAME) 'test context(n) in context, #9930, v9.0' | ||
|
||
begin Unicode > use(main) | ||
|
||
group(main) using keys | ||
|
||
store(liveQwerty) 'qwerty' | ||
store(deadQwerty) '123456' | ||
|
||
c any/index with deadkeys in stores. | ||
any(liveQwerty) + '!' > '?' index(deadQwerty, 1) index(deadQwerty, 1) | ||
|
||
c The rule below is misgenerated by kmc-17.0.205-alpha on `context(2)` statement; | ||
c see https://github.com/keymanapp/keyman/issues/9930 | ||
'?' any(deadQwerty) context(2) + '.' > '(' index(liveQwerty, 2) index(liveQwerty, 2) ')' |
44 changes: 44 additions & 0 deletions
44
developer/src/kmc-kmn/test/fixtures/kmw/test_contextn_in_output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
if(typeof keyman === 'undefined') { | ||
console.log('Keyboard requires KeymanWeb 10.0 or later'); | ||
if(typeof tavultesoft !== 'undefined') tavultesoft.keymanweb.util.alert("This keyboard requires KeymanWeb 10.0 or later"); | ||
} else { | ||
KeymanWeb.KR(new Keyboard_test_contextn_in_output()); | ||
} | ||
function Keyboard_test_contextn_in_output() | ||
{ | ||
var modCodes = keyman.osk.modifierCodes; | ||
var keyCodes = keyman.osk.keyCodes; | ||
|
||
this._v=(typeof keyman!="undefined"&&typeof keyman.version=="string")?parseInt(keyman.version,10):9; | ||
this.KI="Keyboard_test_contextn_in_output"; | ||
this.KN="test context(n) in output, #9930, v10.0"; | ||
this.KMINVER="10.0"; | ||
this.KV=null; | ||
this.KDU=0; | ||
this.KH=''; | ||
this.KM=0; | ||
this.KBVER="1.0"; | ||
this.KMBM=modCodes.SHIFT /* 0x0010 */; | ||
this.s_liveQwerty_6="qwerty"; | ||
this.s_deadQwerty_7=[{t:'d',d:0},{t:'d',d:1},{t:'d',d:2},{t:'d',d:3},{t:'d',d:4},{t:'d',d:5}]; | ||
this.KVS=[]; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.g_main_0=function(t,e) { | ||
var k=KeymanWeb,r=0,m=0; | ||
if(k.KKM(e, modCodes.SHIFT | modCodes.VIRTUAL_KEY /* 0x4010 */, keyCodes.K_1 /* 0x31 */)) { | ||
if(k.KFCM(2,t,[{t:'a',a:this.s_liveQwerty_6},'1'])){ | ||
r=m=1; // Line 13 | ||
k.KDC(2,t); | ||
k.KO(-1,t,"?"); | ||
k.KIO(-1,this.s_deadQwerty_7,1,t); | ||
k.KO(-1,t,"1"); | ||
} | ||
} | ||
return r; | ||
}; | ||
} |
13 changes: 13 additions & 0 deletions
13
developer/src/kmc-kmn/test/fixtures/kmw/test_contextn_in_output.kmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
store(&VERSION) "10.0" | ||
store(&TARGETS) 'web' | ||
store(&NAME) 'test context(n) in output, #9930, v10.0' | ||
|
||
begin Unicode > use(main) | ||
|
||
group(main) using keys | ||
|
||
store(liveQwerty) 'qwerty' | ||
store(deadQwerty) dk(q) dk(w) dk(e) dk(r) dk(t) dk(y) | ||
|
||
c any/index with deadkeys in stores. | ||
any(liveQwerty) '1' + '!' > '?' index(deadQwerty, 1) context(2) |
38 changes: 38 additions & 0 deletions
38
developer/src/kmc-kmn/test/fixtures/kmw/test_contextn_in_output_9.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
KeymanWeb.KR(new Keyboard_test_contextn_in_output_9()); | ||
|
||
function Keyboard_test_contextn_in_output_9() | ||
{ | ||
|
||
this._v=(typeof keyman!="undefined"&&typeof keyman.version=="string")?parseInt(keyman.version,10):9; | ||
this.KI="Keyboard_test_contextn_in_output_9"; | ||
this.KN="test context(n) in output, #9930, v9.0"; | ||
this.KMINVER="9.0"; | ||
this.KV=null; | ||
this.KDU=0; | ||
this.KH=''; | ||
this.KM=0; | ||
this.KBVER="1.0"; | ||
this.KMBM=0x0010; | ||
this.s_liveQwerty_6="qwerty"; | ||
this.s_deadQwerty_7="123456"; | ||
this.KVS=[]; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.gs=function(t,e) { | ||
return this.g_main_0(t,e); | ||
}; | ||
this.g_main_0=function(t,e) { | ||
var k=KeymanWeb,r=0,m=0; | ||
if(k.KKM(e, 0x4010, 0x31)) { | ||
if(k.KA(0,k.KC(2,1,t),this.s_liveQwerty_6)&&k.KCM(1,t,"1",1)){ | ||
r=m=1; // Line 13 | ||
k.KO(2,t,"?"); | ||
k.KIO(-1,this.s_deadQwerty_7,1,t); | ||
k.KO(-1,t,"1"); | ||
} | ||
} | ||
return r; | ||
}; | ||
} |
13 changes: 13 additions & 0 deletions
13
developer/src/kmc-kmn/test/fixtures/kmw/test_contextn_in_output_9.kmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
store(&VERSION) "9.0" | ||
store(&TARGETS) 'web' | ||
store(&NAME) 'test context(n) in output, #9930, v9.0' | ||
|
||
begin Unicode > use(main) | ||
|
||
group(main) using keys | ||
|
||
store(liveQwerty) 'qwerty' | ||
store(deadQwerty) '123456' | ||
|
||
c any/index with deadkeys in stores. | ||
any(liveQwerty) '1' + '!' > '?' index(deadQwerty, 1) context(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters