PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/modulespecification.d

http://github.com/wilkie/djehuty
D | 54 lines | 32 code | 10 blank | 12 comment | 2 complexity | f2a3e6b2112f3aa5d8aea567c17b6653 MD5 | raw file
 1/*
 2 * moduletester.d
 3 *
 4 * This module implements a class that will interface the testing of a module.
 5 *
 6 * Originated: May 6th, 2010
 7 *
 8 */
 9
10module spec.modulespecification;
11
12import spec.itemspecification;
13
14import djehuty;
15
16import io.console;
17
18class ModuleSpecification {
19	this(string name) {
20		_name = name.dup;
21	}
22
23	string name() {
24		return _name;
25	}
26
27	void add(ItemSpecification item) {
28		_tests[item.name] = item;
29	}
30
31	// Description: This function will return a class representing the test
32	//   given by the name.
33	// name: The name of the test.
34	// Returns: A class that can be used to run the test.
35	ItemSpecification retrieve(string name) {
36		if (!(name in _tests)) {
37			return null;
38		}
39		return _tests[name];
40	}
41
42	int opApply(int delegate(ref ItemSpecification) loopBody) {
43		foreach(test; _tests.keys.sort) {
44			if (loopBody(_tests[test])) {
45				return 1;
46			}
47		}
48		return 1;
49	}
50
51private:
52	string _name;
53	ItemSpecification[string] _tests;
54}