|
| 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 | +}; |
0 commit comments