Skip to content

[216_49] 移动并完善 case-test.scm 测试文件#658

Merged
da-liii merged 4 commits intomainfrom
da/216_49/liii_case
Apr 3, 2026
Merged

[216_49] 移动并完善 case-test.scm 测试文件#658
da-liii merged 4 commits intomainfrom
da/216_49/liii_case

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

@da-liii da-liii commented Apr 3, 2026

变更内容

  • case-test.scmtests/goldfish/liii/ 移动到 tests/liii/ 目录
  • 补充完善测试用例,从 58 行扩展到 358 行

关联任务

216_49

🤖 Generated with Claude Code

@da-liii da-liii merged commit 711a870 into main Apr 3, 2026
4 checks passed
@da-liii da-liii deleted the da/216_49/liii_case branch April 3, 2026 05:53
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 3, 2026

Greptile Summary

This PR moves case-test.scm from tests/goldfish/liii/ to tests/liii/ and significantly expands the test coverage from 58 lines to 358 lines, adding real-world usage examples (algebra simplification, AST type inference, list destructuring, a calculator, and user-data validation).

  • check-set-mode! is set to 'report (line 51) instead of 'report-failed, which is the universal convention everywhere else in the codebase — this will print every passing test result and produce very verbose output on each run.

Confidence Score: 5/5

Safe to merge — no failing tests or logic errors; findings are style-only.

Both findings are P2: 'report mode is a verbosity/convention deviation that does not affect correctness, and the misleading comment does not break any test. All remaining concerns are minor style improvements.

tests/liii/case-test.scm — check-set-mode! mode and the "单元素列表" comment at line 193.

Important Files Changed

Filename Overview
tests/goldfish/liii/case-test.scm Deleted — original 58-line test file moved to tests/liii/case-test.scm.
tests/liii/case-test.scm New 358-line test file; uses 'report mode instead of 'report-failed (project-wide convention), and line 195 has a misleading "单元素列表" comment whose pattern actually matches any value, not just single-element lists.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["case* selector"] --> B{Pattern clause}
    B -->|"literal atom\n(a b c)"| C["eqv? / equal? match\n→ result"]
    B -->|"list pattern\n((p1 p2 ...))"| D{Element-wise match}
    D -->|"#<label:>\nwildcard"| E["Capture value\n→ bind label"]
    D -->|"#<pred?>\npredicate"| F["Apply predicate\n→ match if #t"]
    D -->|"#<...>\nellipsis"| G["Consume remaining\nelements (0+)"]
    E --> H["Result body\nreference via #<label>"]
    F --> H
    G --> H
    C --> H
    B -->|"else"| I["Default result"]
    H --> J["Return value"]
    I --> J
Loading

Reviews (1): Last reviewed commit: "wip" | Re-trigger Greptile

(liii case)
) ;import

(check-set-mode! 'report)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 'report 模式与项目规范不符

tests/liii/ 下所有其他使用 check-set-mode! 的测试文件(例如 cut-test.scm)都设置 'report-failed'report 会在每次运行时打印所有通过的测试用例,产生非常冗长的输出,不符合项目惯例。

Suggested change
(check-set-mode! 'report)
(check-set-mode! 'report-failed)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +193 to +197
;; 单元素列表
(check (case* '(only)
((#<x:>) '#<x>)
(else 'none))
=> '(only))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 注释"单元素列表"与实际模式不符

注释说明该测试匹配"单元素列表",但模式 (#<x:>) 中只有一层括号,在 case* 里这表示对任意值(包括列表、数字、符号等)进行通配捕获,而非专门匹配单元素列表。输入 '(only) 恰好是列表,x 被绑定到整个列表 (only),所以结果正确,但注释会误导读者。

若真正想演示匹配单元素列表,应使用双层括号 ((#<x:>)),与下面 list-info 中的模式一致:

;; 单元素列表 — 注意双括号,外层是子句括号,内层是列表模式
(check (case* '(only)
         (((#<x:>)) '#<x>)
         (else 'none))
  => 'only)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant