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

/trunk/Examples/test-suite/chicken/throw_exception_runme.ss

#
Scheme | 29 lines | 20 code | 7 blank | 2 comment | 0 complexity | 0185883782886857885e82e0fd4f237e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. (load "throw_exception.so")
  2. (define-macro (check-throw expr check)
  3. `(if (handle-exceptions exvar (if ,check #f (begin (print "Error executing: " ',expr " " exvar) (exit 1))) ,expr #t)
  4. (print "Expression did not throw an error: " ',expr)))
  5. (define f (new-Foo))
  6. (check-throw (Foo-test-int f) (= exvar 37))
  7. (check-throw (Foo-test-msg f) (string=? exvar "Dead"))
  8. (check-throw (Foo-test-cls f) (test-is-Error exvar))
  9. (check-throw (Foo-test-cls-ptr f) (test-is-Error exvar))
  10. (check-throw (Foo-test-cls-ref f) (test-is-Error exvar))
  11. (check-throw (Foo-test-cls-td f) (test-is-Error exvar))
  12. (check-throw (Foo-test-cls-ptr-td f) (test-is-Error exvar))
  13. (check-throw (Foo-test-cls-ref-td f) (test-is-Error exvar))
  14. (check-throw (Foo-test-enum f) (= exvar (enum2)))
  15. ; don't know how to test this... it is returning a SWIG wrapped int *
  16. ;(check-throw (Foo-test-array f) (equal? exvar '(0 1 2 3 4 5 6 7 8 9)))
  17. (check-throw (Foo-test-multi f 1) (= exvar 37))
  18. (check-throw (Foo-test-multi f 2) (string=? exvar "Dead"))
  19. (check-throw (Foo-test-multi f 3) (test-is-Error exvar))
  20. (set! f #f)
  21. (gc #t)
  22. (exit 0)