1 // REQUIRED_ARGS: -unittest
2 // EXTRA_SOURCES: imports/traits_getUnitTests_import.d
3 module traits_getUnitTests;
5 import imports.traits_getUnitTests_import;
19 void test_getUnitTestsFromModule ()
21 static assert(__traits(getUnitTests, mixin(__MODULE__)).length == 1);
24 struct SGetUnitTestsFromAggregate
29 class CGetUnitTestsFromAggregate
34 void test_getUnitTestsFromAggregate ()
36 static assert(__traits(getUnitTests, SGetUnitTestsFromAggregate).length == 1);
37 static assert(__traits(getUnitTests, CGetUnitTestsFromAggregate).length == 1);
40 void test_callUnitTestFunction ()
42 __traits(getUnitTests, mixin(__MODULE__))[0]();
43 assert(i == 2); // 2, because the standard unit test runner
44 // will call the unit test function as well
47 struct GetUnitTestsWithUDA
52 void test_getUnitTestsWithUDA ()
54 alias tests = Tuple!(__traits(getUnitTests, GetUnitTestsWithUDA));
55 static assert(tests.length == 1);
56 static assert(__traits(getAttributes, tests[0]).length == 1);
59 void test_getUnitTestsFromImport ()
61 static assert(__traits(getUnitTests, imports.traits_getUnitTests_import).length == 1);
62 static assert(__traits(getUnitTests, mixin("imports.traits_getUnitTests_import")).length == 1);
65 // https://issues.dlang.org/show_bug.cgi?id=11358
67 enum len11358 = __traits(getUnitTests, mixin(__MODULE__)).length;
71 test_getUnitTestsFromModule();
72 test_getUnitTestsFromAggregate();
73 test_callUnitTestFunction();
74 test_getUnitTestsWithUDA();
75 test_getUnitTestsFromImport();