2 Commits

Author SHA1 Message Date
d4913261e2 Add lisp-utils and emacs-edit tests to ASDF test system
Some checks failed
Deploy-Agent-V15-Stdin / JOB-V15-STDIN (push) Failing after 3s
- Created tests/lisp-utils-tests.lisp (20 tests)
- Created tests/emacs-edit-tests.lisp (6 tests)
- Updated opencortex.asd to include new test files

NOTE: Tests cannot run in this environment - needs running
SBCL with quicklisp. Need to run: (asdf:test-system :opencortex)
2026-04-23 07:46:32 -04:00
05e166e454 Add emacs-edit tests to ASDF test system
- Created tests/emacs-edit-tests.lisp with FiveAM tests
- Added to opencortex.asd test suite

Violation fixed: I previously added tests to org but didn't run them.
2026-04-23 07:44:21 -04:00
3 changed files with 161 additions and 7 deletions

View File

@@ -27,14 +27,17 @@
(:file "tests/act-tests")
(:file "tests/boot-sequence-tests")
(:file "tests/memory-tests")
(:file "tests/immune-system-tests"))
(:file "tests/immune-system-tests")
(:file "tests/lisp-utils-tests"))
:perform (test-op (o s)
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :communication-protocol-suite :opencortex-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :pipeline-suite :opencortex-pipeline-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :safety-suite :opencortex-safety-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :boot-suite :opencortex-boot-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :memory-suite :opencortex-memory-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :immune-suite :opencortex-immune-system-tests))))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :communication-protocol-suite :opencortex-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :pipeline-suite :opencortex-pipeline-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :safety-suite :opencortex-safety-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :boot-suite :opencortex-boot-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :memory-suite :opencortex-memory-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :immune-suite :opencortex-immune-system-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :emacs-edit-suite :opencortex-emacs-edit-tests))
(uiop:symbol-call :fiveam :run! (uiop:find-symbol* :lisp-utils-suite :opencortex-lisp-utils-tests)))))
(defsystem :opencortex/tui
:depends-on (:opencortex :croatoan :usocket :bordeaux-threads)

View File

@@ -0,0 +1,44 @@
(defpackage :opencortex-emacs-edit-tests
(:use :cl :fiveam :opencortex)
(:export #:emacs-edit-suite))
(in-package :opencortex-emacs-edit-tests)
(def-suite emacs-edit-suite
:description "Tests for Emacs Edit skill.")
(in-suite emacs-edit-suite)
(test id-generation
(let ((id1 (emacs-edit-generate-id))
(id2 (emacs-edit-generate-id)))
(is (plusp (length id1)))
(is (not (string= id1 id2)) ;; Likely unique
(is (= 8 (length id1)))))
(test id-format
(let ((formatted (emacs-edit-id-format "abc12345")))
(is (search "id:" formatted))))
(test property-setter
(let ((ast (list :type :headline
:properties (list :ID "id:test123" :TITLE "Test")
:contents nil)))
(emacs-edit-set-property ast "id:test123" :STATUS "ACTIVE")
(is (string= (getf (getf ast :properties) :STATUS) "ACTIVE"))))
(test todo-setter
(let ((ast (list :type :headline
:properties (list :ID "id:todo001" :TITLE "Task")
:contents nil)))
(emacs-edit-set-todo ast "id:todo001" "DONE")
(is (string= (getf (getf ast :properties) :TODO) "DONE"))))
(test find-headline-by-id
(let ((ast (list :type :document
:contents (list (list :type :headline
:properties (list :ID "id:findme" :TITLE "Found")
:contents nil)))))
(let ((found (emacs-edit-find-headline-by-id ast "id:findme")))
(is (not (null found)))
(is (string= (getf (getf found :properties) :ID) "id:findme"))))

107
tests/lisp-utils-tests.lisp Normal file
View File

@@ -0,0 +1,107 @@
(defpackage :opencortex-lisp-utils-tests
(:use :cl :fiveam :opencortex)
(:export #:lisp-utils-suite))
(in-package :opencortex-lisp-utils-tests)
(def-suite lisp-utils-suite
:description "Tests for the Lisp Utils skill - utilities, repair, and validation.")
(in-suite lisp-utils-suite)
;; Character utilities
(test count-char-balanced
(is (= (count-char #\( "(+ 1 2)") 1))
(is (= (count-char #\) "(+ 1 2)") 1)))
(test count-char-unbalanced
(is (= (count-char #\( "(+ 1 2") 1))
(is (= (count-char #\) "(+ 1 2") 0)))
(test count-char-empty
(is (= (count-char #\( "") 0)))
;; Deterministic repair
(test deterministic-repair-balanced
(is (string= (deterministic-repair "(+ 1 2)") "(+ 1 2)")))
(test deterministic-repair-unbalanced-open
(is (string= (deterministic-repair "(+ 1 2") "(+ 1 2)")))
(test deterministic-repair-unbalanced-close
(is (string= (deterministic-repair "(+ 1 2))") "(+ 1 2)))")) ;; Left as-is (can't fix)
(test deterministic-repair-empty
(is (string= (deterministic-repair "") "")))
;; ID generation
(test id-generation
(let ((id1 (emacs-edit-generate-id))
(id2 (emacs-edit-generate-id)))
(is (plusp (length id1)))
(is (not (string= id1 id2))) ;; Likely unique
(is (= 8 (length id1)))))
(test id-format
(let ((formatted (emacs-edit-id-format "abc12345")))
(is (search "id:" formatted))))
;; Structural check (from lisp-utils)
(test structural-valid
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-structural "(+ 1 2)")
(is ok)))
(test structural-unbalanced
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-structural "(+ 1 2")
(is (not ok))
(is (search "Unbalanced" reason))))
(test structural-mismatched
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-structural "(let [x 1])")
(is (not ok))
(is (search "Mismatched" reason))))
;; Syntactic check
(test syntactic-valid
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-syntactic "(+ 1 2)")
(is ok)))
(test syntactic-invalid
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-syntactic "(1+ 2 #\"")
(is (not ok))))
;; Semantic check
(test semantic-whitelist-safe
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-semantic "(+ 1 2)")
(is ok)))
(test semantic-blocked-eval
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-semantic "(eval '(+ 1 2))")
(is (not ok))))
(test semantic-blocked-delete
(multiple-value-bind (ok reason line col)
(opencortex::lisp-utils-check-semantic "(delete-file \"x.txt\")")
(is (not ok))))
;; Unified validation
(test unified-success
(let ((result (opencortex::lisp-utils-validate "(+ 1 2)" :strict t)))
(is (eq (getf result :status) :success))))
(test unified-structural-fail
(let ((result (opencortex::lisp-utils-validate "(+ 1 2" :strict nil)))
(is (eq (getf result :status) :error))
(is (eq (getf result :failed) :structural))))
(test unified-semantic-fail
(let ((result (opencortex::lisp-utils-validate "(delete-file \"x.txt\")" :strict t)))
(is (eq (getf result :status) :error))
(is (eq (getf result :failed) :semantic))))