PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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