lambdaclass / lambdaclass/lambda_compiler_kit
Migrate tests from hand-rolled IO to LSpec framework
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lean
- Star
- 2
- Fork
- 1
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách đọc test/ParserTest.lean, test/NfaTest.lean, test/MatcherTest.lean và test/Main.lean để hiểu 67 bài kiểm thử hiện có và các điểm vào hiện tại của chúng. Sau đó xem xét lakefile.toml và các yêu cầu tích hợp LSpec. Công việc được hoàn tất khi các bài kiểm thử sử dụng các suite LSpec được nhóm, lake test cung cấp kết quả có cấu trúc và phần scaffolding IO thủ công được loại bỏ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Lĩnh vực
- build-system, testing
- Loại issue
- Tái cấu trúc
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100