annotate orange/test/UnitTester.d @ 26:78e5fef4bbf2 experimental

Third step in refactoring the API. Stating to add unit tests.
author Jacob Carlborg <doob@me.com>
date Tue, 19 Oct 2010 10:22:10 +0200
parents
children fc315d786f24
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
1 /**
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
2 * Copyright: Copyright (c) 2010 Jacob Carlborg. All rights reserved.
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
3 * Authors: Jacob Carlborg
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
4 * Version: Initial created: Oct 17, 2010
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
6 */
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
7 module orange.test.UnitTester;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
8
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
9 import tango.core.Exception;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
10 import orange.core._;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
11 import orange.util._;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
12
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
13 class UnitTester
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
14 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
15 private
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
16 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
17 struct Test
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
18 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
19 void delegate () test;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
20 string message;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
21 AssertException exception;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
22
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
23 bool failed ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
24 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
25 return !succeeded;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
26 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
27
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
28 bool succeeded ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
29 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
30 return !exception;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
31 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
32
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
33 void run ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
34 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
35 if (!isPending)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
36 test();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
37 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
38
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
39 bool isPending ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
40 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
41 return test is null;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
42 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
43 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
44
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
45 Test[] tests;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
46 AssertException[] exceptions;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
47 void delegate () pre_;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
48 void delegate () post_;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
49 size_t failures;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
50 size_t pending;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
51 size_t lastIndex = size_t.max;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
52 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
53
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
54 Use!(void delegate (), string) test (string message)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
55 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
56 tests ~= Test(null, message);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
57 lastIndex++;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
58
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
59 Use!(void delegate (), string) use;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
60
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
61 use.args[0] = &internalTest;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
62 use.args[1] = message;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
63
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
64 return use;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
65 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
66
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
67 void run ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
68 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
69 foreach (test ; tests)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
70 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
71 if (test.isPending)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
72 pending++;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
73
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
74 try
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
75 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
76 execute in {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
77 test.run();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
78 };
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
79 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
80
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
81 catch (AssertException e)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
82 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
83 exceptions ~= e;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
84 failures++;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
85 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
86 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
87
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
88 printResult;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
89 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
90
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
91 void delegate () pre ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
92 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
93 return pre_;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
94 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
95
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
96 void delegate () pre (void delegate () pre)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
97 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
98 return pre_ = pre;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
99 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
100
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
101 void delegate () post ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
102 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
103 return post_;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
104 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
105
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
106 void delegate () post (void delegate () post)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
107 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
108 return post_ = post;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
109 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
110
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
111 private void internalTest (void delegate () dg, string message)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
112 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
113 tests[lastIndex] = Test(dg, message);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
114 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
115
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
116 private void printResult ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
117 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
118 if (isAllTestsSuccessful)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
119 return printSuccess();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
120
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
121 foreach (test ; tests)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
122 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
123 print("- ", test.message);
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
124
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
125 if (test.isPending)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
126 print(" ", "(PENDING: Not Yet Implemented)");
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
127
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
128 println();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
129 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
130
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
131 print("\n", tests.length, " test, ", failures, " failures");
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
132 printPending();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
133 println();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
134 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
135
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
136 private void printPending ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
137 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
138 if (hasPending)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
139 print(", ", pending, " pending");
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
140 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
141
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
142 private void printSuccess ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
143 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
144 println("All ", tests.length, " tests passed successfully.");
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
145 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
146
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
147 private bool isAllTestsSuccessful ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
148 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
149 return !hasPending && !hasFailures;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
150 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
151
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
152 private bool hasPending ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
153 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
154 return pending > 0;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
155 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
156
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
157 private bool hasFailures ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
158 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
159 return failures > 0;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
160 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
161
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
162 private Use!(void delegate ()) execute ()
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
163 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
164 Use!(void delegate ()) use;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
165
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
166 use.args[0] = &executeImpl;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
167
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
168 return use;
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
169 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
170
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
171 private void executeImpl (void delegate () dg)
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
172 {
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
173 if (pre) pre();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
174 if (dg) dg();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
175 if (post) post();
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
176 }
78e5fef4bbf2 Third step in refactoring the API. Stating to add unit tests.
Jacob Carlborg <doob@me.com>
parents:
diff changeset
177 }