asproject 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/CHANGELOG.txt +0 -0
  2. data/History.txt +0 -0
  3. data/MIT-LICENSE.txt +20 -0
  4. data/Manifest.txt +16 -0
  5. data/README.txt +3 -0
  6. data/TODO.txt +10 -0
  7. data/bin/asclass +16 -0
  8. data/bin/asproject +16 -0
  9. data/lib/asclass.rb +254 -0
  10. data/lib/asclass_arguments.rb +147 -0
  11. data/lib/asproject.rb +248 -0
  12. data/lib/asproject/version.rb +9 -0
  13. data/lib/asproject_arguments.rb +175 -0
  14. data/lib/asproject_base.rb +43 -0
  15. data/lib/asproject_utils.rb +57 -0
  16. data/lib/eclipse_project.rb +32 -0
  17. data/lib/path_finder.rb +286 -0
  18. data/lib/platform.rb +107 -0
  19. data/lib/project.rb +82 -0
  20. data/lib/template_resolver.rb +144 -0
  21. data/lib/test_suite_generator.rb +128 -0
  22. data/rakefile.rb +85 -0
  23. data/setup.rb +1585 -0
  24. data/templates/asclass/as2/Class.as +11 -0
  25. data/templates/asclass/as2/Component.as +8 -0
  26. data/templates/asclass/as2/Interface.as +3 -0
  27. data/templates/asclass/as2/TestCase.as +30 -0
  28. data/templates/asclass/as2/TestSuite.as +15 -0
  29. data/templates/asclass/as3/Class.as +9 -0
  30. data/templates/asclass/as3/Component.as +9 -0
  31. data/templates/asclass/as3/Component.mxml +1 -0
  32. data/templates/asclass/as3/Interface.as +6 -0
  33. data/templates/asclass/as3/TestCase.as +30 -0
  34. data/templates/asclass/as3/TestSuite.as +18 -0
  35. data/templates/asproject/as2/project/rakefile.rb +18 -0
  36. data/templates/asproject/as2/project/src/AsProject.as +13 -0
  37. data/templates/asproject/as2/project/test/AsProjectRunner.as +12 -0
  38. data/templates/asproject/as3/project/rakefile.rb +18 -0
  39. data/templates/asproject/as3/project/src/AsProject.as +9 -0
  40. data/templates/asproject/as3/project/src/AsProjectRunner.as +11 -0
  41. data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
  42. data/templates/asproject/asunit2/project/lib/asunit/Sys.as +70 -0
  43. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +182 -0
  44. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +84 -0
  45. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +111 -0
  46. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +26 -0
  47. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +81 -0
  48. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +35 -0
  49. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +34 -0
  50. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +43 -0
  51. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +10 -0
  52. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +169 -0
  53. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +29 -0
  54. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +27 -0
  55. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +19 -0
  56. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +408 -0
  57. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +27 -0
  58. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +68 -0
  59. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +3 -0
  60. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +191 -0
  61. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +31 -0
  62. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +15 -0
  63. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +15 -0
  64. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +41 -0
  65. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +19 -0
  66. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +22 -0
  67. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +325 -0
  68. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +24 -0
  69. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +32 -0
  70. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +7 -0
  71. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +29 -0
  72. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +89 -0
  73. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +42 -0
  74. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +47 -0
  75. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +61 -0
  76. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +58 -0
  77. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +11 -0
  78. data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +30 -0
  79. data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +13 -0
  80. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +7 -0
  81. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +7 -0
  82. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +7 -0
  83. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +7 -0
  84. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +7 -0
  85. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +7 -0
  86. data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +7 -0
  87. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +376 -0
  88. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +15 -0
  89. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +59 -0
  90. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +13 -0
  91. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +11 -0
  92. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +277 -0
  93. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +23 -0
  94. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +29 -0
  95. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +38 -0
  96. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
  97. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +168 -0
  98. data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +102 -0
  99. data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +101 -0
  100. data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +8 -0
  101. data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +254 -0
  102. data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +41 -0
  103. data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +17 -0
  104. data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +24 -0
  105. data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +52 -0
  106. data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +5 -0
  107. data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +10 -0
  108. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +10 -0
  109. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +10 -0
  110. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +10 -0
  111. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +10 -0
  112. data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +10 -0
  113. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +271 -0
  114. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +52 -0
  115. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +71 -0
  116. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +15 -0
  117. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +351 -0
  118. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +73 -0
  119. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
  120. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +22 -0
  121. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +158 -0
  122. data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +115 -0
  123. data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +15 -0
  124. data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +9 -0
  125. data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +11 -0
  126. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +19 -0
  127. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +55 -0
  128. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +245 -0
  129. data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +121 -0
  130. data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +26 -0
  131. data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +9 -0
  132. data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +30 -0
  133. data/templates/asproject/asunit3/project/lib/asunit/mx/managers/LayoutManager.as +945 -0
  134. data/templates/asproject/config/project/config/asclass_config.rb +58 -0
  135. data/templates/asproject/fb2as/project/.actionScriptProperties +21 -0
  136. data/templates/asproject/fb2as/project/.project +29 -0
  137. data/templates/asproject/fdt/project/.as2_classpath +6 -0
  138. data/templates/asproject/fdt/project/.project +19 -0
  139. data/templates/ide/mate/Create Class.tmCommand +37 -0
  140. data/templates/ide/mate/Rebuild Test Suites.tmCommand +33 -0
  141. data/templates/ide/mate/Run Rake Task.tmCommand +127 -0
  142. metadata +266 -0
@@ -0,0 +1,73 @@
1
+ package asunit.framework {
2
+ import asunit.framework.TestCase;
3
+ import flash.display.Sprite;
4
+ import flash.events.Event;
5
+ import flash.events.IEventDispatcher;
6
+ import flash.events.EventDispatcher;
7
+ import flash.utils.setTimeout;
8
+
9
+ // TestCase subclasses should always end with 'Test', the example
10
+ // doesn't because we don't want TestSuites in this directory.
11
+ public class TestCaseExample extends TestCase {
12
+ private var date:Date;
13
+ private var sprite:Sprite;
14
+
15
+ // TestCase constructors must be implemented as follows
16
+ // so that we can execute a single method on them from
17
+ // the TestRunner
18
+ public function TestCaseExample(testMethod:String = null) {
19
+ super(testMethod);
20
+ }
21
+
22
+ // This method will be called before every test method
23
+ override protected function setUp():void {
24
+ date = new Date();
25
+ // sprite = new Sprite();
26
+ // addChild(sprite);
27
+ }
28
+
29
+ // This method will be called after every test method
30
+ // but only if we're executing the entire TestCase,
31
+ // the tearDown method won't be called if we're
32
+ // calling start(MyTestCase, "someMethod");
33
+ override protected function tearDown():void {
34
+ // removeChild(sprite);
35
+ // sprite = null;
36
+ date = null;
37
+ }
38
+
39
+ // This is auto-created by the XULUI and ensures that
40
+ // our objects are actually created as we expect.
41
+ public function testInstantiated():void {
42
+ assertTrue("Date instantiated", date is Date);
43
+ // assertTrue("Sprite instantiated", sprite is Sprite);
44
+ }
45
+
46
+ // This is an example of a typical test method
47
+ public function testMonthGetterSetter():void {
48
+ date.month = 1;
49
+ assertEquals(1, date.month);
50
+ }
51
+
52
+ // This is an asynchronous test method
53
+ public function testAsyncFeature():void {
54
+ // create a new object that dispatches events...
55
+ var dispatcher:IEventDispatcher = new EventDispatcher();
56
+ // get a TestCase async event handler reference
57
+ // the 2nd arg is an optional timeout in ms. (default=1000ms )
58
+ var handler:Function = addAsync(changeHandler, 2000);
59
+ // subscribe to your event dispatcher using the returned handler
60
+ dispatcher.addEventListener(Event.CHANGE, handler);
61
+ // cause the event to be dispatched.
62
+ // either immediately:
63
+ //dispatcher.dispatchEvent(new Event(Event.CHANGE));
64
+ // or in the future < your assigned timeout
65
+ setTimeout( dispatcher.dispatchEvent, 200, new Event(Event.CHANGE));
66
+ }
67
+
68
+ protected function changeHandler(event:Event):void {
69
+ // perform assertions in your handler
70
+ assertEquals(Event.CHANGE, event.type);
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,47 @@
1
+ package asunit.framework {
2
+ import asunit.errors.AssertionFailedError;
3
+
4
+ /**
5
+ * A <code>TestFailure</code> collects a failed test together with
6
+ * the caught exception.
7
+ * @see TestResult
8
+ */
9
+ public class TestFailure {
10
+ protected var fFailedTest:String;
11
+ protected var fThrownException:Error;
12
+
13
+ /**
14
+ * Constructs a TestFailure with the given test and exception.
15
+ */
16
+ public function TestFailure(failedTest:Test, thrownException:Error) {
17
+ fFailedTest = failedTest.toString();
18
+ fThrownException = thrownException;
19
+ }
20
+ /**
21
+ * Gets the failed test.
22
+ */
23
+ public function failedTest():String {
24
+ return fFailedTest;
25
+ }
26
+ /**
27
+ * Gets the thrown exception.
28
+ */
29
+ public function thrownException():Error {
30
+ return fThrownException;
31
+ }
32
+ /**
33
+ * Returns a short description of the failure.
34
+ */
35
+ public function toString():String {
36
+ return "";
37
+ }
38
+
39
+ public function exceptionMessage():String {
40
+ return thrownException().message;
41
+ }
42
+
43
+ public function isFailure():Boolean {
44
+ return thrownException() is AssertionFailedError;
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,22 @@
1
+ package asunit.framework {
2
+ import asunit.errors.AssertionFailedError;
3
+
4
+ public interface TestListener {
5
+ /**
6
+ * An error occurred.
7
+ */
8
+ function addError(test:Test, t:Error):void;
9
+ /**
10
+ * A failure occurred.
11
+ */
12
+ function addFailure(test:Test, t:AssertionFailedError):void;
13
+ /**
14
+ * A test ended.
15
+ */
16
+ function endTest(test:Test):void;
17
+ /**
18
+ * A test started.
19
+ */
20
+ function startTest(test:Test):void;
21
+ }
22
+ }
@@ -0,0 +1,158 @@
1
+ package asunit.framework {
2
+ import asunit.errors.AssertionFailedError;
3
+ import asunit.errors.InstanceNotFoundError;
4
+
5
+ import flash.errors.IllegalOperationError;
6
+ import flash.events.EventDispatcher;
7
+
8
+ /**
9
+ * A <code>TestResult</code> collects the results of executing
10
+ * a test case. It is an instance of the Collecting Parameter pattern.
11
+ * The test framework distinguishes between <i>failures</i> and <i>errors</i>.
12
+ * A failure is anticipated and checked for with assertions. Errors are
13
+ * unanticipated problems like an <code>ArrayIndexOutOfBoundsException</code>.
14
+ *
15
+ * @see Test
16
+ */
17
+ public class TestResult {
18
+ protected var fFailures:Array;
19
+ protected var fErrors:Array;
20
+ protected var fListeners:Array;
21
+ protected var fRunTests:int;
22
+ private var fStop:Boolean;
23
+
24
+ public function TestResult() {
25
+ fFailures = new Array();
26
+ fErrors = new Array();
27
+ fListeners = new Array();
28
+ fRunTests = 0;
29
+ fStop = false;
30
+ }
31
+ /**
32
+ * Adds an error to the list of errors. The passed in exception
33
+ * caused the error.
34
+ */
35
+ public function addError(test:Test, t:Error):void {
36
+ fErrors.push(new TestFailure(test, t));
37
+ var len:uint = fListeners.length;
38
+ var item:TestListener;
39
+ for(var i:uint; i < len; i++) {
40
+ item = TestListener(fListeners[i]);
41
+ item.addError(test, t);
42
+ }
43
+ }
44
+ /**
45
+ * Adds a failure to the list of failures. The passed in exception
46
+ * caused the failure.
47
+ */
48
+ public function addFailure(test:Test, t:AssertionFailedError):void {
49
+ fFailures.push(new TestFailure(test, t));
50
+ var len:uint = fListeners.length;
51
+ var item:TestListener;
52
+ for(var i:uint; i < len; i++) {
53
+ item = TestListener(fListeners[i]);
54
+ item.addFailure(test, t);
55
+ }
56
+ }
57
+ /**
58
+ * Registers a TestListener
59
+ */
60
+ public function addListener(listener:TestListener):void {
61
+ fListeners.push(listener);
62
+ }
63
+ /**
64
+ * Unregisters a TestListener
65
+ */
66
+ public function removeListener(listener:TestListener):void {
67
+ var len:uint = fListeners.length;
68
+ for(var i:uint; i < len; i++) {
69
+ if(fListeners[i] == listener) {
70
+ fListeners.splice(i, 1);
71
+ return;
72
+ }
73
+ }
74
+ throw new InstanceNotFoundError("removeListener called without listener in list");
75
+ }
76
+ /**
77
+ * Gets the number of detected errors.
78
+ */
79
+ public function errorCount():int {
80
+ return fErrors.length;
81
+ }
82
+ /**
83
+ * Returns an Enumeration for the errors
84
+ */
85
+ public function errors():Array {
86
+ return fErrors;
87
+ }
88
+ /**
89
+ * Gets the number of detected failures.
90
+ */
91
+ public function failureCount():int {
92
+ return fFailures.length;
93
+ }
94
+ /**
95
+ * Returns an Enumeration for the failures
96
+ */
97
+ public function failures():Array {
98
+ return fFailures;
99
+ }
100
+
101
+ /**
102
+ * Runs a TestCase.
103
+ */
104
+ public function run(test:TestCase):void {
105
+ startTest(test);
106
+ test.runBare();
107
+ }
108
+ /**
109
+ * Gets the number of run tests.
110
+ */
111
+ public function runCount():int {
112
+ return fRunTests;
113
+ }
114
+ /**
115
+ * Checks whether the test run should stop
116
+ */
117
+ public function shouldStop():Boolean {
118
+ return fStop;
119
+ }
120
+ /**
121
+ * Informs the result that a test will be started.
122
+ */
123
+ public function startTest(test:Test):void {
124
+ var count:int = test.countTestCases();
125
+ fRunTests += count;
126
+
127
+ var len:uint = fListeners.length;
128
+ var item:TestListener;
129
+ for(var i:uint; i < len; i++) {
130
+ item = TestListener(fListeners[i]);
131
+ item.startTest(test);
132
+ }
133
+ }
134
+ /**
135
+ * Informs the result that a test was completed.
136
+ */
137
+ public function endTest(test:Test):void {
138
+ var len:uint = fListeners.length;
139
+ var item:TestListener;
140
+ for(var i:uint; i < len; i++) {
141
+ item = TestListener(fListeners[i]);
142
+ item.endTest(test);
143
+ }
144
+ }
145
+ /**
146
+ * Marks that the test run should stop.
147
+ */
148
+ public function stop():void {
149
+ fStop = true;
150
+ }
151
+ /**
152
+ * Returns whether the entire test was successful or not.
153
+ */
154
+ public function wasSuccessful():Boolean {
155
+ return failureCount() == 0 && errorCount() == 0;
156
+ }
157
+ }
158
+ }
@@ -0,0 +1,115 @@
1
+ package asunit.framework {
2
+ import flash.display.DisplayObjectContainer;
3
+ import flash.events.Event;
4
+ import asunit.util.Iterator;
5
+ import asunit.util.ArrayIterator;
6
+
7
+ /**
8
+ * A <code>TestSuite</code> is a <code>Composite</code> of Tests.
9
+ * It runs a collection of test cases. Here is an example using
10
+ * the dynamic test definition.
11
+ * <pre>
12
+ * TestSuite suite = new TestSuite();
13
+ * suite.addTest(new MathTest());
14
+ * suite.addTest(new OtherTest());
15
+ * </pre>
16
+ * @see Test
17
+ * @see TestCase
18
+ */
19
+ public class TestSuite extends TestCase implements Test {
20
+ private var fTests:Array = new Array();
21
+ private var testsCompleteCount:Number = 0;
22
+ private var iterator:ArrayIterator;
23
+ private var isRunning:Boolean;
24
+
25
+ public function TestSuite() {
26
+ super();
27
+ fTests = new Array();
28
+ }
29
+
30
+ protected override function setTestMethods(methodNodes:XMLList):void {
31
+ testMethods = new Array();
32
+ }
33
+
34
+ /**
35
+ * Adds a test to the suite.
36
+ */
37
+ public function addTest(test:Test):void {
38
+ fTests.push(test);
39
+ }
40
+
41
+ /**
42
+ * Counts the number of tests that will be run by this Suite.
43
+ */
44
+ public override function countTestCases():int {
45
+ var count:int;
46
+ for each(var test:TestCase in fTests) {
47
+ count = count + test.countTestCases();
48
+ }
49
+ return count;
50
+ }
51
+
52
+ /**
53
+ * Runs the tests and collects their result in a TestResult.
54
+ */
55
+ public override function run():void {
56
+ var result:TestResult = getResult();
57
+ var test:Test;
58
+ var itr:Iterator = getIterator();
59
+ while(itr.hasNext()) {
60
+ isRunning = true;
61
+ test = Test(itr.next());
62
+ test.setResult(result);
63
+ test.addEventListener(Event.COMPLETE, testCompleteHandler);
64
+ test.run();
65
+ if(!test.getIsComplete()) {
66
+ isRunning = false;
67
+ break;
68
+ }
69
+ }
70
+ }
71
+
72
+ private function getIterator():ArrayIterator {
73
+ if(iterator == null) {
74
+ iterator = new ArrayIterator(fTests);
75
+ }
76
+ return iterator;
77
+ }
78
+
79
+ private function testCompleteHandler(event:Event):void {
80
+ if(!isRunning) {
81
+ run();
82
+ }
83
+ if(++testsCompleteCount >= testCount()) {
84
+ dispatchEvent(new Event(Event.COMPLETE));
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Returns the number of tests in this suite
90
+ */
91
+ public function testCount():int {
92
+ return fTests.length;
93
+ }
94
+
95
+ public override function toString():String {
96
+ return getName();
97
+ }
98
+
99
+ public override function getIsComplete():Boolean {
100
+ for each(var test:TestCase in fTests) {
101
+ if(!test.getIsComplete()) {
102
+ return false;
103
+ }
104
+ }
105
+ return true;
106
+ }
107
+
108
+ public override function setContext(context:DisplayObjectContainer):void {
109
+ super.setContext(context);
110
+ for each(var test:Test in fTests) {
111
+ test.setContext(context);
112
+ }
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,15 @@
1
+ package asunit.runner {
2
+ import flash.display.Sprite;
3
+
4
+ /**
5
+ * Base class for all test runners.
6
+ * This class was born live on stage in Sardinia during XP2000.
7
+ */
8
+ public class BaseTestRunner extends Sprite {
9
+
10
+ // Filters stack frames from internal JUnit classes
11
+ public static function getFilteredTrace(stack:String):String {
12
+ return stack;
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,9 @@
1
+ package asunit.runner {
2
+
3
+ public interface TestSuiteLoader {
4
+ // throws ClassNotFoundException
5
+ function load(suiteClassName:String):Class;
6
+ // throws ClassNotFoundException
7
+ function reload(aClass:Class):Class;
8
+ }
9
+ }
@@ -0,0 +1,11 @@
1
+ package asunit.runner {
2
+
3
+ public class Version {
4
+ private static var version:String = "3.0";
5
+
6
+ public static function id():String {
7
+ return version.toString();
8
+ }
9
+
10
+ }
11
+ }