mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
* Add tests of Elisp expression evaluation.
This commit is contained in:
parent
e79236a948
commit
a64e666980
2 changed files with 77 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
2002-02-08 Neil Jerram <neil@ossau.uklinux.net>
|
||||
|
||||
* tests/elisp.test: Add tests of Elisp expression evaluation.
|
||||
|
||||
2002-01-25 Neil Jerram <neil@ossau.uklinux.net>
|
||||
|
||||
* tests/load.test: New test; for search-path with Elisp
|
||||
|
|
|
@ -279,4 +279,77 @@
|
|||
|
||||
))
|
||||
|
||||
(if (defined? '%nil)
|
||||
(use-modules (lang elisp interface)))
|
||||
|
||||
(if (defined? '%nil)
|
||||
|
||||
(with-test-prefix "elisp"
|
||||
|
||||
(define (elisp-pass-if expr expected)
|
||||
(pass-if (with-output-to-string
|
||||
(lambda ()
|
||||
(write expr)))
|
||||
(let ((calc (with-output-to-string
|
||||
(lambda ()
|
||||
(write (eval-elisp expr))))))
|
||||
(string=? calc expected))))
|
||||
|
||||
(elisp-pass-if '(and #f) "#f")
|
||||
(elisp-pass-if '(and #t) "#t")
|
||||
(elisp-pass-if '(and nil) "#nil")
|
||||
(elisp-pass-if '(and t) "#t")
|
||||
(elisp-pass-if '(and) "#t")
|
||||
(elisp-pass-if '(cond (nil t) (t 3)) "3")
|
||||
(elisp-pass-if '(cond (nil t) (t)) "#t")
|
||||
(elisp-pass-if '(cond (nil)) "#nil")
|
||||
(elisp-pass-if '(cond) "#nil")
|
||||
(elisp-pass-if '(if #f 'a 'b) "b")
|
||||
(elisp-pass-if '(if #t 'a 'b) "a")
|
||||
(elisp-pass-if '(if '() 'a 'b) "b")
|
||||
(elisp-pass-if '(if nil 'a 'b) "b")
|
||||
(elisp-pass-if '(if nil 1 2 3 4) "4")
|
||||
(elisp-pass-if '(if nil 1 2) "2")
|
||||
(elisp-pass-if '(if nil 1) "#nil")
|
||||
(elisp-pass-if '(if t 1 2) "1")
|
||||
(elisp-pass-if '(if t 1) "1")
|
||||
(elisp-pass-if '(let (a) a) "#nil")
|
||||
(elisp-pass-if '(let* (a) a) "#nil")
|
||||
(elisp-pass-if '(let* ((a 1) (b (* a 2))) b) "2")
|
||||
(elisp-pass-if '(memq '() '(())) "(())")
|
||||
(elisp-pass-if '(memq '() '(nil)) "(#nil)")
|
||||
(elisp-pass-if '(memq '() '(t)) "#nil")
|
||||
(elisp-pass-if '(memq nil '(())) "(())")
|
||||
(elisp-pass-if '(memq nil '(nil)) "(#nil)")
|
||||
(elisp-pass-if '(memq nil (list nil)) "(#nil)")
|
||||
(elisp-pass-if '(null '#f) "#t")
|
||||
(elisp-pass-if '(null '()) "#t")
|
||||
(elisp-pass-if '(null 'nil) "#t")
|
||||
(elisp-pass-if '(null nil) "#t")
|
||||
(elisp-pass-if '(or 1 2 3) "1")
|
||||
(elisp-pass-if '(or nil t nil) "#t")
|
||||
(elisp-pass-if '(or nil) "#nil")
|
||||
(elisp-pass-if '(or t nil t) "#t")
|
||||
(elisp-pass-if '(or t) "#t")
|
||||
(elisp-pass-if '(or) "#nil")
|
||||
(elisp-pass-if '(prog1 1 2 3) "1")
|
||||
(elisp-pass-if '(prog2 1 2 3) "2")
|
||||
(elisp-pass-if '(progn 1 2 3) "3")
|
||||
(elisp-pass-if '(while nil 1) "#nil")
|
||||
|
||||
(elisp-pass-if '(defun testf (x y &optional o &rest r) (list x y o r)) "testf")
|
||||
(elisp-pass-if '(testf 1 2) "(1 2 #nil #nil)")
|
||||
(elisp-pass-if '(testf 1 2 3 4 5 56) "(1 2 3 (4 5 56))")
|
||||
;; NB `lambda' in Emacs is self-quoting, but that's only after
|
||||
;; loading the macro definition of lambda in subr.el.
|
||||
(elisp-pass-if '(function (lambda (x y &optional o &rest r) (list x y o r))) "(lambda (x y &optional o &rest r) (list x y o r))")
|
||||
(elisp-pass-if '(funcall (lambda (x y &optional o &rest r) (list x y o r)) 1 2 3 4) "(1 2 3 (4))")
|
||||
(elisp-pass-if '(apply (lambda (x y &optional o &rest r) (list x y o r)) 1 2 3 nil) "(1 2 3 #nil)")
|
||||
|
||||
(elisp-pass-if '(setq x 3) "3")
|
||||
(elisp-pass-if '(defvar x 4) "x")
|
||||
(elisp-pass-if 'x "3")
|
||||
|
||||
))
|
||||
|
||||
;;; elisp.test ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue