lambdaclass / lambdaclass/lambda_compiler_kit
Migrate tests from hand-rolled IO to LSpec framework
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Summary
The current test suite uses hand-rolled IO Unit functions with manual IO.println "✓" / throw "✗" for pass/fail reporting. This reimplements scaffolding that existing Lean 4 testing frameworks already provide.
Current state
- 67 tests across
ParserTest.lean,NfaTest.lean,MatcherTest.lean - Each test is a
def testFoo : IO Unitthat manually prints results test/Main.leancalls each test function sequentially- No structured output, no test counts, no failure summaries
Recommended approach: LSpec
LSpec is the standard Lean 4 testing framework. Tests become declarative assertions:
import LSpec
import Lck.Regex.Parser
def parserSuite := [
test "single char" (parse "a" = Except.ok (Regex.char 'a')),
test "reversed range fails" (parse "[z-a]" matches Except.error _),
test "empty pattern" (parse "" = Except.error RegexError.emptyPattern)
]
def main := lspecIO $ .ofList [
("parser", parserSuite),
("matcher", matcherSuite)
]
Benefits:
- Eliminates ~200 lines of boilerplate (manual IO.println/throw per test)
- Structured pass/fail output with counts and summaries
- Standard
lake testintegration viatestDriver - Consistent with Lean ecosystem conventions
Other approaches worth considering
#guard: Built-in compile-time assertions (#guard parse "a" = Except.ok (Regex.char 'a')). Zero boilerplate, failures are compilation errors. Good for simple invariants alongside LSpec.- SlimCheck/Plausible: Property-based testing for discovering edge cases automatically. Could complement LSpec for properties like "any regex that parses successfully can be compiled to an NFA".
Migration plan
- Add LSpec dependency to
lakefile.toml - Convert each
testFoo : IO Unitto an LSpectest "name" (assertion) - Group tests into suites by module
- Wire up
main := lspecIO $ .ofList [...] - Configure
testDriverin lakefile - Remove manual IO scaffolding
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading test/ParserTest.lean, test/NfaTest.lean, test/MatcherTest.lean, and test/Main.lean to understand the 67 existing tests and their current entry points. Then review lakefile.toml and the LSpec integration requirements. Done means the tests use grouped LSpec suites, lake test provides structured results, and the manual IO scaffolding is removed.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100