fix: general equality (=) for all types, add type predicates & collection fns, test suite docs

- Fix: = now uses cljEqual/cljMultiEqual instead of numeric-only cljNumEq,
  so (= :a :a), (= "a" "a"), (= [1 2] [1 2]), (= nil nil) etc return true
- Fix: ns forms inside unwrapped (do ...) are skipped instead of emitting
  broken Nim comments inside cljRepr()
- Fix: defmacro forms go to defs section, not wrapped in discard cljRepr()
- Add 18 type predicates: keyword?, symbol?, string?, number?, integer?,
  float?, vector?, map?, set?, list?, seq?, coll?, sequential?, fn?,
  boolean?, true?, false?, some?
- Add collection fns: second, ffirst, nfirst, peek, pop
- Add keyword/symbol ops: keyword, symbol, name, namespace, key, val
- Update eval interpreter = to handle structural collection equality
- Add test_single.py + test_vals.clj for Clojure test suite runner
- Add docs/en/07 and docs/bg/07 for cross-dialect test suite compatibility
- Update README with test suite documentation link
This commit is contained in:
2026-05-09 12:17:10 +03:00
parent ba0b300917
commit a9ad83c509
12 changed files with 777 additions and 83 deletions
+110
View File
@@ -0,0 +1,110 @@
[← Обратно към индекса](index.md)
---
# Съвместимост с Clojure Test Suite
Clojure/Nim участва в между-диалектния **[jank-lang/clojure-test-suite](https://github.com/jank-lang/clojure-test-suite)** — стандартният Clojure тестови пакет за съответствие, който валидира поведението на всички Clojure диалекти.
## Поддържани диалекти
Clojure Test Suite се поддържа официално за следните диалекти:
| Диалект | Статус | Runtime |
|---------|--------|---------|
| Clojure (JVM) | ✅ Официален | JVM |
| ClojureScript | ✅ Официален | JavaScript / Node.js |
| Babashka | ✅ Официален | GraalVM native-image |
| Clojure CLR | ✅ Официален | .NET CLR |
| Basilisp | ✅ Официален | Python |
| **Clojure/Nim** | 🚀 Кандидат | **Nim → C → Native** |
## Бърз старт
### 1. Клониране на тестовия пакет
```bash
git clone https://github.com/jank-lang/clojure-test-suite.git /tmp/clojure-test-suite
```
### 2. Пускане на индивидуални тестове
Използвайте `test_single.py` за пускане на конкретен тестов файл:
```bash
python3 test_single.py /tmp/clojure-test-suite/test/clojure/core_test/nil_qmark.cljc
```
### 3. Пускане на пакет
```bash
python3 test_single.py
# Пуска: zipmap, zero_qmark, with_out_str
```
Редактирайте файла `test_single.py`, за да добавите още тестови файлове към списъка.
## Формат на тестовете
Всеки тестов файл е `.cljc` (cross-platform Clojure/ClojureScript) файл със стандартна структура:
```clojure
(ns clojure.core-test.nil-qmark
(:require [clojure.test :as t :refer [are deftest is testing]]
[clojure.core-test.portability :refer [when-var-exists]]))
(when-var-exists nil?
(deftest test-nil?
(testing "common"
(are [in ex] (= (nil? in) ex)
nil true
0 false
false false
"" false))))
```
## Обработка на Reader Conditionals
`test_single.py` на Clojure/Nim предварително обработва `.cljc` файловете, като премахва `#?` и `#?@` reader conditionals и извлича `:default` клона:
```clojure
;; Преди
#?(:cljs :refer-macros :default :refer)
;; След
:refer
;; Преди
#?@(:cljs [] :default [1 2 3])
;; След
[1 2 3]
```
Това следва стандартната между-диалектна конвенция — всеки диалект разрешава `:default` според своята платформа.
## Текущ обхват на тестовете
Тестовият пакет покрива **212+ функции от `clojure.core`** и **8 функции от `clojure.string`**. Clojure/Nim работи към пълно съответствие.
Вижте [Roadmap](06-roadmap.md) за статуса на имплементацията.
---
## Настройка на тестове за отделните диалекти
За справка, ето линкове към официалните ръководства за настройка на тестовете за други платформи:
| Диалект | Ръководство за настройка |
|---------|--------------------------|
| Clojure (JVM) | [clojure.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/clojure.md) |
| ClojureScript | [clojurescript.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/clojurescript.md) |
| Babashka | [babashka.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/babashka.md) |
| Clojure CLR | [clojureclr.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/clojureclr.md) |
| Basilisp | [basilisp.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/basilisp.md) |
| **Clojure/Nim** | **Този документ** |
---
*Последно обновено: 2026-05-09*
+1
View File
@@ -15,6 +15,7 @@
- **Build:** `make build && make check`
- **Тестове:** 276+ теста в 8 тестови пакета
- **AI Интеграция:** DeepSeek API, OpenAI-compatible, Xiaomi MiMo
- **Test Suite:** [Съвместимост с Clojure Test Suite](07-clojure-test-suite.md) — между-диалектно тестване за съответствие
## Защо Clojure/Nim?
+110
View File
@@ -0,0 +1,110 @@
[← Back to Index](index.md)
---
# Clojure Test Suite Compatibility
Clojure/Nim participates in the cross-dialect **[jank-lang/clojure-test-suite](https://github.com/jank-lang/clojure-test-suite)** — the standard Clojure compliance test suite that validates behavior across all Clojure dialects.
## Supported Dialects
The Clojure Test Suite is officially maintained for these dialects:
| Dialect | Status | Runtime |
|---------|--------|---------|
| Clojure (JVM) | ✅ Official | JVM |
| ClojureScript | ✅ Official | JavaScript / Node.js |
| Babashka | ✅ Official | GraalVM native-image |
| Clojure CLR | ✅ Official | .NET CLR |
| Basilisp | ✅ Official | Python |
| **Clojure/Nim** | 🚀 Candidate | **Nim → C → Native** |
## Quick Start
### 1. Clone the Test Suite
```bash
git clone https://github.com/jank-lang/clojure-test-suite.git /tmp/clojure-test-suite
```
### 2. Run Individual Tests
Use `test_single.py` to run a specific test file:
```bash
python3 test_single.py /tmp/clojure-test-suite/test/clojure/core_test/nil_qmark.cljc
```
### 3. Run a Batch
```bash
python3 test_single.py
# Runs: zipmap, zero_qmark, with_out_str
```
Edit the `test_single.py` file to add more test files to the batch list.
## Test Format
Each test file is a `.cljc` (cross-platform Clojure/ClojureScript) file with a standard structure:
```clojure
(ns clojure.core-test.nil-qmark
(:require [clojure.test :as t :refer [are deftest is testing]]
[clojure.core-test.portability :refer [when-var-exists]]))
(when-var-exists nil?
(deftest test-nil?
(testing "common"
(are [in ex] (= (nil? in) ex)
nil true
0 false
false false
"" false))))
```
## Reader Conditional Handling
Clojure/Nim's `test_single.py` pre-processes `.cljc` files, stripping `#?` and `#?@` reader conditionals and extracting the `:default` branch:
```clojure
;; Before
#?(:cljs :refer-macros :default :refer)
;; After
:refer
;; Before
#?@(:cljs [] :default [1 2 3])
;; After
[1 2 3]
```
This follows the standard cross-dialect convention — each dialect resolves `:default` per its platform.
## Current Test Scope
The test suite covers **212+ `clojure.core` functions** and **8 `clojure.string` functions**. Clojure/Nim is working toward full compliance.
See the [Roadmap](06-roadmap.md) for implementation status.
---
## Dialect-Specific Test Setup
For reference, here are links to the official dialect setup guides for running the test suite on other platforms:
| Dialect | Setup Guide |
|---------|-------------|
| Clojure (JVM) | [clojure.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/clojure.md) |
| ClojureScript | [clojurescript.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/clojurescript.md) |
| Babashka | [babashka.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/babashka.md) |
| Clojure CLR | [clojureclr.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/clojureclr.md) |
| Basilisp | [basilisp.md](https://github.com/jank-lang/clojure-test-suite/blob/main/doc/basilisp.md) |
| **Clojure/Nim** | **This document** |
---
*Last updated: 2026-05-09*
+1
View File
@@ -15,6 +15,7 @@
- **Build:** `make build && make check`
- **Tests:** 276+ tests across 8 test suites
- **AI Integration:** DeepSeek API, OpenAI-compatible, Xiaomi MiMo
- **Test Suite:** [Clojure Test Suite Compatibility](07-clojure-test-suite.md) — cross-dialect compliance testing
## Why Clojure/Nim?