Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
srl295 committed Feb 22, 2024
1 parent 18d8c61 commit 066b438
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 4 deletions.
71 changes: 70 additions & 1 deletion source/ldml_test-test.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<keyboardTest3 conformsTo="techpreview">
<info keyboard="und.xml" author="srl295" name="test" />
<info keyboard="ldml_test.xml" author="srl295" name="test" />

<tests name="separate">
<!-- test direct key output
https://www.unicode.org/reports/tr35/tr35-keyboards.html#element-key -->
<test name="key-1">
<keystroke key="1" />
<check result="1:basic:OK" />
</test>
<!-- test a simple transform
https://www.unicode.org/reports/tr35/tr35-keyboards.html#element-transform -->
<test name="key-2">
<keystroke key="2" />
<check result="2:simple_transform:OK" />
</test>
<!-- test a transform using a marker
https://www.unicode.org/reports/tr35/tr35-keyboards.html#markers -->
<test name="key-3">
<keystroke key="3" />
<check result="3:simple_marker:OK" />
</test>
<!-- test a reorder
https://www.unicode.org/reports/tr35/tr35-keyboards.html#element-reorder -->
<test name="key-4">
<keystroke key="4" />
<check result="4:simple_reorder:OK" />
</test>
<!-- test using variable substitution
https://www.unicode.org/reports/tr35/tr35-keyboards.html#element-string -->
<test name="key-5">
<keystroke key="5" />
<check result="5:simple_vars:OK" />
</test>
<!-- test a mapped variable substitution
https://www.unicode.org/reports/tr35/tr35-keyboards.html#replacement-syntax -->
<test name="key-6">
<keystroke key="6" />
<check result="6:map_var:OK" />
</test>
<!-- test a uset substitution
https://www.unicode.org/reports/tr35/tr35-keyboards.html#element-unicodeset -->
<test name="key-7">
<keystroke key="7" />
<check result="7:simple_uset:OK" />
</test>
<!-- test a different uset substitution
https://www.unicode.org/reports/tr35/tr35-keyboards.html#element-unicodeset -->
<test name="key-shift-7">
<keystroke key="shift-7" />
<check result="7:simple_uset:FAIL" />
</test>
<!-- test pre-existing input context
https://www.unicode.org/reports/tr35/tr35-keyboards.html#test-element-startcontext -->
<test name="key-8">
<startContext to="ABC" />
<keystroke key="8" />
<check result="8:ctxt:OK" />
</test>
<!-- test that the input context is required
https://www.unicode.org/reports/tr35/tr35-keyboards.html#test-element-startcontext -->
<test name="key-8-fail">
<startContext to="" /> <!-- w/o context -->
<keystroke key="8" />
<check result="8:ctxt:FAIL"/>
</test>
<!-- test context with a non-BMP character
https://www.unicode.org/reports/tr35/tr35-keyboards.html#test-element-startcontext -->
<test name="key-8-osage">
<startContext to="𐓏" />
<keystroke key="8" />
<check result="8:ctxt:OK" />
</test>
<!-- test using two pieces of context together with non-BMP chars
https://www.unicode.org/reports/tr35/tr35-keyboards.html#test-element-startcontext -->
<test name="key-8-osage2">
<startContext to="𐒻" />
<keystroke key="shift-8" />
<keystroke key="8" />
<check result="8:ctxt:OK" />
</test>
<!-- test using two markers across two keystrokes
https://www.unicode.org/reports/tr35/tr35-keyboards.html#markers -->
<test name="key-9">
<startContext to="" />
<keystroke key="9" />
<keystroke key="shift-9" />
<check result="9:split_marker:OK" />
</test>
</tests>
</keyboardTest3>
61 changes: 58 additions & 3 deletions source/ldml_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@
<key id="2" output="2:simple_transform:FAIL" />
<key id="3" output="3:simple_marker:FAIL\m{marker}" />
<key id="4" output="4:simple_reorder:UNTIED" />

<key id="5" output="5:simple_vars:${varsok}"/>
<key id="6" output="6:map_var:B\m{map1}X\m{map2}"/>
<key id="7" output="7:simple_uset:FAIL\m{uset7}" /> <!-- will produce OK-->
<key id="shift-7" output="7:simple_uset:OK\m{uset7}" /> <!-- will produce FAIL-->
<key id="8" output="\m{8ctxt}8:ctxt:FAIL" />
<key id="shift-8" output="𐒷" />
<key id="9" output="9:split_marker:FAIL\m{marker1}" />
<key id="shift-9" output="\m{marker2}" />
</keys>

<layers formId="us">
<layer modifiers="none">
<row keys="grave 1 2 3 4 5 6 7 8 9 0 hyphen equal"/>
Expand All @@ -22,7 +30,7 @@
<row keys="space"/>
</layer>
<layer modifiers="shift">
<row keys="tilde bang at hash dollar percent caret amp asterisk open-paren close-paren underscore plus"/>
<row keys="tilde bang at hash dollar percent caret shift-7 shift-8 shift-9 close-paren underscore plus"/>
<row keys="Q W E R T Y U I O P open-curly close-curly pipe"/>
<row keys="A S D F G H J K L colon double-quote"/>
<row keys="Z X C V B N M open-angle close-angle question"/>
Expand All @@ -43,7 +51,20 @@
<row keys="space"/>
</layer>
</layers>


<variables>
<string id="varsok" value="OK"/>
<!-- 6: first 13 chars and second 13 chars of alphabet -->
<set id="alpha1" value="A B C D E F G H I J K L M"/>
<set id="alpha2" value="N O P Q R S T U V W X Y Z"/>
<!-- 6: regular and rot13 alphabet -->
<set id="alpha" value="$[alpha1] $[alpha2]"/>
<set id="nycun" value="$[alpha2] $[alpha1]"/> <!-- 'nycun' in rot13 -->
<!-- 7: uset -->
<unicodeSet id="7ok" value="[[A_LIFE]-[E]]" /> <!-- = the chars [FAIL]-->
<unicodeSet id="7notok" value="[[A-Z]-$[7ok]]"/> <!-- everything not in [FAIL]-->
</variables>

<transforms type="simple">
<transformGroup>
<!--
Expand All @@ -63,11 +84,45 @@
<reorder from="E" order="4" />
<reorder from="D" order="5" />
</transformGroup>
<!-- 6: rot-13 the last char -->
<transformGroup>
<transform from="($[alpha])\m{map2}" to="$[1:nycun]"/>
</transformGroup>
<!-- 6: restore the trailing map2 -->
<transformGroup>
<transform from="\m{map1}($[alpha])" to="\m{map1}$1\m{map2}"/>
</transformGroup>
<!-- 6: swap chars -->
<transformGroup>
<transform from="($[alpha])\m{map1}($[alpha])\m{map2}" to="$2\m{map2}$1\m{map1}" />
</transformGroup>
<!-- 6: rot-13 the last char -->
<transformGroup>
<transform from="($[alpha])\m{map1}" to="$[1:nycun]"/>
</transformGroup>
<!-- 6: restore the trailing map1 -->
<transformGroup>
<transform from="\m{map2}($[alpha])" to="\m{map2}$1\m{map1}"/>
</transformGroup>
<!-- 6: swap back -->
<transformGroup>
<transform from="($[alpha])\m{map2}($[alpha])\m{map1}" to="$2\m{map1}$1\m{map2}" />
<transform from=":(?:$[7notok])+\m{uset7}" to=":FAIL" />
<transform from=":(?:$[7ok])+\m{uset7}" to=":OK" />
</transformGroup>
<transformGroup>
<transform from="simple_transform:FAIL" to="simple_transform:OK" />
<!-- 3: interpret marker results -->
<transform from="FAIL\m{marker}" to="OK" />
<transform from="FAIL\m{marker1}\m{marker2}" to="OK" />
<!-- 4: interpret reorder results -->
<transform from="UNITED" to="OK" />
<transform from="UNTIED" to="FAIL" />
<!-- 6: if untransformed, BX is a failure. -->
<transform from=":B\m{.}X\m{.}" to=":FAIL"/>
<transform from="ABC\m{8ctxt}(8:ctxt):FAIL" to="$1:OK" />
<transform from="𐓏\m{8ctxt}(8:ctxt):FAIL" to="$1:OK" />
<transform from="𐒻𐒷\m{8ctxt}(8:ctxt):FAIL" to="$1:OK" />
</transformGroup>
</transforms>

Expand Down

0 comments on commit 066b438

Please sign in to comment.