Skip to content

test(cpu): achieve 100% test coverage for cpu.py - #50

Merged
sql-hkr merged 1 commit into
mainfrom
test/cpu-coverage-100
Oct 27, 2026
Merged

sql-hkr merged 1 commit into
mainfrom
test/cpu-coverage-100

Conversation

@sql-hkr

@sql-hkr sql-hkr commented Oct 27, 2026

Copy link
Copy Markdown
Owner

What changed

Achieved 100% statement coverage for src/tiny8/cpu.py by covering previously missed lines and branches:

  • Added TestSER in tests/test_data_transfer.py to test the SER (Set Register) instruction (op_ser), both via assembly execution and direct method call.
  • Added test_run_rebuilds_predecoded_when_missing_or_mismatched in tests/test_cpu_edge_cases.py to verify that cpu.run() automatically rebuilds _predecoded during fast-path execution (trace_enabled=False) when it is missing or mismatched.
  • Added test_run_fast_path_not_implemented_instruction in tests/test_cpu_edge_cases.py to verify NotImplementedError is raised on unknown opcodes during fast-path execution.

How tested

  • uv run pytest --cov=tiny8.cpu --cov-report=term-missing:
    • src/tiny8/cpu.py: 548/548 statements, 100% coverage (0 missing lines).
    • 311/311 tests passed.
  • uv run ruff check tests/test_data_transfer.py tests/test_cpu_edge_cases.py: passed.
  • uv run ruff format --check tests/test_data_transfer.py tests/test_cpu_edge_cases.py: passed.

- Add tests for SER instruction (op_ser) in tests/test_data_transfer.py
- Add tests for fast-path rebuilding missing/mismatched predecoded list in tests/test_cpu_edge_cases.py
- Add tests for fast-path raising NotImplementedError on unhandled instructions in tests/test_cpu_edge_cases.py
@sql-hkr
sql-hkr merged commit 66d8eba into main Oct 27, 2026
4 checks passed
@sql-hkr
sql-hkr deleted the test/cpu-coverage-100 branch October 27, 2026 15:58
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant