lambdaclass / lambdaclass/lambda_compiler_kit

Migrate tests from hand-rolled IO to LSpec framework

オープン
#7 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Lean
スター
2
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず test/ParserTest.lean、test/NfaTest.lean、test/MatcherTest.lean、test/Main.lean を読んで、既存の67個のテストと現在のエントリポイントを理解します。次に lakefile.toml と LSpec の統合要件を確認します。テストがグループ化された LSpec スイートを使用し、lake test が構造化された結果を提供し、手動の IO スキャフォールディングが削除されていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

領域
build-system, testing
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。