File: throw_exception_runme.scm

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (45 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
;; The SWIG modules have "passive" Linkage, i.e., they don't generate
;; Guile modules (namespaces) but simply put all the bindings into the
;; current module.  That's enough for such a simple test.
(dynamic-call "scm_init_throw_exception_module" (dynamic-link "./libthrow_exception"))

(define-macro (check-throw form)
  `(catch 'swig-exception
     (lambda ()
       ,form
       (error "Check failed (returned normally): " ',form))
     (lambda (key result)
       result)))

(define-macro (check-throw-error form)
  `(let ((result (check-throw ,form)))
     (test-is-Error result)))

(let ((foo (new-Foo)))
  (let ((result (check-throw (Foo-test-int foo))))
    (if (not (eqv? result 37))
	(error "Foo-test-int failed, returned " result)))
  (let ((result (check-throw (Foo-test-multi foo 1))))
    (if (not (eqv? result 37))
	(error "Foo-test-multi 1 failed, returned " result)))
  (let ((result (check-throw (Foo-test-msg foo))))
    (if (not (and (string? result)
		  (string=? result "Dead")))
	(error "Foo-test-msg failed, returned " result)))
  (let ((result (check-throw (Foo-test-multi foo 2))))
    (if (not (and (string? result)
		  (string=? result "Dead")))
	(error "Foo-test-multi 2 failed, returned " result)))
  (check-throw-error (Foo-test-cls foo))
  (check-throw-error (Foo-test-multi foo 3))
  (check-throw-error (Foo-test-cls-ptr foo))
  (check-throw-error (Foo-test-cls-ref foo))
  ;; Namespace stuff
  (let ((result (check-throw (Foo-test-enum foo))))
    (if (not (eqv? result (enum2)))
	(error "Foo-test-enum failed, returned " result)))
  (check-throw-error (Foo-test-cls-td foo))
  (check-throw-error (Foo-test-cls-ptr-td foo))
  (check-throw-error (Foo-test-cls-ref-td foo)))
  			      
(exit 0)