cl-hssg/test/hssg/readers/lisp.lisp
2022-09-26 22:58:36 +02:00

49 lines
2 KiB
Common Lisp

;;;; SPDX-License-Identifier AGPL-3.0-or-later
;;;; compound.lisp Compound artifact implementation
;;;; Copyright (C) 2022 Alejandro "HiPhish" Sanchez
;;;;
;;;; This file is part of CL-HSSG.
;;;;
;;;; CL-HSSG is free software: you can redistribute it and/or modify it under
;;;; the terms of the GNU Affero General Public License as published by the
;;;; Free Software Foundation, either version 3 of the License, or (at your
;;;; option) any later version.
;;;;
;;;; CL-HSSG is distributed in the hope that it will be useful, but WITHOUT ANY
;;;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;;;; FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
;;;; more details.
;;;;
;;;; You should have received a copy of the GNU Affero General Public License
;;;; along with CL-HSSG If not, see <https://www.gnu.org/licenses/>.(in-package #:hssg.artifact)
(defpackage #:hssg/test/reader/lisp
(:use #:cl))
(in-package #:hssg/test/reader/lisp)
(fiveam:def-suite hssg/reader/lisp
:description "Tests for the Lisp reader"
:in hssg/test:hssg)
(fiveam:in-suite hssg/reader/lisp)
(fiveam:test lisp-reader-is-registered
"The Lisp reader is registered by default"
(fiveam:is-true (eq (hssg.reader:get-reader "lisp") #'hssg.reader.lisp::read-lisp-metadata)))
(fiveam:test lisp-reader-can-read-files
"The Lisp reader can read the contents of a Lisp file"
(let* ((reader (hssg.reader:get-reader "lisp"))
(data (funcall reader "test/hssg/sample-files/metadata.lisp")))
(hssg:let-metadata data ((foo :foo)
(bar :bar)
(baz :baz))
(fiveam:is-true (string-equal "foo" foo))
(fiveam:is-true (string-equal "bar" bar))
(fiveam:is-true (string-equal "baz" baz)))))
(fiveam:test lisp-reader-does-not-pollute
"The Lisp reader does not leak symbols from the file"
(let* ((reader (hssg.reader:get-reader "lisp")))
(funcall reader "test/hssg/sample-files/metadata.lisp")
(fiveam:is-true (null (find-symbol "THROWAWAY-FUNCTION")))))