Skip to content

Commit 27613d1

Browse files
kareltucekclaude
andcommitted
Add regression test for tapKeySeq code-expansion key drop
tapKeySeq drops a key when a code-expansion command (hexCodeOf / decCodeOf / altCodeOf / uCodeOf) appears earlier in the sequence. For example `tapKeySeq x y hexCodeOf(!) x y` types `x y 2 1 x` instead of `x y 2 1 x y`. This adds a TapKeySeq test module reproducing the bug on the right half. It currently fails (the key after the expansion is dropped); the fix follows in the next commit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7e69891 commit 27613d1

4 files changed

Lines changed: 54 additions & 0 deletions

File tree

right/src/test_suite/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ target_sources(${PROJECT_NAME} PRIVATE
1919
tests/test_sticky.c
2020
tests/test_playtime.c
2121
tests/test_transport.c
22+
tests/test_tapkeyseq.c
2223
)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include "tests.h"
2+
3+
// Regression test for a tapKeySeq bug: when a code-expansion command such as
4+
// hexCodeOf(...) sits in the middle of the sequence, the key that immediately
5+
// follows the expansion used to be dropped.
6+
//
7+
// `tapKeySeq x y hexCodeOf(!) x y` must type
8+
// x y 2 1 x y
9+
// ('!' == U+0021, so hexCodeOf(!) expands to the key sequence `2 1`). The bug
10+
// dropped the final key of the whole sequence whenever a code-expansion command
11+
// preceded it, so the tail came out as `... x` instead of `... x y`. Distinct
12+
// keys (x/y) around the expansion make a dropped key surface as a wrong-char
13+
// mismatch rather than only a timeout.
14+
static const test_action_t test_tapkeyseq_hexcode[] = {
15+
TEST_SET_MACRO("u",
16+
"tapKeySeq x y hexCodeOf(!) x y\n"
17+
),
18+
TEST_PRESS______("u"),
19+
TEST_DELAY__(20),
20+
// x
21+
TEST_EXPECT__________("x"),
22+
TEST_EXPECT__________(""),
23+
// y
24+
TEST_EXPECT__________("y"),
25+
TEST_EXPECT__________(""),
26+
// hexCodeOf(!) -> 2 1
27+
TEST_EXPECT__________("2"),
28+
TEST_EXPECT__________(""),
29+
TEST_EXPECT__________("1"),
30+
TEST_EXPECT__________(""),
31+
// x
32+
TEST_EXPECT__________("x"),
33+
TEST_EXPECT__________(""),
34+
// y (the final key of the sequence — the one the bug dropped)
35+
TEST_EXPECT__________("y"),
36+
TEST_EXPECT__________(""),
37+
TEST_RELEASE__U("u"),
38+
TEST_DELAY__(20),
39+
TEST_EXPECT__________(""),
40+
TEST_END()
41+
};
42+
43+
static const test_t tapkeyseq_tests[] = {
44+
{ .name = "tapkeyseq_hexcode", .actions = test_tapkeyseq_hexcode },
45+
};
46+
47+
const test_module_t TestModule_TapKeySeq = {
48+
.name = "TapKeySeq",
49+
.tests = tapkeyseq_tests,
50+
.testCount = sizeof(tapkeyseq_tests) / sizeof(tapkeyseq_tests[0])
51+
};

right/src/test_suite/tests/tests.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const test_module_t * const AllTestModules[] = {
1818
&TestModule_Sticky,
1919
&TestModule_Playtime,
2020
&TestModule_Transport,
21+
&TestModule_TapKeySeq,
2122
};
2223

2324
const uint16_t AllTestModulesCount = sizeof(AllTestModules) / sizeof(AllTestModules[0]);

right/src/test_suite/tests/tests.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ extern const test_module_t TestModule_ParserBenevolence;
3232
extern const test_module_t TestModule_Sticky;
3333
extern const test_module_t TestModule_Playtime;
3434
extern const test_module_t TestModule_Transport;
35+
extern const test_module_t TestModule_TapKeySeq;
3536

3637
#endif

0 commit comments

Comments
 (0)