Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion crates/loon-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,14 @@ fn check_file(path: &PathBuf, json: bool) {
fn print_card(json: bool) {
const CARD: &str = include_str!("card.md");
let version = env!("GIT_VERSION");
let card = CARD.replace("{{VERSION}}", version);
let mut card = CARD.replace("{{VERSION}}", version);

// Builtins section is generated from the shared registry so the card
// can never drift from what the checker/interp/VM actually implement.
card.push_str("\n## Builtins\n\n");
for b in loon_lang::builtins::BUILTINS {
card.push_str(&format!("`{}` : {} — {}\n", b.name, b.sig, b.doc));
}
if json {
// Split on `## ` headings into structured sections.
let mut sections = Vec::new();
Expand Down
14 changes: 14 additions & 0 deletions crates/loon-cli/tests/prior-alignment/c-hex-literals.oo
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; prior: C/Rust/Python/JS — `0xFF`, `0o17`, `0b1010` radix literals are
; universal; agents write them for masks and flags without thinking.
; expectation: hex/octal/binary integer literals parse (with `_`
; separators), including negative forms.
; principle: numeric literal syntax matches mainstream priors.
; expect-stdout: 255
; expect-stdout: 15
; expect-stdout: 10
; expect-stdout: -16
[fn main []
[println 0xFF]
[println 0o17]
[println 0b1010]
[println -0x10]]
10 changes: 10 additions & 0 deletions crates/loon-cli/tests/prior-alignment/clojure-reduce-alias.oo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; prior: Clojure/Python — agents reach for `reduce`, not `fold`, when
; accumulating over a collection.
; expectation: reduce is a first-class alias of fold with identical
; init + fn + coll semantics on every backend.
; principle: meet the agent's prior instead of teaching a synonym.
; expect-stdout: 10
; expect-stdout: 10
[fn main []
[println [reduce 0 [fn [acc x] [+ acc x]] #[1 2 3 4]]]
[println [fold 0 [fn [acc x] [+ acc x]] #[1 2 3 4]]]]
10 changes: 10 additions & 0 deletions crates/loon-cli/tests/prior-alignment/js-index-of-vector.oo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; prior: JS `[10,20,30].indexOf(20)` / Python `list.index` — finding an
; element's position in a list is assumed everywhere.
; expectation: index-of works on vectors (first equal element, -1 when
; absent), not just strings.
; principle: one lookup builtin across strings and vectors.
; expect-stdout: 1
; expect-stdout: -1
[fn main []
[println [index-of #[10 20 30] 20]]
[println [index-of #[1 2] 9]]]
14 changes: 14 additions & 0 deletions crates/loon-cli/tests/prior-alignment/js-string-helpers.oo
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; prior: JS `"ab".repeat(3)`, `padStart`, Python `str.capitalize()` — string
; utility helpers agents type without checking the docs.
; expectation: capitalize / pad-left / pad-right / repeat exist and behave
; like their JS/Python counterparts (pad takes an explicit pad string).
; principle: meet string-helper priors from mainstream languages.
; expect-stdout: Loon
; expect-stdout: 005
; expect-stdout: ab--
; expect-stdout: ababab
[fn main []
[println [capitalize "loon"]]
[println [pad-left "5" 3 "0"]]
[println [pad-right "ab" 4 "-"]]
[println [repeat "ab" 3]]]
16 changes: 16 additions & 0 deletions crates/loon-cli/tests/prior-alignment/python-math-builtins.oo
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; prior: Python/JS — `sqrt(4)`, `pow(2, 10)`, `floor(-1.5)` are table stakes;
; agents assume core math exists and works on integer arguments.
; expectation: sqrt/pow accept Int or Float (no "cannot unify Float with
; Int"); floor/ceil/round return integers.
; principle: numeric builtins are polymorphic over Int/Float.
; expect-stdout: 2
; expect-stdout: 1024
; expect-stdout: -2
; expect-stdout: 2
; expect-stdout: 3
[fn main []
[println [sqrt 4]]
[println [pow 2 10]]
[println [floor -1.5]]
[println [ceil 1.2]]
[println [round 2.5]]]
14 changes: 14 additions & 0 deletions crates/loon-cli/tests/prior-alignment/python-parse-int.oo
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; prior: Python `int("42")` / JS `parseInt` — string→number conversion is
; assumed; agents also expect a safe form that signals failure.
; expectation: parse-int / parse-float return Option — Some on success,
; None on garbage — so failure is a value, not a crash.
; principle: fallible conversions return Option (agent-first, no exceptions).
; expect-stdout: 43
; expect-stdout: no-parse
[fn main []
[match [parse-int "42"]
[Some n] [println [+ n 1]]
None [println "no-parse"]]
[match [parse-int "not a number"]
[Some n] [println n]
None [println "no-parse"]]]
Loading
Loading