456636700c
- Emitter: def registry (definedGlobals) for symbol emit distinction - Emitter: cond emits return statements - Emitter: reduce wraps named functions in closure adapter - Emitter: clojure.string/* function mappings (split, lower-case, etc.) - Emitter: statement detection for echo cljRepr wrapping - Runtime: cljGet supports default value (3 args) - Runtime: cljStrSplit supports regex patterns via re module - Examples: fizzbuzz.clj and wordfreq.clj both compile and run correctly - Tests: emit symbol / emit mangled symbol now pass (80/80) - Compliance: 233/233 (100%) maintained
3.7 KiB
3.7 KiB
Clojure/Nim — Test Suite Compliance Plan
Current Status: 233/233 (100%)
| Component | Pass | Total | % |
|---|---|---|---|
| clojure.string | 8 | 8 | 100% |
| clojure.core | 225 | 225 | 100% |
| Total | 233 | 233 | 100% |
Unit Tests: 80/80 (100%) ✅
| Status | Test | Issue |
|---|---|---|
| ✅ | 40 reader + 40 emitter | All passing |
Note: 8 macro tests (test_macros.nim) have pre-existing failures unrelated to this work.
Real-World Examples ✅
| Example | Description | Status |
|---|---|---|
fizzbuzz.clj |
Classic FizzBuzz with cond, mod, range, doseq |
✅ Works |
wordfreq.clj |
Word frequency counter with reduce, assoc, get, keys, sort, clojure.string/split, clojure.string/lower-case |
✅ Works |
Both examples compile to native binaries and produce correct output with minimal code changes (only removed #"" regex literal syntax).
0 Remaining Failures
All 233 clojure.test-suite compliance tests pass (rc=0). All 80 unit tests pass.
Previous failures resolved:
1. not_eq — Cross-namespace dependency ✅
- Root cause:
extractRequiresdidn't findnsinside(do ...)wrapper from test runner.resolveNsToPathonly tried.cljextension, not.cljc. Search path didn't include test suite directory. - Fix: Made
extractRequiresrecurse intodoforms, added.cljcfallback inresolveNsToPath, added test suite auto-detection in search paths, filtered to only inlinedef/defnfrom required files (not macros).
2. add_watch — STM ref functions missing ✅
- Root cause:
(ref 10)emitted asref1(cljInt(10))instead ofcljRef(cljInt(10)).dosync,ref-set,alteralso missing. - Fix: Added runtime name mappings (
ref→cljRef,ref-set→cljRefSet,dosync→cljDosync,alter→cljAlter). Implemented minimal STM ref runtime functions.
3. remove_watch — Same STM ref issue ✅
- Root cause: Same as
add_watch— usesref,dosync,alter. - Fix: Same as
add_watch.
4. Symbol Emit Fix ✅
- Root cause:
emitExprfor unknown symbols fell through tocljSymbol(...)instead of emitting mangled name. No def registry existed to distinguish variable references from symbol literals. - Fix: Added
definedGlobalsregistry in emitter.def,defn,defn-,definterface,defprotocol,defrecord,deftypenow register names. Symbol emit checks registry before falling back tocljSymbol(...). Unit tests updated to register globals before testing.
Session Log
2026-05-11 (current session) — 233/233 (100%), 80/80 unit tests
- Emitter: added
definedGlobalsregistry withregisterGlobal/clearGlobalsprocs - Emitter:
def/defn/defn-/definterface/defprotocol/defrecord/deftyperegister globals - Emitter: symbol emit checks
definedGlobalsbefore falling back tocljSymbol(...) - Emitter:
condnow emitsreturnstatements in branches - Emitter:
reducewraps named function symbols incljFn(...)closure adapter - Emitter:
clojure.string/*functions mapped to runtime (split,lower-case,upper-case,trim,join,replace,includes?,starts-with?,ends-with?,blank?,reverse) - Emitter:
keys/valsremoved from variadic list (they take single map arg) - Emitter: statement detection expanded for
echo cljRepr(...)wrapping (while,if,block:,for,try) - Runtime:
cljGetwith 3 args now usescljGetDefaultfor default value - Runtime:
cljStrSplitnow supports regex patterns via Nim'sremodule - Tests:
emit symbolandemit mangled symbolnow register globals before testing - Examples: added
fizzbuzz.cljandwordfreq.clj— both compile and run correctly - Result: 78/80 → 80/80 unit tests