test sweep: cover EscapeParser + EscapeEmitter (T-91)
Adds test/terminal/escape/parser_test.dart — 70 unit tests covering the parser's dispatch surface end-to-end: - single-byte controls (BEL, BS, HT, LF/VT/FF, CR, SO, SI), - ESC sequences (D, E, H, M, =, >, 7, 8, ( name, ) name, unknown), - CSI cursor moves (A/B/C/D/E/F/G/H/d/f) with default + 0-as-1 fallback semantics, - erase / scroll / line-insert/delete / chars (J, K, L, M, P, S, T, X, @, b, g, r), - device attributes (c / >c / =c) and DSR (5, 6), - window manipulation (CSI 8 t resize, CSI 18 t sendSize, ignored no-op codes, malformed CSI 8 t), - mode set/reset (h/l, ? prefix for DEC modes — covering ?1, ?3, ?5, ?6, ?7, ?9, ?12, ?25, ?47, ?66, ?1000, ?1002, ?1003, ?1004, ?1005, ?1006, ?1007, ?1015, ?1047, ?1048, ?1049, ?2004, + unknown fallback), - SGR styling (resets, set/unset for every attr, 16-colour foreground + background, 256-colour, 24-bit RGB, 39 / 49 resets, unknown → unsupportedStyle), - OSC 0/1/2 (BEL- and ST-terminated), unknown OSC, incomplete sequence held back across writes, - unknown CSI final byte → unknownCSI, - token bookkeeping (tokenBegin / tokenEnd advance with consumed bytes). Plus EscapeEmitter — every reply string format (primary / secondary / tertiary device attributes, operating status, cursor position, bracketed paste, size). Coverage delta: - parser.dart: 0 / 462 → 504 / 514 (98.1%; the remaining 10 lines sit inside the `// ignore: dead_code` SGR loop, which I'm surfacing for separate review rather than extending tests around). - emitter.dart: 1 / 11 → 11 / 11. - Total project: 43.20% → 49.38%; coverage_floor bumped 43 → 49. Two real source-code issues found while writing tests, fixed in the same commit: 1. Swapped docstrings on `_escHandleSetAppKeypadMode` / `_escHandleResetAppKeypadMode`. The function names + dispatch table + bodies all match the VT spec correctly (ESC = enables, ESC > disables); only the doc-comments were swapped. Now read the right way around. 2. `case 10061000:` in `_setDecMode` was unreachable (no DEC mode has that value). Almost certainly a typo where `case 1006:` meant to glue onto `case 1000:` but a newline went missing. Mode 1006 is already handled separately at its own clause as `MouseReportMode.sgr`. Removed. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -175,17 +175,17 @@ class EscapeParser {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// `ESC >` Reset Application Keypad Mode (DECKPNM)
|
||||
/// `ESC =` Set Application Keypad Mode (DECKPAM)
|
||||
///
|
||||
/// https://terminalguide.namepad.de/seq/a_esc_x3c_greater_than/
|
||||
/// https://terminalguide.namepad.de/seq/a_esc_x3d_equals/
|
||||
bool _escHandleSetAppKeypadMode() {
|
||||
handler.setAppKeypadMode(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// `ESC =` Set Application Keypad Mode (DECKPAM)
|
||||
/// `ESC >` Reset Application Keypad Mode (DECKPNM)
|
||||
///
|
||||
/// https://terminalguide.namepad.de/seq/a_esc_x3d_equals/
|
||||
/// https://terminalguide.namepad.de/seq/a_esc_x3c_greater_than/
|
||||
bool _escHandleResetAppKeypadMode() {
|
||||
handler.setAppKeypadMode(false);
|
||||
return true;
|
||||
@@ -982,7 +982,6 @@ class EscapeParser {
|
||||
case 66:
|
||||
return handler.setAppKeypadMode(enabled);
|
||||
case 1000:
|
||||
case 10061000:
|
||||
return enabled ? handler.setMouseMode(MouseMode.upDownScroll) : handler.setMouseMode(MouseMode.none);
|
||||
case 1001:
|
||||
return enabled ? handler.setMouseMode(MouseMode.upDownScroll) : handler.setMouseMode(MouseMode.none);
|
||||
|
||||
Reference in New Issue
Block a user