#!/bin/sh

# Copyright (C) 2006 Free Software Foundation, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 3 of
# the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA


# Test that two srfi numbers on the command line work.
#
guile -q --use-srfi=1,10 >/dev/null <<EOF
(if (and (defined? 'partition)
         (defined? 'define-reader-ctor))
    (exit 0)   ;; good
    (exit 1))  ;; bad
EOF
if test $? = 0; then :; else
  echo "guile --use-srfi=1,10 fails to run"
  exit 1
fi


# Test that running "guile --use-srfi=1" leaves the interactive REPL with
# the srfi-1 version of iota.
#
# In guile 1.8.1 and earlier, and 1.6.8 and earlier, these failed because in
# `top-repl' the core bindings got ahead of anything --use-srfi gave.
#

guile -q --use-srfi=1 >/dev/null <<EOF
(catch #t
  (lambda ()
    (iota 2 3 4))
  (lambda args
    (exit 1))) ;; bad
(exit 0)       ;; good
EOF
if test $? = 0; then :; else
  echo "guile --use-srfi=1 doesn't give SRFI-1 iota"
  exit 1
fi


# Similar test on srfi-17 car, which differs in being a #:replacement.  This
# exercises duplicates handling in `top-repl' versus `use-srfis' (in
# boot-9.scm).
#
guile -q --use-srfi=17 >/dev/null <<EOF
(if (procedure-with-setter? car)
    (exit 0)   ;; good
    (exit 1))  ;; bad
EOF
if test $? = 0; then :; else
  echo "guile --use-srfi=17 doesn't give SRFI-17 car"
  exit 1
fi
