test sweep: cover utils/ + core/mouse/ (T-91)

Adds two test files closing the last two pure-Dart sub-areas in
`lib/src/terminal/src/`:

`test/terminal/utils/utils_test.dart` — 51 tests covering:
- Ascii.isNonPrintable (control chars + DEL).
- hashValues (every optional arg slot, 2..20 inclusive) +
  hashList (including the documented zero-on-empty short-circuit).
- ByteConsumer (single-block + cross-block consume, peek's
  consume-rollback path, rollback within block + across consumed
  blocks, rollbackTo, unrefConsumedBlocks, reset).
- IndexAwareCircularBuffer (push/trim, pushAll, pop, [] / []=,
  clear, forEach, remove with count clamp / no-op, insert in the
  middle / at end / at full ring, insertAll, trimStart, replaceWith
  with truncate-from-head, swap, maxLength setter incl. error +
  no-op cases, debugDump, IndexedItem mixin attach/detach/index).
- UnicodeV11.wcwidth (control chars, printable ASCII, DEL+C1,
  combining marks BMP+high-plane, wide chars BMP+high-plane,
  unmapped high-plane default, version field).
- The push wrap branch where _startIndex resets to 0 after a full
  revolution (last circular_buffer line).

`test/terminal/mouse/mouse_test.dart` — 21 tests covering:
- TerminalMouseButton ids + isWheel for the 7 enum values.
- MouseReporter for all four MouseReportMode shapes (normal with
  >223 null-byte clamp, utf with the 2015-limit clamp, sgr's M/m
  pair, urxvt's button+32 / 3-on-up encoding).
- TerminalMouseEvent constructor.
- CascadeMouseHandler first-non-null semantics.
- ClickMouseHandler — only fires on clickOnly + down + button id
  < 3; null otherwise. UpDownMouseHandler — fires on every
  upDownScroll* mode; drops wheel-up; passes wheel-down. Default
  defaultMouseHandler routes through both.

Coverage delta:
- utils/ascii.dart: 0/2 → 2/2.
- utils/byte_consumer.dart: 28/42 → 42/42.
- utils/circular_buffer.dart: 71/130 → 130/130.
- utils/hash_values.dart: 16/36 → 36/36.
- utils/unicode_v11.dart: 16/27 → 27/27.
- core/mouse/handler.dart: 3/34 → 34/34.
- core/mouse/reporter.dart: 0/17 → 17/17.
- (utils/char_code.dart, utils/lookup_table.dart already at 100%
  from earlier reflow + parser work; mouse/button.dart,
  mouse/button_state.dart, mouse/mode.dart are pure enums with no
  executable lines.)
- Total project: 54.62% → 56.40%; coverage_floor bumped 54 → 56.

Two pre-existing `// ignore_for_file: constant_identifier_names`
suppressions that lacked documented reasons get inline
justifications:
- `lib/src/terminal/src/utils/ascii.dart` — RFC 20 / ISO 646
  control-character names; lowerCamelCase would diverge from every
  spec/man-page reference.
- `lib/src/terminal/src/utils/unicode_v11.dart` — Unicode 11
  wcwidth tables vendored as-is; future re-vendoring stays a
  verbatim paste.

Both fall under the same "FFI / spec-shaped names" pattern as the
libc.dart suppression (D-66 era).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-07 08:13:07 +02:00
co-authored by Claude
parent 6caa82597e
commit 6008b4914c
6 changed files with 872 additions and 110 deletions
+116 -109
View File
@@ -1,5 +1,5 @@
{
"exported_at": "2026-05-07T05:58:44Z",
"exported_at": "2026-05-07T06:13:07Z",
"decisions": [
{
"id": "D-1",
@@ -9,7 +9,7 @@
"status": "active",
"date": "2026-04-20",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-3",
@@ -19,7 +19,7 @@
"status": "active",
"date": "2026-04-20",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-4",
@@ -29,7 +29,7 @@
"status": "active",
"date": "2026-04-20",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-5",
@@ -39,7 +39,7 @@
"status": "active",
"date": "2026-04-20",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-6",
@@ -49,7 +49,7 @@
"status": "active",
"date": "2026-04-20",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-7",
@@ -59,7 +59,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-8",
@@ -69,7 +69,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-9",
@@ -79,7 +79,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-10",
@@ -89,7 +89,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-11",
@@ -99,7 +99,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-12",
@@ -109,7 +109,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-13",
@@ -119,7 +119,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-14",
@@ -129,7 +129,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-15",
@@ -139,7 +139,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-16",
@@ -149,7 +149,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-17",
@@ -159,7 +159,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-18",
@@ -169,7 +169,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-19",
@@ -179,7 +179,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-20",
@@ -189,7 +189,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/accessibility.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-21",
@@ -199,7 +199,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/accessibility.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-22",
@@ -209,7 +209,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/accessibility.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-23",
@@ -219,7 +219,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-24",
@@ -229,7 +229,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-25",
@@ -239,7 +239,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-26",
@@ -249,7 +249,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-27",
@@ -259,7 +259,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-28",
@@ -269,7 +269,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-29",
@@ -279,7 +279,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-30",
@@ -289,7 +289,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-31",
@@ -299,7 +299,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-32",
@@ -309,7 +309,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-33",
@@ -319,7 +319,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-34",
@@ -329,7 +329,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-35",
@@ -339,7 +339,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-36",
@@ -349,7 +349,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-37",
@@ -359,7 +359,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-38",
@@ -369,7 +369,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-39",
@@ -379,7 +379,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-40",
@@ -389,7 +389,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-41",
@@ -399,7 +399,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-42",
@@ -409,7 +409,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-43",
@@ -419,7 +419,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-44",
@@ -429,7 +429,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-45",
@@ -439,7 +439,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-46",
@@ -449,7 +449,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-47",
@@ -459,7 +459,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-48",
@@ -469,7 +469,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-49",
@@ -479,7 +479,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-50",
@@ -489,7 +489,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-51",
@@ -499,7 +499,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-52",
@@ -509,7 +509,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-53",
@@ -519,7 +519,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-54",
@@ -529,7 +529,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-55",
@@ -539,7 +539,7 @@
"status": "active",
"date": "2026-04-23",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-56",
@@ -549,7 +549,7 @@
"status": "active",
"date": "2026-04-23",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-57",
@@ -559,7 +559,7 @@
"status": "active",
"date": "2026-04-23",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-58",
@@ -569,7 +569,7 @@
"status": "active",
"date": "2026-04-23",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-59",
@@ -579,7 +579,7 @@
"status": "active",
"date": "2026-04-25",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-60",
@@ -589,7 +589,7 @@
"status": "active",
"date": "2026-04-26",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-61",
@@ -599,7 +599,7 @@
"status": "active",
"date": "2026-04-26",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-62",
@@ -609,7 +609,7 @@
"status": "active",
"date": "2026-04-26",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-63",
@@ -619,7 +619,7 @@
"status": "active",
"date": "2026-04-26",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-64",
@@ -629,7 +629,7 @@
"status": "active",
"date": "2026-05-03",
"file_path": "decisions/architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-65",
@@ -639,7 +639,7 @@
"status": "active",
"date": "2026-04-26",
"file_path": "decisions/tooling.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "D-66",
@@ -649,7 +649,7 @@
"status": "active",
"date": "2026-05-06",
"file_path": "decisions/testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-1",
@@ -658,7 +658,7 @@
"title": "Authorisation granularity on the IPC socket",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-2",
@@ -667,7 +667,7 @@
"title": "Back-pressure on event streams",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-3",
@@ -676,7 +676,7 @@
"title": "Event persistence + audit/undo",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-4",
@@ -685,7 +685,7 @@
"title": "`.canvas` schema compatibility with Obsidian",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-5",
@@ -694,7 +694,7 @@
"title": "IPC wire-format stability + `schema_version:`",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-6",
@@ -703,7 +703,7 @@
"title": "Window chrome — native frame vs frameless custom",
"status": "resolved",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-7",
@@ -712,7 +712,7 @@
"title": "macOS app bundle signing / notarisation",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-8",
@@ -721,7 +721,7 @@
"title": "Extension API shape — widgets, subcommands, both?",
"status": "open",
"file_path": "decisions/questions-extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-9",
@@ -730,7 +730,7 @@
"title": "Lua runtime vendoring",
"status": "open",
"file_path": "decisions/questions-extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-10",
@@ -739,7 +739,7 @@
"title": "Extension manifest `schema_version:`",
"status": "open",
"file_path": "decisions/questions-extensions.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-11",
@@ -748,7 +748,7 @@
"title": "Coverage gates — hard thresholds vs soft reporting",
"status": "open",
"file_path": "decisions/questions-testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-12",
@@ -757,7 +757,7 @@
"title": "Screen-reader automation (axe-core via Playwright)",
"status": "open",
"file_path": "decisions/questions-testing.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-13",
@@ -766,7 +766,7 @@
"title": "Web production-mode a11y",
"status": "open",
"file_path": "decisions/questions-accessibility.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-14",
@@ -775,7 +775,7 @@
"title": "i18n plurals / gender / date-format tooling",
"status": "open",
"file_path": "decisions/questions-accessibility.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-15",
@@ -784,7 +784,7 @@
"title": "Editor tab — full LSP vs tree-sitter-only highlight",
"status": "open",
"file_path": "decisions/questions-process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-16",
@@ -793,7 +793,7 @@
"title": "`tree-sitter-dart` grammar maintenance",
"status": "open",
"file_path": "decisions/questions-process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-17",
@@ -802,7 +802,7 @@
"title": "Icon set growth",
"status": "open",
"file_path": "decisions/questions-process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-18",
@@ -811,7 +811,7 @@
"title": "Theme hot-reload in release builds",
"status": "open",
"file_path": "decisions/questions-process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-19",
@@ -820,7 +820,7 @@
"title": "(withdrawn)",
"status": "resolved",
"file_path": "decisions/questions-process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-20",
@@ -829,7 +829,7 @@
"title": "Kernel DB service — namespaced SQL access?",
"status": "open",
"file_path": "decisions/questions-process.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-21",
@@ -838,7 +838,7 @@
"title": "Pql absorbs planning vs keeps separate",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-22",
@@ -847,7 +847,7 @@
"title": "Ticket persistence strategy",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-23",
@@ -856,7 +856,7 @@
"title": "SSH-remote development — run clide against a remote workspace",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-25",
@@ -865,7 +865,7 @@
"title": "Body text face — mono everywhere vs Josefin Sans UI + mono code",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-26",
@@ -874,7 +874,7 @@
"title": "Small screen layout (\u003c 1000px)",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-27",
@@ -883,7 +883,7 @@
"title": "Two-editor split",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-28",
@@ -892,7 +892,7 @@
"title": "Terminal strip scope — shell only or logs/errors/tests",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-29",
@@ -901,7 +901,7 @@
"title": "Branch picker location",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-30",
@@ -910,7 +910,7 @@
"title": "Focus behavior when editor is dirty and viewer is peeked",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "Q-31",
@@ -919,7 +919,7 @@
"title": "XWayland fallback for frameless — proper Wayland protocol needed",
"status": "open",
"file_path": "decisions/questions-architecture.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-2",
@@ -929,7 +929,7 @@
"status": "active",
"date": "2026-04-20",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-3",
@@ -939,7 +939,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-4",
@@ -949,7 +949,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-5",
@@ -959,7 +959,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-6",
@@ -969,7 +969,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-7",
@@ -979,7 +979,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-8",
@@ -989,7 +989,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-9",
@@ -999,7 +999,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-10",
@@ -1009,7 +1009,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-11",
@@ -1019,7 +1019,7 @@
"status": "active",
"date": "2026-04-21",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
},
{
"id": "R-12",
@@ -1029,7 +1029,7 @@
"status": "active",
"date": "2026-04-22",
"file_path": "decisions/rejected.md",
"synced_at": "2026-05-07 05:57:38"
"synced_at": "2026-05-07 06:10:54"
}
],
"decision_refs": [
@@ -2797,10 +2797,10 @@
"type": "bug",
"title": "reflow tail-anchor reparenting can dangle on partially-filled lines",
"description": "**File:** `lib/src/terminal/src/core/reflow.dart` (`_LineReflow._addPart`).\n\n**Bug:** Anchors whose x-coordinate sits past the source line's `trimmedLength` get reparented onto whatever `_builder._result` is active at that moment. After the main reparenting loop has run with `lineFilled` on the final iteration, `_builder.take()` has already moved the filled line into `_lines` and reset `_result` to a fresh empty `BufferLine`. The post-loop block (lines 144-150 in the current source) then reparents the tail anchor onto that fresh empty line. If no further content lands in the builder before `finish()` exits — which is the case whenever the post-loop block fires on a non-wrapped logical line — the empty builder line is never appended to `_lines`, and the anchor ends up pointing to a `BufferLine` that the reflow result never includes.\n\n**Trigger paths in production code:**\n\n1. `SelectAllTextIntent` (`lib/src/terminal/src/ui/shortcut/actions.dart:60-63`) creates the end anchor at `x = terminal.viewWidth`. That is *exactly* the past-trimmedLength position for every partially-filled line in the buffer. Any user who Ctrl+A's and then resizes the terminal narrower hits the bug for every short line in the scrollback.\n2. `selectCharacters` / mouse drag selection (`lib/src/terminal/src/ui/render.dart:286-298`) — anchors are clamped to `[0, viewWidth-1]` but can sit past `trimmedLength` on a partially-filled line. Drag past content end + resize narrower trips the bug.\n3. `selectWord` (`render.dart:264-275`) — `getWordBoundary` walks until a separator OR `viewWidth`, so the end anchor of a near-edge word can land at `x = viewWidth` and trip the bug on resize.\n\n**Symptom:** selection extents lose track of content after a width change. Visible highlight stops moving with the underlying selection, or extents disappear off the rendered buffer entirely. No exception is thrown — the dangling anchor still has a valid `BufferLine` reference, it just isn't on a line in the visible buffer.\n\n**Acceptance:**\n- New unit test in `test/terminal/core/core_test.dart` (or a sibling) that:\n - Constructs a partially-filled source line and an anchor past `trimmedLength`,\n - Runs reflow shrink,\n - Asserts the anchor's owning line is *in the reflow output list*, not dangling.\n- The existing widget-level select-all behaviour still works on resize: a Ctrl+A across the buffer followed by a narrower resize keeps the selection's end anchor pointing to a line in the reflowed result.\n- No regression in the existing reflow tests (the tail-clamp cases, wide-char boundaries, multi-line wrapped runs).\n\n**Investigation notes (do not skip):**\n\nThe fix is conceptually small — the reparented tail anchor must land on a line that gets emitted. Two candidate shapes:\n\n- **Skip the reparent entirely.** Anchors past `trimmedLength` arguably shouldn't survive a shrink that drops their column. Risk: callers expect every anchor on the source to be reparented somewhere; silently disposing them changes semantics.\n- **Force `finish()` to flush the builder line.** Whenever the tail-anchor branch fired during `_addPart`, set a flag, and have `finish()` emit the builder line even if `isEmpty`. Risk: empty trailing lines start showing up in the reflow result, which would break callers that assume reflow returns only content lines (resize loop in `Buffer.resize` pads to viewport height after, so an extra empty might be benign there but worth checking).\n\nDon't pick one without re-reading the full reflow flow + every caller of `reflow()`. The selection round-trip is also tested at the widget layer indirectly — verify `make test-a11y` still passes after the change.\n\n**Surfaced from:** T-91 test sweep (commit 3196c49). The 100% coverage on reflow.dart was achieved by exercising this branch but explicitly *not* asserting on the resulting line being in the output — see the test comment.\n\n**Cross-references:** T-91 (epic parent for the test sweep that found this), T-89 (coverage epic), the test in `test/terminal/core/core_test.dart` group `reflow` named \"anchors on the source line tail (past trimmedLength) get reparented\" documents the current (buggy) behaviour.\n",
"status": "in_progress",
"status": "done",
"priority": "high",
"created_at": "2026-05-07 05:51:48",
"updated_at": "2026-05-07 05:56:47"
"updated_at": "2026-05-07 05:58:51"
}
],
"ticket_deps": null,
@@ -4452,6 +4452,13 @@
"old_value": "backlog",
"new_value": "in_progress",
"changed_at": "2026-05-07 05:56:47"
},
{
"ticket_id": "T-92",
"field": "status",
"old_value": "in_progress",
"new_value": "done",
"changed_at": "2026-05-07 05:58:51"
}
]
}
+7
View File
@@ -1,5 +1,12 @@
// Based on xterm.dart v4.0.0 by xuty (MIT). See LICENSE in this directory.
// The constants below mirror the historical ASCII control-character
// names from RFC 20 / ISO 646 (NULL, SOH, STX, ETX, EOT, ENQ, ACK, BEL,
// BS, HT, LF, VT, FF, CR, SO, SI, DLE, DC1..4, NAK, SYN, ETB, CAN, EM,
// SUB, ESC, FS, GS, RS, US, DEL). Renaming them to lowerCamelCase
// would diverge from every spec, man page, and upstream reference the
// reader is likely to consult — the lint works against the file.
//
// ignore_for_file: constant_identifier_names
abstract class Ascii {
@@ -1,5 +1,12 @@
// Based on xterm.dart v4.0.0 by xuty (MIT). See LICENSE in this directory.
// `BMP_COMBINING`, `HIGH_COMBINING`, `BMP_WIDE`, `HIGH_WIDE` are the
// names used by the upstream Unicode 11 wcwidth tables (xterm.dart
// vendored from the standard wcwidth implementation). Renaming them
// to lowerCamelCase would force every diff against an updated upstream
// table to be re-translated; keep the spec-shaped names so future
// re-vendoring is a verbatim paste.
//
// ignore_for_file: constant_identifier_names
import 'dart:typed_data';
+1 -1
View File
@@ -18,7 +18,7 @@ repository: https://github.com/postmeridiem/clide
# Pre-push line-coverage floor. Ratchets up only — see D-66.
# Reading: `awk -F: '/^coverage_floor:/ {gsub(/ /,"",$2); print $2}' pubspec.yaml`.
coverage_floor: 54
coverage_floor: 56
# Project metadata (was project.yaml, folded in per D-056).
# version: above is the single source of truth. The Makefile reads
+304
View File
@@ -0,0 +1,304 @@
/// Pure-Dart tests for `lib/src/terminal/src/core/mouse/`.
library;
import 'package:clide/src/terminal/src/core/buffer/cell_offset.dart';
import 'package:clide/src/terminal/src/core/cursor.dart';
import 'package:clide/src/terminal/src/core/mouse/button.dart';
import 'package:clide/src/terminal/src/core/mouse/button_state.dart';
import 'package:clide/src/terminal/src/core/mouse/handler.dart';
import 'package:clide/src/terminal/src/core/mouse/mode.dart';
import 'package:clide/src/terminal/src/core/mouse/reporter.dart';
import 'package:clide/src/terminal/src/core/platform.dart';
import 'package:clide/src/terminal/src/core/state.dart';
import 'package:test/test.dart';
class _State implements TerminalState {
_State({
this.mouseMode = MouseMode.none,
this.mouseReportMode = MouseReportMode.normal,
});
@override
MouseMode mouseMode;
@override
MouseReportMode mouseReportMode;
@override
int get viewWidth => 80;
@override
int get viewHeight => 24;
@override
CursorStyle get cursor => CursorStyle();
@override
bool get reflowEnabled => false;
@override
bool get insertMode => false;
@override
bool get lineFeedMode => false;
@override
bool get cursorKeysMode => false;
@override
bool get reverseDisplayMode => false;
@override
bool get originMode => false;
@override
bool get autoWrapMode => true;
@override
bool get cursorBlinkMode => true;
@override
bool get cursorVisibleMode => true;
@override
bool get appKeypadMode => false;
@override
bool get reportFocusMode => false;
@override
bool get altBufferMouseScrollMode => false;
@override
bool get bracketedPasteMode => false;
}
TerminalMouseEvent _evt(
TerminalMouseButton button,
TerminalMouseButtonState state, {
int x = 0,
int y = 0,
MouseMode mode = MouseMode.none,
MouseReportMode reportMode = MouseReportMode.normal,
TerminalTargetPlatform platform = TerminalTargetPlatform.linux,
}) {
return TerminalMouseEvent(
button: button,
buttonState: state,
position: CellOffset(x, y),
state: _State(mouseMode: mode, mouseReportMode: reportMode),
platform: platform,
);
}
void main() {
group('TerminalMouseButton', () {
test('left/middle/right have ids 0/1/2 and isWheel=false', () {
expect(TerminalMouseButton.left.id, 0);
expect(TerminalMouseButton.middle.id, 1);
expect(TerminalMouseButton.right.id, 2);
expect(TerminalMouseButton.left.isWheel, isFalse);
expect(TerminalMouseButton.middle.isWheel, isFalse);
expect(TerminalMouseButton.right.isWheel, isFalse);
});
test('wheel buttons are flagged isWheel and use the 64+N transposed ids', () {
expect(TerminalMouseButton.wheelUp.id, 64 + 4);
expect(TerminalMouseButton.wheelDown.id, 64 + 5);
expect(TerminalMouseButton.wheelLeft.id, 64 + 6);
expect(TerminalMouseButton.wheelRight.id, 64 + 7);
for (final b in [
TerminalMouseButton.wheelUp,
TerminalMouseButton.wheelDown,
TerminalMouseButton.wheelLeft,
TerminalMouseButton.wheelRight,
]) {
expect(b.isWheel, isTrue, reason: '$b');
}
});
});
group('MouseReporter (normal mode)', () {
String r(TerminalMouseButton b, TerminalMouseButtonState s, {int x = 0, int y = 0}) => MouseReporter.report(b, s, CellOffset(x, y), MouseReportMode.normal);
test('press encodes button id + 1-based coordinates', () {
// Position (0,0) → button code 32+0=32 (' '), col 32+1=33 ('!'),
// row 32+1+1=34 ('"').
expect(r(TerminalMouseButton.left, TerminalMouseButtonState.down), '\x1b[M !"');
});
test('release uses button id 3 regardless of which button was up', () {
expect(r(TerminalMouseButton.right, TerminalMouseButtonState.up), '\x1b[M#!"'); // 32+3='#' for the up code
});
test('coordinates beyond 223 (8-bit limit) emit a null byte', () {
final out = r(TerminalMouseButton.left, TerminalMouseButtonState.down, x: 300, y: 0);
expect(out, '\x1b[M \x00"'); // null in the column slot
});
});
group('MouseReporter (utf mode)', () {
test('uses the 2015 limit for the null-byte clamp', () {
// x=300 fits into utf mode (limit 2015) — should emit a real char.
final out = MouseReporter.report(TerminalMouseButton.left, TerminalMouseButtonState.down, const CellOffset(300, 0), MouseReportMode.utf);
expect(out.contains('\x00'), isFalse);
// x=3000 trips the utf limit.
final outBig = MouseReporter.report(TerminalMouseButton.left, TerminalMouseButtonState.down, const CellOffset(3000, 3000), MouseReportMode.utf);
expect(outBig.contains('\x00'), isTrue);
});
});
group('MouseReporter (sgr mode)', () {
test('M for press, m for release, with raw 1-based coords', () {
expect(
MouseReporter.report(TerminalMouseButton.middle, TerminalMouseButtonState.down, const CellOffset(10, 20), MouseReportMode.sgr),
'\x1b[<1;11;21M',
);
expect(
MouseReporter.report(TerminalMouseButton.middle, TerminalMouseButtonState.up, const CellOffset(10, 20), MouseReportMode.sgr),
'\x1b[<1;11;21m',
);
});
});
group('MouseReporter (urxvt mode)', () {
test('always M, button id +32 (3 for up, real for down)', () {
expect(
MouseReporter.report(TerminalMouseButton.left, TerminalMouseButtonState.down, const CellOffset(5, 7), MouseReportMode.urxvt),
'\x1b[32;6;8M', // 32+0 = 32 for left-button down
);
expect(
MouseReporter.report(TerminalMouseButton.left, TerminalMouseButtonState.up, const CellOffset(5, 7), MouseReportMode.urxvt),
'\x1b[35;6;8M', // 32+3 = 35 for any up
);
});
});
group('TerminalMouseEvent', () {
test('constructor exposes every field directly', () {
final e = _evt(TerminalMouseButton.left, TerminalMouseButtonState.down, x: 3, y: 5);
expect(e.button, TerminalMouseButton.left);
expect(e.buttonState, TerminalMouseButtonState.down);
expect(e.position, const CellOffset(3, 5));
expect(e.platform, TerminalTargetPlatform.linux);
expect(e.state, isA<TerminalState>());
});
});
group('CascadeMouseHandler', () {
test('returns the first non-null result; null when all return null', () {
const cascade = CascadeMouseHandler([
_NullHandler(),
_ConstHandler('first'),
_ConstHandler('second'),
]);
expect(
cascade(_evt(TerminalMouseButton.left, TerminalMouseButtonState.down)),
'first',
);
const allNull = CascadeMouseHandler([_NullHandler(), _NullHandler()]);
expect(
allNull(_evt(TerminalMouseButton.left, TerminalMouseButtonState.down)),
isNull,
);
});
});
group('ClickMouseHandler', () {
const h = ClickMouseHandler();
test('clickOnly mode + down + button id < 3 → reports', () {
final out = h(_evt(TerminalMouseButton.middle, TerminalMouseButtonState.down, mode: MouseMode.clickOnly));
expect(out, isNotNull);
});
test('clickOnly mode + up → null (only down events report)', () {
expect(
h(_evt(TerminalMouseButton.middle, TerminalMouseButtonState.up, mode: MouseMode.clickOnly)),
isNull,
);
});
test('clickOnly mode + button id >= 3 (wheel) → null', () {
expect(
h(_evt(TerminalMouseButton.wheelUp, TerminalMouseButtonState.down, mode: MouseMode.clickOnly)),
isNull,
);
});
test('non-clickOnly modes always return null', () {
for (final m in [
MouseMode.none,
MouseMode.upDownScroll,
MouseMode.upDownScrollDrag,
MouseMode.upDownScrollMove,
]) {
expect(
h(_evt(TerminalMouseButton.left, TerminalMouseButtonState.down, mode: m)),
isNull,
reason: '$m',
);
}
});
});
group('UpDownMouseHandler', () {
const h = UpDownMouseHandler();
test('none / clickOnly modes return null', () {
for (final m in [MouseMode.none, MouseMode.clickOnly]) {
expect(
h(_evt(TerminalMouseButton.left, TerminalMouseButtonState.down, mode: m)),
isNull,
);
}
});
test('upDownScroll modes report regular button events', () {
for (final m in [
MouseMode.upDownScroll,
MouseMode.upDownScrollDrag,
MouseMode.upDownScrollMove,
]) {
expect(
h(_evt(TerminalMouseButton.left, TerminalMouseButtonState.down, mode: m)),
isNotNull,
reason: '$m',
);
}
});
test('wheel up events are silently dropped (no report on wheel release)', () {
expect(
h(_evt(TerminalMouseButton.wheelUp, TerminalMouseButtonState.up, mode: MouseMode.upDownScroll)),
isNull,
);
});
test('wheel down events do report (one click per scroll tick)', () {
expect(
h(_evt(TerminalMouseButton.wheelDown, TerminalMouseButtonState.down, mode: MouseMode.upDownScroll)),
isNotNull,
);
});
});
group('defaultMouseHandler', () {
test('routes clickOnly through ClickMouseHandler', () {
final out = defaultMouseHandler(_evt(TerminalMouseButton.left, TerminalMouseButtonState.down, mode: MouseMode.clickOnly));
expect(out, isNotNull);
});
test('routes upDownScroll through UpDownMouseHandler', () {
final out = defaultMouseHandler(_evt(TerminalMouseButton.middle, TerminalMouseButtonState.up, mode: MouseMode.upDownScrollDrag));
expect(out, isNotNull);
});
test('mode=none produces null (no handler reports)', () {
expect(
defaultMouseHandler(
_evt(TerminalMouseButton.left, TerminalMouseButtonState.down, mode: MouseMode.none),
),
isNull,
);
});
});
}
class _NullHandler extends TerminalMouseHandler {
const _NullHandler();
@override
String? call(TerminalMouseEvent event) => null;
}
class _ConstHandler extends TerminalMouseHandler {
const _ConstHandler(this._value);
final String _value;
@override
String? call(TerminalMouseEvent event) => _value;
}
+437
View File
@@ -0,0 +1,437 @@
/// Pure-Dart tests for `lib/src/terminal/src/utils/`.
library;
import 'package:clide/src/terminal/src/utils/ascii.dart';
import 'package:clide/src/terminal/src/utils/byte_consumer.dart';
import 'package:clide/src/terminal/src/utils/circular_buffer.dart';
import 'package:clide/src/terminal/src/utils/hash_values.dart';
import 'package:clide/src/terminal/src/utils/unicode_v11.dart';
import 'package:test/test.dart';
class _Item with IndexedItem {
_Item(this.value);
final int value;
@override
String toString() => 'Item($value)';
}
void main() {
group('Ascii.isNonPrintable', () {
test('returns true for control chars (< 32) and DEL (127)', () {
expect(Ascii.isNonPrintable(0), isTrue);
expect(Ascii.isNonPrintable(31), isTrue);
expect(Ascii.isNonPrintable(127), isTrue);
});
test('returns false for printable range [32, 126]', () {
for (var i = 32; i < 127; i++) {
expect(Ascii.isNonPrintable(i), isFalse, reason: 'codepoint $i');
}
});
});
group('hashValues', () {
test('combines two args deterministically', () {
expect(hashValues(1, 2), hashValues(1, 2));
expect(hashValues(1, 2), isNot(hashValues(2, 1)));
});
test('extra args change the hash (covers each optional slot)', () {
// Walk through 3..20 inclusive — the cascade of nested ifs in
// hashValues is one branch per arg.
final base = hashValues(1, 2);
// Wrap up to 20 args; assert each adds entropy.
var prev = base;
final args = <Object?>[3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
for (var i = 0; i < args.length; i++) {
final next = Function.apply(hashValues, [1, 2, ...args.sublist(0, i + 1)]) as int;
expect(next, isNot(prev), reason: 'arg slot ${i + 3}');
prev = next;
}
});
test('hashList sums an iterable to a single hash', () {
expect(hashList([1, 2, 3]), hashList([1, 2, 3]));
expect(hashList([1, 2, 3]), isNot(hashList([3, 2, 1])));
// Empty iterable short-circuits — Jenkins.finish(0) == 0; document
// the contract rather than fight it.
expect(hashList(<Object>[]), 0);
});
});
group('ByteConsumer', () {
test('add + consume — basic single-block sequence', () {
final c = ByteConsumer();
c.add('abc');
expect(c.length, 3);
expect(c.isEmpty, isFalse);
expect(c.isNotEmpty, isTrue);
expect(c.consume(), 'a'.codeUnitAt(0));
expect(c.consume(), 'b'.codeUnitAt(0));
expect(c.consume(), 'c'.codeUnitAt(0));
expect(c.length, 0);
expect(c.totalConsumed, 3);
expect(c.isEmpty, isTrue);
});
test('add empty string is a no-op', () {
final c = ByteConsumer();
c.add('');
expect(c.length, 0);
});
test('consume across block boundaries (recursive consume path)', () {
final c = ByteConsumer();
c.add('ab');
c.add('cd');
expect(c.consume(), 'a'.codeUnitAt(0));
expect(c.consume(), 'b'.codeUnitAt(0));
// Crossing boundary: consume() recurses after _queue.removeFirst().
expect(c.consume(), 'c'.codeUnitAt(0));
expect(c.consume(), 'd'.codeUnitAt(0));
expect(c.length, 0);
});
test('peek returns the current head without consuming', () {
final c = ByteConsumer();
c.add('ab');
expect(c.peek(), 'a'.codeUnitAt(0));
expect(c.length, 2); // unchanged
});
test('peek across a block boundary uses consume+rollback', () {
final c = ByteConsumer();
c.add('ab');
c.add('cd');
c.consume();
c.consume();
// _currentOffset == 2, equal to first block length → peek takes the
// consume + rollback path.
expect(c.peek(), 'c'.codeUnitAt(0));
expect(c.length, 2);
});
test('rollback by 1 within current block', () {
final c = ByteConsumer();
c.add('abc');
c.consume();
c.consume();
c.rollback();
expect(c.length, 2);
expect(c.consume(), 'b'.codeUnitAt(0));
});
test('rollback across consumed blocks restores them', () {
final c = ByteConsumer();
c.add('ab');
c.add('cd');
c.consume();
c.consume();
c.consume(); // crosses boundary, moves first block to consumed
c.rollback(2); // span back across the boundary
expect(c.length, 3);
expect(c.consume(), 'b'.codeUnitAt(0));
});
test('rollbackTo restores the consumer to a previous length', () {
final c = ByteConsumer();
c.add('abcd');
c.consume();
c.consume();
c.rollbackTo(4); // back to the start
expect(c.length, 4);
});
test('unrefConsumedBlocks empties the consumed history', () {
final c = ByteConsumer();
c.add('ab');
c.add('cd');
c.consume();
c.consume();
c.consume(); // 'c' from second block; first block now in _consumed
c.unrefConsumedBlocks();
// Subsequent rollback within current block still works.
c.rollback();
expect(c.length, 2);
});
test('reset wipes everything', () {
final c = ByteConsumer();
c.add('abc');
c.consume();
c.reset();
expect(c.length, 0);
expect(c.totalConsumed, 0);
c.add('x');
expect(c.consume(), 'x'.codeUnitAt(0));
});
});
group('IndexAwareCircularBuffer', () {
test('push grows the list while length < maxLength', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.push(_Item(1));
r.push(_Item(2));
expect(r.length, 2);
expect(r[0].value, 1);
expect(r[1].value, 2);
expect(r.isFull, isFalse);
});
test('push past capacity trims the first element (FIFO ring)', () {
final r = IndexAwareCircularBuffer<_Item>(2);
r.push(_Item(1));
r.push(_Item(2));
r.push(_Item(3)); // trims item 1
expect(r.length, 2);
expect(r[0].value, 2);
expect(r[1].value, 3);
expect(r.isFull, isTrue);
});
test('push wraps _startIndex back to 0 after a full revolution', () {
final r = IndexAwareCircularBuffer<_Item>(2);
r.push(_Item(1));
r.push(_Item(2));
r.push(_Item(3)); // _startIndex 0 → 1
r.push(_Item(4)); // _startIndex 1 → 2 → wraps to 0
// Visible state: ring contains the most recent two items.
expect(r[0].value, 3);
expect(r[1].value, 4);
});
test('pushAll forwards each item through push', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2), _Item(3)]);
expect(r.toList().map((i) => i.value), [1, 2, 3]);
});
test('pop returns and removes the last item', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2)]);
expect(r.pop().value, 2);
expect(r.length, 1);
});
test('[]= replaces an element in place; [] reads it', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2)]);
r[0] = _Item(99);
expect(r[0].value, 99);
});
test('clear removes every element', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2)]);
r.clear();
expect(r.length, 0);
});
test('forEach iterates in order', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2), _Item(3)]);
final out = <int>[];
r.forEach((it) => out.add(it.value));
expect(out, [1, 2, 3]);
});
test('remove deletes a contiguous range and shifts trailing items left', () {
final r = IndexAwareCircularBuffer<_Item>(8);
r.pushAll([_Item(1), _Item(2), _Item(3), _Item(4), _Item(5)]);
r.remove(1, 2); // drops items 2 + 3
expect(r.toList().map((i) => i.value), [1, 4, 5]);
});
test('remove with count past end clamps to remaining length', () {
final r = IndexAwareCircularBuffer<_Item>(8);
r.pushAll([_Item(1), _Item(2), _Item(3)]);
r.remove(1, 99);
expect(r.toList().map((i) => i.value), [1]);
});
test('remove with count=0 is a no-op', () {
final r = IndexAwareCircularBuffer<_Item>(8);
r.pushAll([_Item(1), _Item(2)]);
r.remove(0, 0);
expect(r.length, 2);
});
test('insert at length delegates to push', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2)]);
r.insert(2, _Item(3));
expect(r.toList().map((i) => i.value), [1, 2, 3]);
});
test('insert in the middle shifts trailing items right', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2)]);
r.insert(1, _Item(99));
expect(r.toList().map((i) => i.value), [1, 99, 2]);
});
test('insert at index 0 of a full ring drops the new value', () {
// Documented contract: when ring is full, inserting at 0 immediately
// trims that same value, so the visible state is unchanged.
final r = IndexAwareCircularBuffer<_Item>(2);
r.pushAll([_Item(1), _Item(2)]);
r.insert(0, _Item(99));
expect(r.toList().map((i) => i.value), [1, 2]);
});
test('insert in the middle of a full ring trims the head', () {
final r = IndexAwareCircularBuffer<_Item>(3);
r.pushAll([_Item(1), _Item(2), _Item(3)]);
r.insert(1, _Item(99)); // ring full → head trimmed
expect(r.length, 3);
});
test('insertAll preserves order', () {
final r = IndexAwareCircularBuffer<_Item>(8);
r.pushAll([_Item(1), _Item(4)]);
r.insertAll(1, [_Item(2), _Item(3)]);
expect(r.toList().map((i) => i.value), [1, 2, 3, 4]);
});
test('insertAll truncates when target is full from the head', () {
final r = IndexAwareCircularBuffer<_Item>(2);
r.pushAll([_Item(1), _Item(2)]);
r.insertAll(0, [_Item(91), _Item(92), _Item(93)]);
expect(r.length, 2);
});
test('trimStart drops the leading [count] items in O(1)', () {
final r = IndexAwareCircularBuffer<_Item>(8);
r.pushAll([_Item(1), _Item(2), _Item(3), _Item(4)]);
r.trimStart(2);
expect(r.toList().map((i) => i.value), [3, 4]);
});
test('trimStart clamps to the current length', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1)]);
r.trimStart(10);
expect(r.length, 0);
});
test('replaceWith swaps the contents with a new list', () {
final r = IndexAwareCircularBuffer<_Item>(8);
r.pushAll([_Item(1), _Item(2)]);
r.replaceWith([_Item(10), _Item(20), _Item(30)]);
expect(r.toList().map((i) => i.value), [10, 20, 30]);
});
test('replaceWith truncates inputs longer than maxLength', () {
final r = IndexAwareCircularBuffer<_Item>(2);
r.replaceWith([_Item(1), _Item(2), _Item(3), _Item(4)]);
expect(r.toList().map((i) => i.value), [3, 4]); // last two kept
});
test('swap replaces the element and returns the old value', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2)]);
final old = r.swap(0, _Item(99));
expect(old.value, 1);
expect(r[0].value, 99);
});
test('maxLength setter rejects non-positive values', () {
final r = IndexAwareCircularBuffer<_Item>(4);
expect(() => r.maxLength = 0, throwsArgumentError);
expect(() => r.maxLength = -1, throwsArgumentError);
});
test('maxLength setter same value is a no-op', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1)]);
r.maxLength = 4;
expect(r.length, 1);
});
test('maxLength setter rebuilds the array, preserving order', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2), _Item(3)]);
r.maxLength = 8;
expect(r.maxLength, 8);
expect(r.toList().map((i) => i.value), [1, 2, 3]);
});
test('debugDump returns a multi-line string with each item', () {
final r = IndexAwareCircularBuffer<_Item>(4);
r.pushAll([_Item(1), _Item(2)]);
final s = r.debugDump();
expect(s, contains('CircularList:'));
expect(s, contains('Item(1)'));
expect(s, contains('Item(2)'));
});
test('IndexedItem mixin: index reflects ring position; attached toggles', () {
final r = IndexAwareCircularBuffer<_Item>(4);
final a = _Item(1);
expect(a.attached, isFalse);
r.push(a);
expect(a.attached, isTrue);
expect(a.index, 0);
r.push(_Item(2));
// After a.push, index stays absolute-relative; the buffer's index
// exposes regular 0-based.
r.pop(); // removes the newer item, leaves a in place at index 0
expect(a.attached, isTrue);
expect(a.index, 0);
r.pop(); // removes a
expect(a.attached, isFalse);
});
});
group('UnicodeV11.wcwidth', () {
final w = unicodeV11.wcwidth;
test('control chars (<32) are zero-width', () {
for (var c = 0; c < 32; c++) {
expect(w(c), 0, reason: 'codepoint $c');
}
});
test('printable ASCII is width 1', () {
for (var c = 32; c < 127; c++) {
expect(w(c), 1, reason: 'codepoint $c');
}
});
test('DEL + C1 controls are width 0 (table)', () {
expect(w(0x7f), 0); // DEL
for (var c = 0x80; c < 0xa0; c++) {
expect(w(c), 0, reason: 'C1 control $c');
}
});
test('combining marks (BMP_COMBINING) are width 0', () {
expect(w(0x0301), 0); // combining acute accent
expect(w(0x05BD), 0); // hebrew point meteg
});
test('CJK ideographs (BMP_WIDE) are width 2', () {
expect(w(0x4E2D), 2); // 中
expect(w(0x4F60), 2); // 你
});
test('high-plane combining marks return 0', () {
// Pull a known HIGH_COMBINING entry — variation-selector range.
expect(w(0xE0100), 0); // VARIATION SELECTOR-17
});
test('high-plane wide chars return 2', () {
// Emoji.
expect(w(0x1F600), 2); // GRINNING FACE
});
test('unmapped high codepoint defaults to width 1', () {
// 0x100000 is in PUA-B; not in HIGH_WIDE / HIGH_COMBINING.
expect(w(0x100000), 1);
});
test('UnicodeV11.version is the expected unicode version', () {
expect(UnicodeV11().version, '11');
});
});
}