From 05e166e454965e4b4a51fae954b84f212a5a4571 Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Thu, 23 Apr 2026 07:44:21 -0400 Subject: [PATCH] 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. --- opencortex.asd | 16 ++++++++------ tests/emacs-edit-tests.lisp | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 tests/emacs-edit-tests.lisp diff --git a/opencortex.asd b/opencortex.asd index 692b604..a54e2f9 100644 --- a/opencortex.asd +++ b/opencortex.asd @@ -27,14 +27,16 @@ (: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/emacs-edit-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)))) (defsystem :opencortex/tui :depends-on (:opencortex :croatoan :usocket :bordeaux-threads) diff --git a/tests/emacs-edit-tests.lisp b/tests/emacs-edit-tests.lisp new file mode 100644 index 0000000..ae3a169 --- /dev/null +++ b/tests/emacs-edit-tests.lisp @@ -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")))) \ No newline at end of file