Removed:
trunk/src/haxelib.xml
Modified:
trunk/src/tests/iterations/Iteration2.hx
trunk/src/tests/utest/TestAssert.hx
trunk/src/utest/Assert.hx
trunk/src/utest/Runner.hx
trunk/src/utest/ui/text/TraceReport.hx
Log:
Runner does not consume fixtures anymore. Now they are simply iterated so
that the same runner can be used more than once.
Modified: trunk/src/tests/iterations/Iteration2.hx
==============================================================================
--- trunk/src/tests/iterations/Iteration2.hx (original)
+++ trunk/src/tests/iterations/Iteration2.hx Sun Nov 2 09:19:46 2008
@@ -10,7 +10,7 @@
// #1
public function testRunnerRun() {
var r = new Runner();
- r.fixtures.add(new TestFixture(new TestClass(), "assertTrue"));
+ r.addFixture(new TestFixture(new TestClass(), "assertTrue"));
r.onProgress.add(function(e) {
trace(e.done == 1 ? "OK @1" : "FAIL");
});
@@ -20,7 +20,7 @@
// #2
public function testAssertCreateAsync() {
var r = new Runner();
- r.fixtures.add(new TestFixture(new TestClass(), "assertAsync"));
+ r.addFixture(new TestFixture(new TestClass(), "assertAsync"));
r.onProgress.add(function(e) {
trace(e.done == 1 ? "OK @2" : "FAIL");
});
@@ -31,9 +31,9 @@
public function testRunnerSequenceOnAsync() {
var r = new Runner();
var test = new TestSequenceClass();
- r.fixtures.add(new TestFixture(test, "test1"));
- r.fixtures.add(new TestFixture(test, "test2"));
- r.fixtures.add(new TestFixture(test, "test3"));
+ r.addFixture(new TestFixture(test, "test1"));
+ r.addFixture(new TestFixture(test, "test2"));
+ r.addFixture(new TestFixture(test, "test3"));
r.onComplete.add(function(r){
trace(test.seq == "123" ? "OK @3" : "FAIL");
});
@@ -44,8 +44,8 @@
public function testRunnerAddCase() {
var r = new Runner();
r.addCase(new TestCaseClass());
- trace(r.fixtures.length == 1 ? "OK @4" : "FAIL");
- var fix = r.fixtures.pop();
+ trace(r.length == 1 ? "OK @4" : "FAIL");
+ var fix = r.getFixture(0);
trace(fix.method == "testOne" ? "OK @5" : "FAIL");
trace(fix.setup == null ? "OK @6" : "FAIL");
trace(fix.teardown == "teardown" ? "OK @7" : "FAIL");
@@ -55,7 +55,7 @@
public function testRunnerAddCaseCustomFun() {
var r = new Runner();
r.addCase(new TestCaseClass(), "_setup", "_teardown");
- var fix = r.fixtures.pop();
+ var fix = r.getFixture(0);
trace(fix.setup == "_setup" ? "OK @8" : "FAIL");
trace(fix.teardown == null ? "OK @9" : "FAIL");
}
@@ -64,8 +64,8 @@
public function testRunnerAddCaseCustomPrefix() {
var r = new Runner();
r.addCase(new TestCaseClass(), "_setup", "teardown", "Test");
- trace(r.fixtures.length == 1 ? "OK @10" : "FAIL ");
- var fix = r.fixtures.pop();
+ trace(r.length == 1 ? "OK @10" : "FAIL ");
+ var fix = r.getFixture(0);
trace(fix.method == "TestTwo" ? "OK @11" : "FAIL");
trace(fix.setup == "_setup" ? "OK @12" : "FAIL");
trace(fix.teardown == "teardown" ? "OK @13" : "FAIL");
@@ -75,7 +75,7 @@
public function testRunnerAddCaseCustomPattern() {
var r = new Runner();
r.addCase(new TestCaseClass(), null, null, ~/test/i);
- trace(r.fixtures.length == 3 ? "OK @14" : "FAIL");
+ trace(r.length == 3 ? "OK @14" : "FAIL");
}
Modified: trunk/src/tests/utest/TestAssert.hx
==============================================================================
--- trunk/src/tests/utest/TestAssert.hx (original)
+++ trunk/src/tests/utest/TestAssert.hx Sun Nov 2 09:19:46 2008
@@ -92,7 +92,7 @@
expect(expectedsuccess, i-expectedsuccess);
}
- public function testLikePrimitive() {
+ public function testSamePrimitive() {
bypass();
Assert.same(null, 1);
Assert.same(1, 1);
@@ -106,7 +106,7 @@
expect(3, 4);
}
- public function testLikeType() {
+ public function testSameType() {
bypass();
Assert.same(null, {});
Assert.same(null, null);
@@ -120,7 +120,7 @@
expect(1, 6);
}
- public function testLikeArray() {
+ public function testSameArray() {
bypass();
Assert.same([], []);
Assert.same([1], ["1"]);
@@ -135,7 +135,7 @@
expect(4, 4);
}
- public function testLikeObject() {
+ public function testSameObject() {
bypass();
Assert.same({}, {});
Assert.same({a:1}, {a:"1"});
@@ -152,7 +152,7 @@
public var value : String;
public var sub : TestAssert;
- public function testLikeInstance() {
+ public function testSameInstance() {
var c1 = new TestAssert();
c1.value = "a";
var c2 = new TestAssert();
@@ -180,7 +180,7 @@
expect(4, 2);
}
- public function testLikeIterable() {
+ public function testSameIterable() {
var list1 = new List<Dynamic>();
list1.add("a");
list1.add(1);
@@ -208,7 +208,7 @@
expect(3, 2);
}
- public function testLikeHash() {
+ public function testSameHash() {
var h1 = new Hash();
h1.set('a', 'b');
h1.set('c', 'd');
@@ -235,7 +235,7 @@
expect(2, 2);
}
- public function testLikeEnums() {
+ public function testSameEnums() {
bypass();
Assert.same(None, None);
Modified: trunk/src/utest/Assert.hx
==============================================================================
--- trunk/src/utest/Assert.hx (original)
+++ trunk/src/utest/Assert.hx Sun Nov 2 09:19:46 2008
@@ -256,6 +256,14 @@
}
}
+ public static function allow<T>(possibilities : Array<T>, value :
T, ?msg : String , ?pos : PosInfos) {
+ if(Lambda.has(possibilities, value)) {
+ isTrue(true, msg, pos);
+ } else {
+ fail(msg == null ? "value "+value+" not found in the expected
possibilities "+possibilities : msg, pos);
+ }
+ }
+
public static function fail(msg = "failure expected", ?pos : PosInfos) {
isTrue(false, msg, pos);
}
Modified: trunk/src/utest/Runner.hx
==============================================================================
--- trunk/src/utest/Runner.hx (original)
+++ trunk/src/utest/Runner.hx Sun Nov 2 09:19:46 2008
@@ -4,17 +4,19 @@
class Runner {
- public var fixtures(default, null) : List<TestFixture<Dynamic>>;
+ var fixtures(default, null) : Array<TestFixture<Dynamic>>;
public var onProgress(default, null) : Dispatcher<{ result : TestResult,
done : Int, totals : Int }>;
public var onStart(default, null) : Dispatcher<Runner>;
public var onComplete(default, null) : Dispatcher<Runner>;
+ public var length(default, null) : Int;
public function new() {
- fixtures = new List();
+ fixtures = new Array();
onProgress = new Dispatcher();
onStart = new Dispatcher();
onComplete = new Dispatcher();
+ length = 0;
}
public function addCase(test : Dynamic, setup = "setup", teardown
= "teardown", prefix = "test", ?pattern : EReg) {
@@ -28,16 +30,25 @@
for(field in fields) {
if(!StringTools.startsWith(field, prefix)) continue;
if(!isMethod(test, field)) continue;
- fixtures.add(new TestFixture(test, field, setup, teardown));
+ addFixture(new TestFixture(test, field, setup, teardown));
}
} else {
for(field in fields) {
if(!pattern.match(field)) continue;
if(!isMethod(test, field)) continue;
- fixtures.add(new TestFixture(test, field, setup, teardown));
+ addFixture(new TestFixture(test, field, setup, teardown));
}
}
}
+
+ public function addFixture(fixture : TestFixture<Dynamic>) {
+ fixtures.push(fixture);
+ length++;
+ }
+
+ public function getFixture(index : Int) {
+ return fixtures[index];
+ }
function isMethod(test : Dynamic, name : String) {
try {
@@ -47,22 +58,20 @@
}
}
- var testsToRun : Int;
+ var pos : Int;
public function run() {
- counter = 0;
- testsToRun = fixtures.length;
+ pos = 0;
onStart.dispatch(this);
runNext();
}
function runNext() {
- if(fixtures.length > 0)
- runFixture(fixtures.pop());
+ if(fixtures.length > pos)
+ runFixture(fixtures[pos++]);
else
onComplete.dispatch(this);
}
- var counter : Int;
function runFixture(fixture : TestFixture<Dynamic>) {
var handler = new TestHandler(fixture);
handler.onComplete.add(testComplete);
@@ -70,7 +79,7 @@
}
function testComplete(h : TestHandler<Dynamic>) {
- onProgress.dispatch({ result : TestResult.ofHandler(h), done :
fixtures.length+1, totals : testsToRun });
+ onProgress.dispatch({ result : TestResult.ofHandler(h), done : pos,
totals : length });
runNext();
}
}
Modified: trunk/src/utest/ui/text/TraceReport.hx
==============================================================================
--- trunk/src/utest/ui/text/TraceReport.hx (original)
+++ trunk/src/utest/ui/text/TraceReport.hx Sun Nov 2 09:19:46 2008
@@ -64,12 +64,12 @@
buf.add("errors: " + result.stats.errors+newline);
buf.add("failures: " + result.stats.failures+newline);
buf.add("warnings: " + result.stats.warnings+newline);
+ buf.add("classes: " + result.classNames(false).length+newline);
buf.add("execution time: " + time+newline);
#if php
buf.add("script time: " + scripttime+newline);
#end
buf.add(newline);
-
for(pname in result.packageNames()) {
var pack = result.getPackage(pname);