1 /**
2  A module with tests to test the compile-time reflection
3  */
4 
5 module unit_threaded.ut.modules.parametrized;
6 
7 import unit_threaded.runner.attrs;
8 
9 version(unittest) {
10 
11     @(1, 2, 3)
12     @AutoTags
13     void testValues(int i) {
14         assert(i % 2 != 0);
15     }
16 
17     @Types!(float, int)
18     @AutoTags
19     void testTypes(T)() {
20         assert(T.init == 0);
21     }
22 
23     @Name("my_name_is_test")
24     @UnitTest
25     @Types!(float, int)
26     void typesWithName(T)() {
27         assert(T.init == 0);
28     }
29 
30     struct Foo { int i; }
31     struct Bar { int i; }
32 
33     @Name("cartesian_types")
34     @UnitTest
35     @Types!(int, float)
36     @Types!(string, Foo, Bar)
37     void cartesianTypes(T0, T1)() {
38         static assert(T0.sizeof == 4);
39         assert(T1.sizeof == 4);
40     }
41 }
42 
43 @("builtinIntValues")
44 @AutoTags
45 @Values(2, 3, 4, 5)
46 unittest {
47     import std.conv;
48     immutable i = getValue!int;
49     assert(i == 3);
50 }
51 
52 @("cartesianBuiltinNoAutoTags")
53 @Values("foo", "bar")
54 @Values("red", "blue", "green")
55 unittest {
56     assert(getValue!(string, 0).length == getValue!(string, 1).length);
57 }
58 
59 @("cartesianBuiltinAutoTags")
60 @Values("foo", "bar")
61 @Values("red", "blue", "green")
62 @AutoTags
63 unittest {
64     assert(getValue!(string, 0).length == getValue!(string, 1).length);
65 }
66 
67 
68 
69 @(1, 2, 3)
70 @("foo", "bar")
71 @AutoTags
72 testCartesianFunction(int i, string s) {
73     assert(i == 2 && s == "bar");
74 }
75 
76 
77 void testIssue31(int, string) {
78     // this used to fail because there are no UDAs on this function
79 }