lambdaclass / lambdaclass/lambda_compiler_kit

Migrate tests from hand-rolled IO to LSpec framework

Abierto
#7 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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 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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. 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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.