-
Notifications
You must be signed in to change notification settings - Fork 6
/
modulespecification.d
54 lines (44 loc) · 956 Bytes
/
modulespecification.d
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
43
44
45
46
47
48
49
50
51
52
53
54
/*
* moduletester.d
*
* This module implements a class that will interface the testing of a module.
*
* Originated: May 6th, 2010
*
*/
module spec.modulespecification;
import spec.itemspecification;
import djehuty;
import io.console;
class ModuleSpecification {
this(string name) {
_name = name.dup;
}
string name() {
return _name;
}
void add(ItemSpecification item) {
_tests[item.name] = item;
}
// Description: This function will return a class representing the test
// given by the name.
// name: The name of the test.
// Returns: A class that can be used to run the test.
ItemSpecification retrieve(string name) {
if (!(name in _tests)) {
return null;
}
return _tests[name];
}
int opApply(int delegate(ref ItemSpecification) loopBody) {
foreach(test; _tests.keys.sort) {
if (loopBody(_tests[test])) {
return 1;
}
}
return 1;
}
private:
string _name;
ItemSpecification[string] _tests;
}