src/asunit/framework/SuiteIterator.as in asunit4-4.2.2.pre vs src/asunit/framework/SuiteIterator.as in asunit4-4.2.3.pre
- old
+ new
@@ -1,48 +1,52 @@
-package asunit.framework {
+package asunit.framework {
+ import asunit.util.Iterator;
+
+ import p2.reflect.Reflection;
+ import p2.reflect.ReflectionVariable;
+
+ import flash.utils.getDefinitionByName;
- import asunit.util.Iterator;
-
- import flash.utils.getDefinitionByName;
-
- import p2.reflect.Reflection;
- import p2.reflect.ReflectionVariable;
- import p2.reflect.ReflectionMetaData;
-
public class SuiteIterator implements Iterator {
protected var index:int;
protected var list:Array;
- public function SuiteIterator(Suite:Class, bridge:CallbackBridge=null) {
- list = getTestClasses(Suite, bridge);
+ public function SuiteIterator(Suite:Class) {
+ list = getTestClasses(Suite);
}
- private function getTestClasses(Suite:Class, bridge:CallbackBridge=null):Array {
- if(bridge == null) bridge = new CallbackBridge();
-
- var reflection:Reflection = Reflection.create(Suite);
+ private function getTestClasses(Suite:Class):Array {
+ var reflection:Reflection = Reflection.create(Suite);
if(!isSuite(reflection) && isTest(reflection)) {
return [Suite];
}
var variable:ReflectionVariable;
var TestConstructor:Class;
var response:Array = [];
for each(variable in reflection.variables) {
TestConstructor = Class(getDefinitionByName(variable.type));
- if(isSuite(Reflection.create(TestConstructor))) {
- response = response.concat( getTestClasses(TestConstructor, bridge) );
+ if(isSuite(Reflection.create(TestConstructor))) {
+ var testClasses:Array = getTestClasses(TestConstructor);
+ for each(var testClass:Class in testClasses) {
+ pushIfNotInArray(testClass, response);
+ }
+ }
+ else {
+ pushIfNotInArray(TestConstructor, response)
}
- else if(bridge.shouldRunTest(TestConstructor)) {
- response.push(TestConstructor);
- }
}
response.sort();
return response;
- }
+ }
+
+ private function pushIfNotInArray(item:Object, array:Array):void {
+ if (array.indexOf(item) >= 0) return;
+ array[array.length] = item;
+ }
public function get length():uint {
return list.length;
}
@@ -56,10 +60,12 @@
public function hasNext():Boolean {
return list[index] != null;
}
- // Returns a Class reference:
+ /**
+ * Returns a test Class.
+ */
public function next():* {
return list[index++];
}
public function reset():void {