New library of helper macros for the runtime tests.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5377 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
873bfced75
commit
9097e28fa4
1 changed files with 37 additions and 0 deletions
37
SWIG/Examples/test-suite/guile/testsuite.scm
Normal file
37
SWIG/Examples/test-suite/guile/testsuite.scm
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
;; Little helper functions and macros for the run tests
|
||||
|
||||
(use-modules (ice-9 format))
|
||||
|
||||
(define (test-error error-format . args)
|
||||
(display "Runtime check failed. ")
|
||||
(apply format #t error-format args)
|
||||
(newline)
|
||||
(exit 1))
|
||||
|
||||
(define-macro (expect-true form)
|
||||
`(if (not ,form)
|
||||
(test-error "Expected true value of ~A" ',form)))
|
||||
|
||||
(define-macro (expect-false form)
|
||||
`(if ,form
|
||||
(test-error "Expected false value of ~A" ',form)))
|
||||
|
||||
(define-macro (expect-result expected-result-form equal? form)
|
||||
`(let ((expected-result ,expected-result-form)
|
||||
(result ,form))
|
||||
(if (not (,equal? result expected-result))
|
||||
(test-error "The result of ~A was ~A, expected ~A, which is not ~A"
|
||||
',form result expected-result ',equal?))))
|
||||
|
||||
(define-macro (expect-throw tag-form form)
|
||||
`(let ((tag ,tag-form))
|
||||
(if (catch #t
|
||||
(lambda ()
|
||||
,form
|
||||
#t)
|
||||
(lambda (key . args)
|
||||
(if (eq? key ,tag-form)
|
||||
#f
|
||||
(test-error "The form ~A threw to ~A (expected a throw to ~A)"
|
||||
',form key tag))))
|
||||
(test-error "The form ~A returned normally (expected a throw to ~A)"))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue