test.lisp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. (defpackage #:lilu-apropos-tests
  2. (:use #:cl #:fiveam #:lilu-apropos))
  3. (in-package #:lilu-apropos-tests)
  4. (def-suite lilu-apropos-system
  5. :description "Test lilu-apropos system")
  6. (in-suite lilu-apropos-system)
  7. ;;;
  8. (defvar tt-var
  9. nil
  10. "tt-var")
  11. (defvar tt nil "tt-var")
  12. (defun tt ()
  13. "tt-fun"
  14. 0)
  15. ;;;
  16. (defvar iap (make-instance 'iapropos))
  17. (test package
  18. (setf (iapropos-package-text iap) "lilu-apropos-tests")
  19. (format *debug-io* "~A~%" (iapropos-matching-packages iap))
  20. (is (equal (iapropos-matching-packages iap) (list (find-package :lilu-apropos-tests)))))
  21. (test var
  22. (setf (iapropos-package-text iap) "lilu-apropos-tests")
  23. (setf (iapropos-symbol-text iap) "tt-var")
  24. (is (equal (iapropos-matching-symbols iap) (list (find-symbol "TT-VAR" (find-package :lilu-apropos-tests))))))
  25. (test var-type
  26. (let ((sym (find-symbol "TT-VAR" (find-package :lilu-apropos-tests))))
  27. (is (equal (list-symbol-bounding-types sym) (list :variable)))))
  28. (test var-doc
  29. (let ((sym (find-symbol "TT-VAR" (find-package :lilu-apropos-tests))))
  30. (is (equal (symbol-documentation sym :variable) "tt-var"))))
  31. (test var-loc
  32. (let ((sym (find-symbol "TT-VAR" (find-package :lilu-apropos-tests))))
  33. (is (equal (lilu-apropos::symbol-location sym :variable)
  34. (cons "/home/gas/.roswell/local-projects/my/lilu-apropos/tests/test.lisp" 219)))))
  35. (test sym-tt
  36. (setf (iapropos-package-text iap) "lilu-apropos-tests")
  37. (setf (iapropos-symbol-text iap) "^tt$")
  38. (is (equal (iapropos-matching-symbols iap) (list (find-symbol "TT" (find-package :lilu-apropos-tests))))))
  39. (test sym-tt-type
  40. (let ((sym (find-symbol "TT" (find-package :lilu-apropos-tests))))
  41. (is (equal (list-symbol-bounding-types sym) (list :variable :function)))))
  42. (test sym-tt-doc
  43. (let ((sym (find-symbol "TT" (find-package :lilu-apropos-tests))))
  44. (is (equal (symbol-documentation sym :variable) "tt-var"))
  45. (is (equal (symbol-documentation sym :function) "tt-fun"))
  46. ))
  47. (test sym-tt-loc
  48. (let ((sym (find-symbol "TT" (find-package :lilu-apropos-tests))))
  49. (is (equal (lilu-apropos::symbol-location sym :variable)
  50. (cons "/home/gas/.roswell/local-projects/my/lilu-apropos/tests/test.lisp" 253)))
  51. (is (equal (lilu-apropos::symbol-location sym :function)
  52. (cons "/home/gas/.roswell/local-projects/my/lilu-apropos/tests/test.lisp" 278)))))
  53. ;;;
  54. ;;;
  55. ;;;
  56. (defun run-tests ()
  57. (run! 'lilu-apropos-system))