# 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: 78/80 (97.5%) | Status | Test | Issue | |---|---|---| | ✅ | 78 tests | All passing | | ❌ | `emit symbol` | Returns `cljSymbol("x")` instead of raw `"x"` | | ❌ | `emit mangled symbol` | Same — symbol emit returns data instead of name | ## 0 Remaining Compliance Failures All 233 clojure.test-suite compliance tests now pass (rc=0). ### Previous failures resolved: ### 1. `not_eq` — Cross-namespace dependency ✅ - **Root cause**: `extractRequires` didn't find `ns` inside `(do ...)` wrapper from test runner. `resolveNsToPath` only tried `.clj` extension, not `.cljc`. Search path didn't include test suite directory. - **Fix**: Made `extractRequires` recurse into `do` forms, added `.cljc` fallback in `resolveNsToPath`, added test suite auto-detection in search paths, filtered to only inline `def`/`defn` from required files (not macros). ### 2. `add_watch` — STM ref functions missing ✅ - **Root cause**: `(ref 10)` emitted as `ref1(cljInt(10))` instead of `cljRef(cljInt(10))`. `dosync`, `ref-set`, `alter` also 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` — uses `ref`, `dosync`, `alter`. - **Fix**: Same as `add_watch`. ## Symbol Emit Fix (Phase C) — Deferred The 2 failing unit tests (`emit symbol`, `emit mangled symbol`) require a proper def registry to distinguish between code references (emit mangled name) and symbol values (emit `cljSymbol(...)`). A simpler fix (emitting all symbols as mangled names) breaks compliance tests that use symbol literals like ratio `22/7` which Nim can't parse as numbers. This requires more careful design and will be addressed later. ## Session Log ### 2026-05-11 (current session) — 233/233 (100%) - Emitter: added `ref`, `ref-set`, `dosync`, `alter` runtime mappings + variadic lists - Runtime: implemented `cljRef`, `cljRefSet`, `cljDosync`, `cljAlter` - Reader: added special float token handling for `nan`/`inf`/`-inf` - Compiler: `extractRequires` now walks `do` forms for `ns` extraction - Compiler: `resolveNsToPath` tries `.cljc` fallback extension - Compiler: auto-detects `/tmp/clojure-test-suite/test` as search path - Compiler: filters required file inlining to only `def`/`defn`/`defn-` (excludes macros) - Emitter: fixed `NaN`/`Inf` float constants (Nim's `$NaN` produces lowercase `nan`) - Result: 230/233 → 233/233 compliance ### 2026-05-11 (late session) — Bulk fixes - Reader: prefer `:default` over `:clj` in conditionals - Emitter: `cond`, `definterface`, `new` special forms - Emitter: `ns` alias registration, `when` discard, `try/catch` scope + type mapping - Emitter: `emitBlock` var hoisting out of IIFEs - Emitter: removed all DEBUG stderr output - Runtime: `random-uuid`, `System/getProperty`, `vreset!`, `restart-agent`, `require`/`eval`/`resolve` stubs - Runtime: `Boolean`/`Object`/`Integer` constructors - Runtime: seq overloads for `cljAssoc`, `cljDissoc`, `cljGet`, `cljExInfo`, `cljTransduce` - Result: 220/233 → 230/233 compliance, 77/80 → 78/80 unit tests