lambdaclass / lambdaclass/lambda_compiler_kit
Migrate tests from hand-rolled IO to LSpec framework
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Lean
- Estrellas
- 2
- Forks
- 1
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza leyendo test/ParserTest.lean, test/NfaTest.lean, test/MatcherTest.lean y test/Main.lean para comprender las 67 pruebas existentes y sus puntos de entrada actuales. Después, revisa lakefile.toml y los requisitos de integración de LSpec. La tarea estará terminada cuando las pruebas usen suites de LSpec agrupadas, lake test proporcione resultados estructurados y se elimine el scaffolding manual de IO.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Área
- build-system, testing
- Tipo de issue
- Refactorización
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 42/100