"""Tests for CustomSlice in src/type_aliases.py Per-aggregate dataclass regression-guard for the metadata_promotion_20260624 track. CONVENTION: 1-space indentation. NO COMMENTS. """ from __future__ import annotations from dataclasses import FrozenInstanceError import pytest from src.type_aliases import CustomSlice def test_constructor_with_kwargs() -> None: cs = CustomSlice(tag="hotspot", comment="key section", start_line=10, end_line=20) assert cs.tag == "hotspot" assert cs.comment == "key section" assert cs.start_line == 10 assert cs.end_line == 20 def test_field_access() -> None: cs = CustomSlice(tag="x", start_line=5) assert cs.tag == "x" assert cs.start_line == 5 def test_frozen_raises_on_mutation() -> None: cs = CustomSlice() with pytest.raises(FrozenInstanceError): cs.tag = "x" def test_to_dict_roundtrip() -> None: cs = CustomSlice(tag="t", comment="c", start_line=1, end_line=5) d = cs.to_dict() assert d["tag"] == "t" assert d["comment"] == "c" assert d["start_line"] == 1 assert d["end_line"] == 5 def test_default_values() -> None: cs = CustomSlice() assert cs.tag == "" assert cs.comment == "" assert cs.start_line == 0 assert cs.end_line == 0 def test_hashability() -> None: cs = CustomSlice(tag="t") assert hash(cs) is not None