1 ;; The SWIG modules have "passive" Linkage, i.e., they don't generate
2 ;; Guile modules (namespaces) but simply put all the bindings into the
3 ;; current module. That's enough for such a simple test.
4 (dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception.so"))
6 (define-macro (check-throw form)
7 `(catch 'swig-exception
10 (error "Check failed (returned normally): " ',form))
14 (define-macro (check-throw-error form)
15 `(let ((result (check-throw ,form)))
16 (test-is-Error result)))
18 (let ((foo (new-Foo)))
19 (let ((result (check-throw (Foo-test-int foo))))
20 (if (not (eqv? result 37))
21 (error "Foo-test-int failed, returned " result)))
22 (let ((result (check-throw (Foo-test-multi foo 1))))
23 (if (not (eqv? result 37))
24 (error "Foo-test-multi 1 failed, returned " result)))
25 (let ((result (check-throw (Foo-test-msg foo))))
26 (if (not (and (string? result)
27 (string=? result "Dead")))
28 (error "Foo-test-msg failed, returned " result)))
29 (let ((result (check-throw (Foo-test-multi foo 2))))
30 (if (not (and (string? result)
31 (string=? result "Dead")))
32 (error "Foo-test-multi 2 failed, returned " result)))
33 (check-throw-error (Foo-test-cls foo))
34 (check-throw-error (Foo-test-multi foo 3))
35 (check-throw-error (Foo-test-cls-ptr foo))
36 (check-throw-error (Foo-test-cls-ref foo))
38 (let ((result (check-throw (Foo-test-enum foo))))
39 (if (not (eqv? result (enum2)))
40 (error "Foo-test-enum failed, returned " result)))
41 (check-throw-error (Foo-test-cls-td foo))
42 (check-throw-error (Foo-test-cls-ptr-td foo))
43 (check-throw-error (Foo-test-cls-ref-td foo)))