feat: add fullscreen TUI and project updates
- New TUI screens: Main Menu, Compile, Run, REPL, AI Generator, AI Settings, Help - AI configuration persisted in ~/.config/cljnim/config.json - Added illwill dependency for terminal UI - Updated experiments, examples, docs, and core modules
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
# Tests for AI assistance module (no real API calls)
|
||||
|
||||
import unittest, strutils
|
||||
import unittest, strutils, times
|
||||
import os
|
||||
import ai_assist
|
||||
|
||||
suite "AI Config Detection":
|
||||
test "detectConfig returns empty when no env vars set":
|
||||
# Note: this test assumes no API keys are set in test environment
|
||||
# If keys ARE set, it will detect them
|
||||
let cfg = detectConfig()
|
||||
# At minimum, the function should not crash
|
||||
check cfg.timeoutMs >= 0
|
||||
|
||||
test "hasAiConfig returns false when no keys set (if env empty)":
|
||||
@@ -31,6 +28,30 @@ suite "Prompt Building":
|
||||
check "reverse a list" in prompt
|
||||
check "Clojure" in prompt
|
||||
|
||||
test "buildOptimizationPrompt includes code":
|
||||
let prompt = buildOptimizationPrompt("(reduce + [1 2 3])")
|
||||
check "(reduce + [1 2 3])" in prompt
|
||||
check "SIMD" in prompt or "optim" in prompt.toLowerAscii()
|
||||
|
||||
test "buildDebugPrompt includes code and result":
|
||||
let prompt = buildDebugPrompt("(+ 1 2)", "3")
|
||||
check "(+ 1 2)" in prompt
|
||||
check "3" in prompt
|
||||
check "Clojure" in prompt
|
||||
|
||||
suite "Error Cache":
|
||||
test "getCachedError returns empty for unknown errors":
|
||||
check getCachedError("unknown error", "test.clj") == ""
|
||||
|
||||
test "cacheError and getCachedError work":
|
||||
cacheError("type mismatch", "test.clj", "Check your types")
|
||||
check getCachedError("type mismatch", "test.clj") == "Check your types"
|
||||
|
||||
test "cacheError with same key returns correct suggestion":
|
||||
cacheError("unterminated string", "src.clj", "Add closing quote")
|
||||
let cached = getCachedError("unterminated string", "src.clj")
|
||||
check cached == "Add closing quote"
|
||||
|
||||
suite "Response Formatting":
|
||||
test "formatSuggestion shows error when not ok":
|
||||
let resp = AiResponse(ok: false, suggestion: "No key configured")
|
||||
|
||||
Reference in New Issue
Block a user