lambdaclass / lambdaclass/lambda_compiler_kit

Migrate tests from hand-rolled IO to LSpec framework

Aperta
#7 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Lean
Stelle
2
Fork
1
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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 Unit that manually prints results
  • test/Main.lean calls 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 test integration via testDriver
  • 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

  1. Add LSpec dependency to lakefile.toml
  2. Convert each testFoo : IO Unit to an LSpec test "name" (assertion)
  3. Group tests into suites by module
  4. Wire up main := lspecIO $ .ofList [...]
  5. Configure testDriver in lakefile
  6. Remove manual IO scaffolding

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia leggendo test/ParserTest.lean, test/NfaTest.lean, test/MatcherTest.lean e test/Main.lean per comprendere i 67 test esistenti e i loro attuali punti di ingresso. Poi esamina lakefile.toml e i requisiti di integrazione di LSpec. Il lavoro è completato quando i test usano suite LSpec raggruppate, lake test fornisce risultati strutturati e il scaffolding IO manuale viene rimosso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Ambito
build-system, testing
Tipo di issue
Refactoring
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.