/trunk/Examples/test-suite/d/throw_exception_runme.2.d

# · D · 30 lines · 25 code · 5 blank · 0 comment · 1 complexity · 4caa60e24c20c447649843cc2c0839d8 MD5 · raw file

  1. module throw_exception_runme;
  2. import throw_exception.Foo;
  3. void main() {
  4. test!("test_int");
  5. test!("test_msg");
  6. test!("test_cls");
  7. test!("test_cls_ptr");
  8. test!("test_cls_ref");
  9. test!("test_cls_td");
  10. test!("test_cls_ptr_td");
  11. test!("test_cls_ref_td");
  12. test!("test_array");
  13. test!("test_enum");
  14. }
  15. void test(string methodName)() {
  16. auto foo = new Foo();
  17. bool didntThrow;
  18. try {
  19. mixin("foo." ~ methodName ~ "();");
  20. didntThrow = true;
  21. } catch (Exception) {}
  22. if (didntThrow) {
  23. throw new Exception(methodName ~ " failed");
  24. }
  25. }