- NEW: org-skill-utils-lisp (consolidated from org-skill-lisp-utils) * 3-phase validation: structural, syntactic, semantic * Sandboxed eval, AST extraction/injection/wrapping * Format, list-definitions utilities - NEW: org-skill-utils-org (consolidated from org-skill-emacs-edit) * Read/update/delete org headlines * Property management, TODO state handling * ID-link and internal link support - DELETE: org-skill-lisp-utils (merged into utils-lisp) - DELETE: org-skill-emacs-edit (merged into utils-org) - RENAME: run-all-tests.lisp -> run-tests.lisp - HARDEN: Skill loader with improved lisp keyword handling - FIX: Package jailing issues with def-cognitive-tool macro conflicts - ADD: Setup wizard (opencortex setup) and doctor (opencortex doctor) - ADD: TUI client with Croatoan for native terminal rendering - REMOVE: Dynamic loading from opencortex.asd (use :force t instead) - CLEANUP: Test file consolidation (removed duplicate test suites) Co-authored-by: Agent <agent@memex>
126 lines
3.5 KiB
Org Mode
126 lines
3.5 KiB
Org Mode
#+TITLE: Tests: Utils Lisp
|
|
#+AUTHOR: Agent
|
|
#+PROPERTY: header-args:lisp :tangle utils-lisp-tests.lisp
|
|
|
|
* Overview
|
|
Verification of the structural, syntactic, and semantic gates of the Lisp Validator.
|
|
|
|
* Implementation
|
|
|
|
** Package Context
|
|
#+begin_src lisp
|
|
(defpackage :opencortex-utils-lisp-tests
|
|
(:use :cl :fiveam :opencortex)
|
|
(:export #:utils-lisp-suite))
|
|
|
|
(in-package :opencortex-utils-lisp-tests)
|
|
|
|
(def-suite utils-lisp-suite
|
|
:description "Tests for the Lisp Validator structural, syntactic, and semantic gates")
|
|
|
|
(in-suite utils-lisp-suite)
|
|
#+end_src
|
|
|
|
** Structural Balanced
|
|
#+begin_src lisp
|
|
(test structural-balanced
|
|
(is (eq t (opencortex:utils-lisp-check-structural "(+ 1 2)"))))
|
|
#+end_src
|
|
|
|
** Structural Unbalanced (Open)
|
|
#+begin_src lisp
|
|
(test structural-unbalanced-open
|
|
(multiple-value-bind (ok reason) (opencortex:utils-lisp-check-structural "(+ 1 2")
|
|
(is (null ok))
|
|
(is (search "Reader Error" reason))))
|
|
#+end_src
|
|
|
|
** Structural Unbalanced (Close)
|
|
#+begin_src lisp
|
|
(test structural-unbalanced-close
|
|
(multiple-value-bind (ok reason) (opencortex:utils-lisp-check-structural "+ 1 2)")
|
|
(is (null ok))
|
|
(is (search "Reader Error" reason))))
|
|
#+end_src
|
|
|
|
** Syntactic Valid
|
|
#+begin_src lisp
|
|
(test syntactic-valid
|
|
(is (eq t (opencortex:utils-lisp-check-syntactic "(+ 1 2)"))))
|
|
#+end_src
|
|
|
|
** Semantic Safe
|
|
#+begin_src lisp
|
|
(test semantic-safe
|
|
(is (eq t (opencortex:utils-lisp-check-semantic "(+ 1 2)"))))
|
|
#+end_src
|
|
|
|
** Semantic Blocked (Eval)
|
|
#+begin_src lisp
|
|
(test semantic-blocked-eval
|
|
(multiple-value-bind (ok reason) (opencortex:utils-lisp-check-semantic "(eval '(+ 1 2))")
|
|
(is (null ok))
|
|
(is (search "Unsafe" reason))))
|
|
#+end_src
|
|
|
|
** Unified Success
|
|
#+begin_src lisp
|
|
(test unified-success
|
|
(let ((result (opencortex:utils-lisp-validate "(+ 1 2)" :strict t)))
|
|
(is (eq (getf result :status) :success))))
|
|
#+end_src
|
|
|
|
** Unified Failure
|
|
#+begin_src lisp
|
|
(test unified-failure
|
|
(let ((result (opencortex:utils-lisp-validate "(+ 1 2" :strict nil)))
|
|
(is (eq (getf result :status) :error))))
|
|
#+end_src
|
|
|
|
** Evaluation (Basic)
|
|
#+begin_src lisp
|
|
(test eval-basic
|
|
(let ((result (opencortex:utils-lisp-eval "(+ 1 2)")))
|
|
(is (eq (getf result :status) :success))
|
|
(is (string= (getf result :result) "3"))))
|
|
#+end_src
|
|
|
|
** Structural Extraction
|
|
#+begin_src lisp
|
|
(test structural-extract
|
|
(let* ((code "(defun hello () (print \"hi\")) (defun bye () (print \"bye\"))")
|
|
(extracted (opencortex:utils-lisp-structural-extract code "hello")))
|
|
(is (not (null extracted)))
|
|
(let ((form (read-from-string extracted)))
|
|
(is (eq (car form) 'DEFUN))
|
|
(is (eq (second form) 'HELLO)))))
|
|
#+end_src
|
|
|
|
** List Definitions
|
|
#+begin_src lisp
|
|
(test list-definitions
|
|
(let ((code "(defun foo () t) (defmacro bar () nil) (defparameter *baz* 10)"))
|
|
(let ((names (opencortex:utils-lisp-list-definitions code)))
|
|
(is (member 'FOO names))
|
|
(is (member 'BAR names))
|
|
(is (member '*BAZ* names)))))
|
|
#+end_src
|
|
|
|
** Structural Injection
|
|
#+begin_src lisp
|
|
(test structural-inject
|
|
(let* ((code "(defun my-fun (x) (print x))")
|
|
(injected (opencortex:utils-lisp-structural-inject code "my-fun" "(finish-output)")))
|
|
(let ((form (read-from-string injected)))
|
|
(is (equal (last form) '((FINISH-OUTPUT)))))))
|
|
#+end_src
|
|
|
|
** Structural Slurp
|
|
#+begin_src lisp
|
|
(test structural-slurp
|
|
(let* ((code "(defun work () (step-1))")
|
|
(slurped (opencortex:utils-lisp-structural-slurp code "work" "(step-2)")))
|
|
(let ((form (read-from-string slurped)))
|
|
(is (equal (last form) '((STEP-2)))))))
|
|
#+end_src
|