Skip to content

Add tasty test-suite for pure helpers. - #75

Merged
galenhuntington merged 2 commits into
masterfrom
claude/review-haskell-project-Y1EuR
May 17, 2026
Merged

Add tasty test-suite for pure helpers.#75
galenhuntington merged 2 commits into
masterfrom
claude/review-haskell-project-Y1EuR

Conversation

@galenhuntington

Copy link
Copy Markdown
Owner

Credit to Claude Code for this work:

The cabal file is restructured into a library plus executable plus
test-suite, sharing a common opts stanza for default extensions and
GHC options. The library exposes every module except Main so the
test-suite can import them directly.

Initial tests cover the pure logic that is easiest to nail down:

  • Lexer.doP/doF/doS/doI for the mpg123 protocol parsers,
  • Tree.doOrphans and Tree.merge (including the value-order
    behavior of the latter),
  • FastIO.basenameP/dirnameP/trim/packedFileNameEndClean,
  • Core.showTimeDiff_ across the four output branches.

Lexer.doP/doF/doS/doI and Core.showTimeDiff_ are added to their
module export lists for testability.

CI runs cabal build all && cabal test all and stack test; the build
step is kept because cabal test does not build the executable.

Putting Main.hs under app/ gives the executable a non-overlapping
source directory and lets the library do its job: compiled once, linked
into both the executable and the test-suite.

Lexer-relevant types in Syntax now derive Eq and Show, which lets
LexerSpec compare whole Msg values directly instead of pattern-
matching out individual fields. The tests get noticeably shorter.

claude added 2 commits May 17, 2026 04:24
The cabal file is restructured into a library plus executable plus
test-suite, sharing a `common opts` stanza for default extensions and
GHC options.  The library exposes every module except `Main` so the
test-suite can import them directly.

Initial tests cover the pure logic that is easiest to nail down:

  * `Lexer.doP`/`doF`/`doS`/`doI` for the mpg123 protocol parsers,
  * `Tree.doOrphans` and `Tree.merge` (including the value-order
    behavior of the latter),
  * `FastIO.basenameP`/`dirnameP`/`trim`/`packedFileNameEndClean`,
  * `Core.showTimeDiff_` across the four output branches.

`Lexer.doP/doF/doS/doI` and `Core.showTimeDiff_` are added to their
module export lists for testability.

CI runs `cabal build all && cabal test all` and `stack test`; the build
step is kept because `cabal test` does not build the executable.
The previous layout had the library and the executable sharing
`hs-source-dirs: ./`, which let GHC's home-module rule treat every
library module as a home source of the executable.  It then tried to
recompile them against the executable's (much smaller) dependency list
and failed on clock/array/hscurses.

Putting Main.hs under `app/` gives the executable a non-overlapping
source directory and lets the library do its job: compiled once, linked
into both the executable and the test-suite.

Lexer-relevant types in `Syntax` now derive `Eq` and `Show`, which lets
`LexerSpec` compare whole `Msg` values directly instead of pattern-
matching out individual fields.  The tests get noticeably shorter.
@galenhuntington
galenhuntington merged commit 536d6ec into master May 17, 2026
5 checks passed
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.

2 participants