describeModule

Describe a module and containing members

describeModule
(
bool withUnitTests = false
)
()
if (
__traits(isModule, T)
)

Examples

It should describe a module with all functions, aggregates, templates, and global vars

1 import introspection.test.moduleDef;
2 
3 auto result = describeModule!(introspection.test.moduleDef, true);
4 
5 result.name.should.equal("module moduleDef");
6 result.fullyQualifiedName.should.equal("introspection.test.moduleDef");
7 
8 /// check functions
9 result.functions.length.should.equal(2);
10 result.functions[0].name.should.equal("testFunction");
11 result.functions[1].name.should.equal("privateFunction");
12 
13 /// check aggregates
14 result.aggregates.length.should.equal(4);
15 result.aggregates[0].name.should.equal("TestStructure");
16 result.aggregates[1].name.should.equal("TestClass");
17 result.aggregates[2].name.should.equal("TestInterface");
18 result.aggregates[3].name.should.equal("TestUnion");
19 
20 /// check templates
21 result.templates.length.should.equal(2);
22 result.templates[0].name.should.equal("TestTpl");
23 result.templates[1].name.should.equal("templatedFunction");
24 
25 /// check globals
26 result.globals.length.should.equal(1);
27 result.globals[0].name.should.equal("globalVar");
28 
29 /// check manifest constants
30 result.manifestConstants.length.should.equal(1);
31 result.manifestConstants[0].name.should.equal("someManifestConstant");
32 
33 /// check unittests
34 result.unitTests.length.should.equal(2);
35 
36 ///
37 result.location.file.should.equal("source/introspection/test/moduleDef.d");
38 result.location.line.should.equal(0);
39 result.location.column.should.equal(0);

It should be able to describe the std.array module

1 import std.array;
2 
3 auto result = describeModule!(std.array);
4 
5 result.name.should.equal("module array");
6 result.fullyQualifiedName.should.equal("std.array");
7 
8 result.functions.length.should.equal(1);
9 result.functions[0].name.should.equal("_d_newarrayU");
10 
11 result.templates.length.should.equal(31);

It should be able to describe the std.stdio module

1 import std.stdio;
2 
3 auto result = describeModule!(std.stdio);
4 
5 result.name.should.equal("module stdio");
6 result.fullyQualifiedName.should.equal("std.stdio");
7 
8 result.functions.length.should.equal(22);
9 result.functions[0].name.should.equal("fputc_unlocked");
10 
11 result.templates.length.should.equal(15);

Meta