blob: 3b028d42bf67340a94f5809ff41efcfd068e771f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// REQUIRED_ARGS: -unittest
// COMPILE_SEPARATELY
// EXTRA_SOURCES: imports/module_with_tests.d imports/another_module_with_tests.d
import imports.module_with_tests;
import imports.another_module_with_tests;
import core.exception: AssertError;
shared static this()
{
import core.runtime: Runtime, UnitTestResult;
Runtime.extendedModuleUnitTester = () => UnitTestResult.pass;
}
void main()
{
foreach(i, ut; __traits(getUnitTests, imports.module_with_tests))
{
try
{
ut();
assert(i == 0, "2nd unittest should fail");
}
catch(AssertError e)
{
assert(i == 1, "Only 2nd unittest should fail");
}
}
foreach(i, ut; __traits(getUnitTests, imports.another_module_with_tests))
{
try
{
ut();
assert(i == 0 || i == 1, "3rd unittest should fail");
}
catch(AssertError e)
{
assert(i == 2, "Only 3rd unittest should fail");
}
}
}
|