1 module unit_threaded.ut.modules.module_with_attrs;
2 
3 import unit_threaded.runner.attrs;
4 import std.exception;
5 
6 @HiddenTest("foo")
7 @ShouldFail("bar")
8 @SingleThreaded
9 void testAttrs() { }
10 
11 @ShouldFailWith!Exception
12 void testOtherAttrs() {}
13 
14 
15 @ShouldFail
16 @(1, 2, 3)
17 void testValues(int i) { }
18 
19 @DontTest
20 @("DontTestBlock")
21 unittest {
22     assert(0);
23 }
24 
25 @ShouldFail
26 @("will fail")
27 unittest {
28     assert(0);
29 }
30 
31 class TestException : Exception { this(string m) { super(m); } }
32 
33 @ShouldFailWith!TestException
34 @("ShouldFailWith that fails due to wrong type")
35 unittest {
36     assert(0);
37 }
38 
39 @ShouldFailWith!TestException
40 @("ShouldFailWith that fails due to not failing")
41 unittest {
42 }
43 
44 
45 @ShouldFailWith!TestException
46 @("ShouldFailWith that passes")
47 unittest {
48     throw new TestException("you won't see this");
49 }
50 
51 
52 @Flaky
53 @("flaky that passes eventually")
54 unittest {
55     static int i = 0;
56     if(i++ % 2 == 0) throw new Exception("failed");
57 }
58 
59 @Flaky(1)
60 @("flaky that fails due to not enough retries")
61 unittest {
62     static int i = 0;
63     if(i++ % 2 == 0) throw new Exception("failed");
64 }