#! /bin/sh
exec ../src/sizzle -qs $0 $*
!#
;; test/regexp.scm -- regular expression tests
;;
;; Copyright (C) 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
;;
;; This 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, or (at your option)
;; any later version.
;; 
;; This software 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 package; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.  

;; Load the test framework.

(load "test-suite.scm")

;; Actual tests.

(begin-section "regexp")

(begin-sub-section "regexp?")
(pass-if (regexp? #t) #f eq?)
(pass-if (regexp? (make-regexp ".")) #t eq?)

(begin-sub-section "make-regexp")
(pass-if (regexp? (make-regexp ".")) #t eq?)
(pass-if (regexp? (make-regexp "." regexp/icase)) #t eq?)
(pass-if (regexp? (make-regexp "." regexp/extended)) #t eq?)
(pass-if (regexp? (make-regexp "." regexp/basic)) #t eq?)
(pass-if (regexp? (make-regexp "." regexp/newline)) #t eq?)

(begin-sub-section "regexp-exec")
(define rx0 (make-regexp "."))
(pass-if (vector? (regexp-exec rx0 "a")) #t eq?)
(define rx1 (make-regexp "^.$"))
(pass-if (vector? (regexp-exec rx1 "a")) #t eq?)
(pass-if (vector? (regexp-exec rx1 "aa")) #f eq?)
(pass-if (vector? (regexp-exec rx1 "aa" 0
			       (logior regexp/notbol regexp/noteol))) #f eq?)
(define rx2 (make-regexp "A" regexp/icase))
(pass-if (vector? (regexp-exec rx1 "a")) #t eq?)
(pass-if (vector? (regexp-exec rx1 "A")) #t eq?)

(test-summary)
