Skip to content

Commit

Permalink
Merge pull request #10304 from keymanapp/feat/core/9121-more-regex-ep…
Browse files Browse the repository at this point in the history
…ic-ldml

feat(core): more regex testing 🙀
  • Loading branch information
srl295 authored Jan 3, 2024
2 parents 3190391 + 0c3d1b5 commit f42f759
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
69 changes: 69 additions & 0 deletions core/tests/unit/ldml/keyboards/k_007_transform_rgx-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,73 @@
<check result="ayy" />
</test>
</tests>
<tests name="regex-coverage-set">
<test name="regex-coverage-set-0">
<keystroke key="e"/>
<keystroke key="x"/>
<check result="ex"/> <!-- no change-->
</test>
<test name="regex-coverage-set-1">
<keystroke key="A"/>
<keystroke key="x"/>
<check result="Z"/>
</test>
<test name="regex-coverage-set-2">
<keystroke key="Y"/>
<keystroke key="Y"/>
<keystroke key="x"/>
<check result="Z"/>
</test>
</tests>
<tests name="regex-coverage-quantifiers">
<test name="regex-coverage-quantifiers-0">
<keystroke key="e"/>
<keystroke key="z"/>
<check result="ez"/>
</test>
<test name="regex-coverage-quantifiers-1">
<keystroke key="e"/>
<keystroke key="z"/>
<keystroke key="z"/>
<check result="E"/>
</test>
<test name="regex-coverage-quantifiers-2">
<keystroke key="e"/>
<keystroke key="z"/>
<keystroke key="z"/>
<keystroke key="z"/>
<check result="Ez"/> <!-- ezz matches first -->
</test>
<test name="regex-coverage-quantifiers-3">
<keystroke key="e"/>
<keystroke key="z"/>
<keystroke key="z"/>
<keystroke key="z"/>
<keystroke key="z"/>
<check result="Ezz"/>
</test>
<test name="regex-coverage-quantifiers-1b">
<keystroke key="e"/>
<keystroke key="zz"/>
<check result="E"/> <!-- zz captured in one go-->
</test>
<test name="regex-coverage-quantifiers-2b">
<keystroke key="e"/>
<keystroke key="zzz"/>
<check result="E"/> <!-- zzz captured in one go-->
</test>
<test name="regex-coverage-quantifiers-3b">
<keystroke key="e"/>
<keystroke key="zzzz"/>
<check result="ezzzz"/> <!-- zzzz did not match (too many -->
<backspace />
<check result="ezzz"/>
<keystroke key="z" />
<check result="ezzzz"/> <!-- back to where we just were-->
<backspace />
<backspace />
<keystroke key="z" /> <!-- ezz + z => E-->
<check result="E"/>
</test>
</tests>
</keyboardTest3>
10 changes: 9 additions & 1 deletion core/tests/unit/ldml/keyboards/k_007_transform_rgx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ from https://github.com/unicode-org/cldr/blob/keyboard-preview/docs/ldml/tr35-ke

<keys>
<key id="grave" output="`"/>
<key id="zz" output="zz" />
<key id="zzz" output="zzz" />
<key id="zzzz" output="zzzz" />
</keys>

<layers formId="us">
Expand All @@ -24,7 +27,7 @@ from https://github.com/unicode-org/cldr/blob/keyboard-preview/docs/ldml/tr35-ke
<row keys="grave 1 2 3 4 5 6 7 8 9 0" />
<row keys="Q W E R T Y U I O P" />
<row keys="A S D F G H J K L" />
<row keys="Z X C V B N M" />
<row keys="Z X C V zz zzz zzzz" />
<row keys="space" />
</layer>
</layers>
Expand All @@ -38,6 +41,11 @@ from https://github.com/unicode-org/cldr/blob/keyboard-preview/docs/ldml/tr35-ke
<transformGroup>
<transform from="([abc])`([def])" to="$2`$1"/> <!-- flip the order: a`e » e`a -->
<transform from="($[upper])`" to="$[1:lower]"/> <!-- Lowercase (and drop grave): A` » a -->
<transform from="$[upper]x" to="Z" />
<transform from="$[upper]x" to="Z" />
</transformGroup>
<transformGroup>
<transform from="ez{2,3}" to="E" />
</transformGroup>
</transforms>
</keyboard3>

0 comments on commit f42f759

Please sign in to comment.