mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
(test-suite lib) uses plain old catch, not stack-catch
* test-suite/test-suite/lib.scm (run-test-exception): Refactor to just use "catch" instead of stack-catch.
This commit is contained in:
parent
48e65b4468
commit
af11242268
1 changed files with 22 additions and 28 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;;; test-suite/lib.scm --- generic support for testing
|
;;;; test-suite/lib.scm --- generic support for testing
|
||||||
;;;; Copyright (C) 1999, 2000, 2001, 2004, 2006, 2007, 2009, 2010,
|
;;;; Copyright (C) 1999, 2000, 2001, 2004, 2006, 2007, 2009, 2010,
|
||||||
;;;; 2011, 2012, 2013 Free Software Foundation, Inc.
|
;;;; 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This program is free software; you can redistribute it and/or
|
;;;; This program is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -18,8 +18,8 @@
|
||||||
;;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
|
;;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
(define-module (test-suite lib)
|
(define-module (test-suite lib)
|
||||||
#:use-module (ice-9 stack-catch)
|
|
||||||
#:use-module (ice-9 regex)
|
#:use-module (ice-9 regex)
|
||||||
|
#:use-module (ice-9 match)
|
||||||
#:autoload (srfi srfi-1) (append-map)
|
#:autoload (srfi srfi-1) (append-map)
|
||||||
#:autoload (system base compile) (compile)
|
#:autoload (system base compile) (compile)
|
||||||
#:export (
|
#:export (
|
||||||
|
@ -383,32 +383,26 @@
|
||||||
|
|
||||||
;;; A helper function to implement the macros that test for exceptions.
|
;;; A helper function to implement the macros that test for exceptions.
|
||||||
(define (run-test-exception name exception expect-pass thunk)
|
(define (run-test-exception name exception expect-pass thunk)
|
||||||
(run-test name expect-pass
|
(match exception
|
||||||
|
((expected-key . expected-pattern)
|
||||||
|
(run-test
|
||||||
|
name
|
||||||
|
expect-pass
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(stack-catch (car exception)
|
(catch expected-key
|
||||||
(lambda () (thunk) #f)
|
(lambda () (thunk) #f)
|
||||||
(lambda (key proc message . rest)
|
(lambda (key proc message . rest)
|
||||||
(cond
|
;; Match the message against the expected pattern. If that
|
||||||
;; handle explicit key
|
;; doesn't work, in the case of `misc-error' and
|
||||||
((string-match (cdr exception) message)
|
;; `syntax-error' we treat the message as a format string,
|
||||||
#t)
|
;; and format it. This is pretty terrible but it's
|
||||||
;; handle `(error ...)' which uses `misc-error' for key and doesn't
|
;; historical.
|
||||||
;; yet format the message and args (we have to do it here).
|
(or (and (string-match expected-pattern message) #t)
|
||||||
((and (eq? 'misc-error (car exception))
|
(and (memq expected-key '(misc-error syntax-error))
|
||||||
(list? rest)
|
(list? rest)
|
||||||
(string-match (cdr exception)
|
(let ((out (apply simple-format #f message (car rest))))
|
||||||
(apply simple-format #f message (car rest))))
|
(and (string-match expected-pattern out) #t)))
|
||||||
#t)
|
(apply throw key proc message rest)))))))))
|
||||||
;; handle syntax errors which use `syntax-error' for key and don't
|
|
||||||
;; yet format the message and args (we have to do it here).
|
|
||||||
((and (eq? 'syntax-error (car exception))
|
|
||||||
(list? rest)
|
|
||||||
(string-match (cdr exception)
|
|
||||||
(apply simple-format #f message (car rest))))
|
|
||||||
#t)
|
|
||||||
;; unhandled; throw again
|
|
||||||
(else
|
|
||||||
(apply throw key proc message rest))))))))
|
|
||||||
|
|
||||||
;;; A short form for tests that expect a certain exception to be thrown.
|
;;; A short form for tests that expect a certain exception to be thrown.
|
||||||
(define-syntax pass-if-exception
|
(define-syntax pass-if-exception
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue