;;;;
;;;; test-r5.stk        -- Test various exemaples of R5RS
;;;;
;;;; Copyright © 2010-2018 Erick Gallesio - Polytech'Nice-Sophia <eg@unice.fr>
;;;;
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; This program 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 General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;;;; USA.
;;;;
;;;;           Author: Erick Gallesio [eg@unice.fr]
;;;;    Creation date: 23-Dec-2010 18:47 (eg)
;;;;
(require "test")

(test-section "Some R5RS Report examples")

;;------------------------------------------------------------------
(test-subsection "4.2.6 Quasiquotation")


(test "Quasiquote.1" '(list 3 4) `(list ,(+ 1 2) 4))
(test "Quasiquote.2" '(list a (quote a))
                     (let ((name 'a)) `(list ,name ',name)))
(test "Quasiquote.3" '(a 3 4 5 6 b)
                     `(a ,(+ 1 2) ,@(map abs '(4 -5 6)) b))
(test "Quasiquote.4" '((foo 7) . cons)
                     `(( foo ,(- 10 3)) ,@(cdr '(c)) . ,(car '(cons))))
(test "Quasiquote.5" '#(10 5 2 4 3 8)
                     `#(10 5 ,(sqrt 4) ,@(map sqrt '(16 9)) 8))

(test "Quasiquote.6" '(a `(b ,(+ 1 2) ,(foo 4 d) e) f)
                     `(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f))

(test "Quasiquote.7" '(a `(b ,x ,'y d) e)
                     (let ((name1 'x)
                           (name2 'y))
                       `(a `(b ,,name1 ,',name2 d) e)))

;;---- tests added for STklos
(test "Quasiquote.stklos.1"
      '(quasiquote ((unquote-splicing (append (list 2 3) (list 5 7)))))
      ``(,@(append ,@'((list 2 3) (list 5 7)))))


;;------------------------------------------------------------------
(test-section-end)
