test sweep: cover BufferLine + CellAnchor (T-91)

Adds test/terminal/buffer/line_test.dart — 51 unit tests covering
BufferLine and CellAnchor, hitting every reachable line in
lib/src/terminal/src/core/buffer/line.dart (192 / 192).

Coverage delta:
- line.dart: 0 / 194 → 192 / 192 (file shrank by two lines after
  the prior commit's iteration fix folded two for-loop heads into
  for-each-toList).
- Total project: 36.39% → 39.12%.
- pubspec.yaml `coverage_floor:` bumped 36 → 39 in lockstep.

Highlights:
- All packed-cell encodings (foreground/background/attrs/content
  channels, codepoint+width packing, CellData round-trips).
- `eraseRange` wide-char neighbor extension on both ends.
- `removeCells` / `insertCells` shift logic, anchor reposition, and
  the wide-tail-erase branch (insertCells case where the post-shift
  last cell carries a wide marker).
- `resize` exercising the [64, 256) capacity-doubling branch and
  the >=256 +32 branch separately.
- `getTrimmedLength` cols-clamp behaviour for null/over-capacity.
- `getText` skip-trailing-wide-char branch.
- `CellAnchor` lifecycle: detached construction, `reposition`,
  `reparent` (both detached→attached and between owners), `dispose`,
  attached y/offset via a real IndexAwareCircularBuffer.

Also cleans up five `unrelated_type_equality_checks` analyze infos
in test/terminal/buffer/range_test.dart by typing the RHS as Object
when intentionally probing the type-mismatch branch of operator==.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-05-06 23:03:21 +02:00
co-authored by Claude
parent 1d75e8e1cd
commit c744c8ce4b
5 changed files with 556 additions and 7 deletions
+10 -5
View File
@@ -18,7 +18,8 @@ void main() {
expect(a.hashCode, b.hashCode);
expect(a.isEqual(b), isTrue);
expect(identical(a, a), isTrue); // hits the identity branch in ==
expect(a == 'CellOffset(3, 5)', isFalse); // hits the type-mismatch branch
const Object notACellOffset = 'CellOffset(3, 5)';
expect(a == notACellOffset, isFalse); // hits the type-mismatch branch
});
test('inequality for different coordinates', () {
@@ -119,7 +120,8 @@ void main() {
expect(a, b);
expect(a.hashCode, b.hashCode);
expect(a, isNot(c));
expect(a == 'segment', isFalse);
const Object notASegment = 'segment';
expect(a == notASegment, isFalse);
expect(identical(a, a), isTrue);
});
@@ -217,7 +219,8 @@ void main() {
expect(a, b);
expect(a.hashCode, b.hashCode);
expect(a, isNot(c));
expect(a == 'line range', isFalse);
const Object notALineRange = 'line range';
expect(a == notALineRange, isFalse);
expect(identical(a, a), isTrue);
expect(a.toString(), startsWith('Line Range('));
});
@@ -304,7 +307,8 @@ void main() {
expect(a, b);
expect(a.hashCode, b.hashCode);
expect(a, isNot(c));
expect(a == 'block range', isFalse);
const Object notABlockRange = 'block range';
expect(a == notABlockRange, isFalse);
expect(identical(a, a), isTrue);
expect(a.toString(), startsWith('Block Range('));
});
@@ -330,7 +334,8 @@ void main() {
expect(a, b); // same begin + end via base ==
expect(a.hashCode, b.hashCode);
expect(a, isNot(c));
expect(a == 'not a range', isFalse); // type-mismatch branch
const Object notARange = 'not a range';
expect(a == notARange, isFalse); // type-mismatch branch
expect(identical(a, a), isTrue);
expect(a.toString(), 'Range(CellOffset(0, 0), CellOffset(1, 1))');
});