PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/guile/throw_exception_runme.scm

#
Lisp | 45 lines | 37 code | 4 blank | 4 comment | 0 complexity | 4854f9814d167f06544b5be7076ebdff MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  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"))
  5. (define-macro (check-throw form)
  6. `(catch 'swig-exception
  7. (lambda ()
  8. ,form
  9. (error "Check failed (returned normally): " ',form))
  10. (lambda (key result)
  11. result)))
  12. (define-macro (check-throw-error form)
  13. `(let ((result (check-throw ,form)))
  14. (test-is-Error result)))
  15. (let ((foo (new-Foo)))
  16. (let ((result (check-throw (Foo-test-int foo))))
  17. (if (not (eqv? result 37))
  18. (error "Foo-test-int failed, returned " result)))
  19. (let ((result (check-throw (Foo-test-multi foo 1))))
  20. (if (not (eqv? result 37))
  21. (error "Foo-test-multi 1 failed, returned " result)))
  22. (let ((result (check-throw (Foo-test-msg foo))))
  23. (if (not (and (string? result)
  24. (string=? result "Dead")))
  25. (error "Foo-test-msg failed, returned " result)))
  26. (let ((result (check-throw (Foo-test-multi foo 2))))
  27. (if (not (and (string? result)
  28. (string=? result "Dead")))
  29. (error "Foo-test-multi 2 failed, returned " result)))
  30. (check-throw-error (Foo-test-cls foo))
  31. (check-throw-error (Foo-test-multi foo 3))
  32. (check-throw-error (Foo-test-cls-ptr foo))
  33. (check-throw-error (Foo-test-cls-ref foo))
  34. ;; Namespace stuff
  35. (let ((result (check-throw (Foo-test-enum foo))))
  36. (if (not (eqv? result (enum2)))
  37. (error "Foo-test-enum failed, returned " result)))
  38. (check-throw-error (Foo-test-cls-td foo))
  39. (check-throw-error (Foo-test-cls-ptr-td foo))
  40. (check-throw-error (Foo-test-cls-ref-td foo)))
  41. (exit 0)