semillagen 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +27 -0
- data/bin/semillagen +65 -0
- data/default_templates/class/default/classTemplate.as.tpl +22 -0
- data/default_templates/class/default/info.semilla +8 -0
- data/default_templates/class/default/testClassTemplate.as.tpl +30 -0
- data/default_templates/project/default/Gemfile +5 -0
- data/default_templates/project/default/Gemfile.lock +24 -0
- data/default_templates/project/default/MagicBox.as3proj +96 -0
- data/default_templates/project/default/lib/flexunit4/FlexUnit1Lib.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8-javadoc.jar +0 -0
- data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8-sources.jar +0 -0
- data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8.jar +0 -0
- data/default_templates/project/default/lib/flexunit4/flexunit-4.1.0-8-as3_4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/flexunit-uilistener-4.1.0-8-4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/fluint-extensions-4.1.0-8-4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/hamcrest-as3-flex-1.1.3.swc +0 -0
- data/default_templates/project/default/rakefile.rb +128 -0
- data/default_templates/project/default/src/MagicBox.as +104 -0
- data/default_templates/project/default/src/PlainButton.as +72 -0
- data/default_templates/project/default/src/transforms/LeetTransform.as +40 -0
- data/default_templates/project/default/src/transforms/LowerCaseTransform.as +22 -0
- data/default_templates/project/default/src/transforms/ReverseTransform.as +22 -0
- data/default_templates/project/default/src/transforms/SplitTransform.as +22 -0
- data/default_templates/project/default/src/transforms/UpperCaseTransform.as +22 -0
- data/default_templates/project/default/test-src/TestRunner.template +66 -0
- data/default_templates/project/default/test-src/TextFieldListener.as +66 -0
- data/default_templates/project/default/test-src/listeners/SemillaCIListener.as +389 -0
- data/default_templates/project/default/test-src/listeners/TraceListener.as +79 -0
- data/default_templates/project/default/test-src/transforms/LeetTransformTest.as +45 -0
- data/default_templates/project/default/test-src/transforms/LowerCaseTransformTest.as +44 -0
- data/default_templates/project/default/test-src/transforms/ReverseTransformTest.as +31 -0
- data/default_templates/project/default/test-src/transforms/SplitTransformTest.as +37 -0
- data/default_templates/project/default/test-src/transforms/UpperCaseTransformTest.as +45 -0
- data/doc/SemillaGen/TemplateItem.html +340 -0
- data/doc/SemillaGen.html +916 -0
- data/doc/_index.html +112 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file_list.html +46 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +112 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +110 -0
- data/doc/top-level-namespace.html +105 -0
- data/lib/semillagen/generator.rb +248 -0
- data/lib/semillagen/utils.rb +40 -0
- data/lib/semillagen/version.rb +3 -0
- data/lib/semillagen.rb +33 -0
- data/rakefile.rb +39 -0
- data/semillagen.gemspec +76 -0
- metadata +136 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
package transforms
|
2
|
+
{
|
3
|
+
/**
|
4
|
+
* ...
|
5
|
+
* @author @@AUTHOR@@
|
6
|
+
*/
|
7
|
+
public class ReverseTransform
|
8
|
+
{
|
9
|
+
|
10
|
+
public function ReverseTransform()
|
11
|
+
{
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
public function run(data:String):String
|
16
|
+
{
|
17
|
+
return data.split("").reverse().join("");
|
18
|
+
}
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
package transforms
|
2
|
+
{
|
3
|
+
/**
|
4
|
+
* ...
|
5
|
+
* @author @@AUTHOR@@
|
6
|
+
*/
|
7
|
+
public class SplitTransform
|
8
|
+
{
|
9
|
+
|
10
|
+
public function SplitTransform()
|
11
|
+
{
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
public function run(data:String, separator:String = "."):String
|
16
|
+
{
|
17
|
+
return data.split("").join(separator);
|
18
|
+
}
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
package transforms
|
2
|
+
{
|
3
|
+
/**
|
4
|
+
* ...
|
5
|
+
* @author @@AUTHOR@@
|
6
|
+
*/
|
7
|
+
public class UpperCaseTransform
|
8
|
+
{
|
9
|
+
|
10
|
+
public function UpperCaseTransform()
|
11
|
+
{
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
public function run(data:String):String
|
16
|
+
{
|
17
|
+
return data.toUpperCase();
|
18
|
+
}
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
package
|
2
|
+
{
|
3
|
+
import flash.display.Sprite;
|
4
|
+
import flash.events.Event;
|
5
|
+
import flash.text.TextField;
|
6
|
+
import flash.text.TextFieldAutoSize;
|
7
|
+
import listeners.SemillaCIListener;
|
8
|
+
import org.flexunit.runner.FlexUnitCore;
|
9
|
+
import org.flexunit.runner.Request;
|
10
|
+
import org.flexunit.runner.notification.async.AsyncListenerWatcher;
|
11
|
+
|
12
|
+
|
13
|
+
@@IMPORTS@@
|
14
|
+
|
15
|
+
|
16
|
+
/**
|
17
|
+
* IMPORTANT: This file was generated, any edits to this file will be
|
18
|
+
* overwritten the next time the rake test is executed.
|
19
|
+
*/
|
20
|
+
public class TestRunner extends Sprite
|
21
|
+
{
|
22
|
+
private var txtoutput:TextField;
|
23
|
+
|
24
|
+
public var classes:Array;
|
25
|
+
|
26
|
+
public function TestRunner()
|
27
|
+
{
|
28
|
+
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
|
29
|
+
}
|
30
|
+
|
31
|
+
private function setupClasses():void
|
32
|
+
{
|
33
|
+
classes = [
|
34
|
+
@@CLASSES@@
|
35
|
+
];
|
36
|
+
}
|
37
|
+
|
38
|
+
private function addedToStageHandler(e:Event):void
|
39
|
+
{
|
40
|
+
removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
|
41
|
+
|
42
|
+
/*---- Run the unit tests ----*/
|
43
|
+
setupClasses();
|
44
|
+
runTests();
|
45
|
+
/*---- Finished ----*/
|
46
|
+
}
|
47
|
+
|
48
|
+
public function runTests() : void {
|
49
|
+
|
50
|
+
txtoutput = new TextField();
|
51
|
+
txtoutput.autoSize = TextFieldAutoSize.LEFT;
|
52
|
+
addChild(txtoutput);
|
53
|
+
|
54
|
+
var core : FlexUnitCore = new FlexUnitCore();
|
55
|
+
var semillaListener:SemillaCIListener = new SemillaCIListener(@@PORT@@);
|
56
|
+
semillaListener.debugTxt = txtoutput;
|
57
|
+
core.addListener(semillaListener);
|
58
|
+
|
59
|
+
var request:Request = Request.qualifyClasses.apply(null, classes);
|
60
|
+
core.run(request);
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
package
|
2
|
+
{
|
3
|
+
import flash.text.TextField;
|
4
|
+
import org.flexunit.internals.TraceListener;
|
5
|
+
import org.flexunit.runner.notification.Failure;
|
6
|
+
import org.flexunit.runner.Result;
|
7
|
+
|
8
|
+
/**
|
9
|
+
* ...
|
10
|
+
* @author Victor Rosales
|
11
|
+
*/
|
12
|
+
public class TextFieldListener extends TraceListener
|
13
|
+
{
|
14
|
+
private var textField:TextField;
|
15
|
+
|
16
|
+
public function TextFieldListener(textField:TextField)
|
17
|
+
{
|
18
|
+
this.textField = textField;
|
19
|
+
log("TextfieldListener");
|
20
|
+
}
|
21
|
+
|
22
|
+
override protected function printHeader(runTime:Number):void
|
23
|
+
{
|
24
|
+
log( "Time: " + elapsedTimeAsString(runTime) );
|
25
|
+
}
|
26
|
+
|
27
|
+
override protected function printFooter(result:Result):void
|
28
|
+
{
|
29
|
+
//Determine if the result was a success
|
30
|
+
if (result.successful ) {
|
31
|
+
log( "OK (" + result.runCount + " test " + (result.runCount == 1 ? "" : "s") + ")" );
|
32
|
+
} else {
|
33
|
+
log( "FAILURES!!! Tests run: " + result.runCount + ", " + result.failureCount + " Failures:" );
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
override protected function printFailures(result:Result):void
|
38
|
+
{
|
39
|
+
var failures:Array = result.failures;
|
40
|
+
//Determine if there are any failures to print
|
41
|
+
if (failures.length == 0)
|
42
|
+
return;
|
43
|
+
if (failures.length == 1)
|
44
|
+
log( "There was " + failures.length + " failure:" );
|
45
|
+
else
|
46
|
+
log("There were " + failures.length + " failures:" );
|
47
|
+
|
48
|
+
//Print each failure
|
49
|
+
for ( var i:int=0; i<failures.length; i++ ) {
|
50
|
+
printFailure( failures[ i ], String( i+1 ) );
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
override protected function printFailure(failure:Failure, prefix:String):void
|
55
|
+
{
|
56
|
+
log( prefix + " " + failure.testHeader + " " + failure.stackTrace );
|
57
|
+
}
|
58
|
+
|
59
|
+
protected function log(...args):void
|
60
|
+
{
|
61
|
+
textField.appendText(args.join(",") + "\n");
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
65
|
+
|
66
|
+
}
|
@@ -0,0 +1,389 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2009 Digital Primates IT Consulting Group
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person
|
5
|
+
* obtaining a copy of this software and associated documentation
|
6
|
+
* files (the "Software"), to deal in the Software without
|
7
|
+
* restriction, including without limitation the rights to use,
|
8
|
+
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
* copies of the Software, and to permit persons to whom the
|
10
|
+
* Software is furnished to do so, subject to the following
|
11
|
+
* conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be
|
14
|
+
* included in all copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
18
|
+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
20
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
21
|
+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
22
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
23
|
+
* OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
*
|
25
|
+
* @author Jeff Tapper
|
26
|
+
* @version
|
27
|
+
**/
|
28
|
+
|
29
|
+
package listeners
|
30
|
+
{
|
31
|
+
import flash.events.DataEvent;
|
32
|
+
import flash.events.Event;
|
33
|
+
import flash.events.EventDispatcher;
|
34
|
+
import flash.events.IOErrorEvent;
|
35
|
+
import flash.events.SecurityErrorEvent;
|
36
|
+
import flash.events.TimerEvent;
|
37
|
+
import flash.net.XMLSocket;
|
38
|
+
import flash.text.TextField;
|
39
|
+
import flash.utils.Timer;
|
40
|
+
|
41
|
+
import org.flexunit.listeners.closer.ApplicationCloser;
|
42
|
+
import org.flexunit.listeners.closer.StandAloneFlashPlayerCloser;
|
43
|
+
import org.flexunit.reporting.FailureFormatter;
|
44
|
+
import org.flexunit.runner.Descriptor;
|
45
|
+
import org.flexunit.runner.IDescription;
|
46
|
+
import org.flexunit.runner.Result;
|
47
|
+
import org.flexunit.runner.notification.Failure;
|
48
|
+
import org.flexunit.runner.notification.IAsyncStartupRunListener;
|
49
|
+
import org.flexunit.runner.notification.ITemporalRunListener;
|
50
|
+
import org.flexunit.runner.notification.async.AsyncListenerWatcher;
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
public class SemillaCIListener extends EventDispatcher implements IAsyncStartupRunListener, ITemporalRunListener
|
55
|
+
{
|
56
|
+
protected static const DEFAULT_PORT:uint = 1024;
|
57
|
+
|
58
|
+
protected static const DEFAULT_SERVER:String = "127.0.0.1";
|
59
|
+
|
60
|
+
private static const SUCCESS:String = "success";
|
61
|
+
|
62
|
+
private static const ERROR:String = "error";
|
63
|
+
|
64
|
+
private static const FAILURE:String = "failure";
|
65
|
+
|
66
|
+
private static const IGNORE:String = "ignore";
|
67
|
+
|
68
|
+
private var successes:Array = new Array();
|
69
|
+
|
70
|
+
private var ignores:Array = new Array();
|
71
|
+
|
72
|
+
private var _ready:Boolean = false;
|
73
|
+
|
74
|
+
private static const END_OF_TEST_ACK:String = "<endOfTestRunAck/>";
|
75
|
+
|
76
|
+
private static const END_OF_TEST_RUN:String = "<endOfTestRun/>";
|
77
|
+
|
78
|
+
private static const START_OF_TEST_RUN_ACK:String = "<startOfTestRunAck/>";
|
79
|
+
|
80
|
+
private var socket:XMLSocket;
|
81
|
+
|
82
|
+
public var debugTxt:TextField;
|
83
|
+
|
84
|
+
[Inspectable]
|
85
|
+
public var port:uint;
|
86
|
+
|
87
|
+
[Inspectable]
|
88
|
+
public var server:String; //this is local host. same machine
|
89
|
+
|
90
|
+
public var closer:ApplicationCloser;
|
91
|
+
|
92
|
+
private var lastFailedTest:IDescription;
|
93
|
+
|
94
|
+
private var timeOut:Timer;
|
95
|
+
|
96
|
+
private var lastTestTime:Number = 0;
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
public function SemillaCIListener(port:uint = DEFAULT_PORT, server:String = DEFAULT_SERVER)
|
101
|
+
{
|
102
|
+
this.port = port;
|
103
|
+
this.server = server;
|
104
|
+
this.closer = new StandAloneFlashPlayerCloser(); //default application closer
|
105
|
+
|
106
|
+
socket = new XMLSocket();
|
107
|
+
socket.addEventListener(DataEvent.DATA, dataHandler);
|
108
|
+
socket.addEventListener(Event.CONNECT, handleConnect);
|
109
|
+
socket.addEventListener(IOErrorEvent.IO_ERROR, ioerrorHandler);
|
110
|
+
socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
|
111
|
+
socket.addEventListener(Event.CLOSE, errorHandler);
|
112
|
+
|
113
|
+
timeOut = new Timer(2000, 1);
|
114
|
+
timeOut.addEventListener(TimerEvent.TIMER_COMPLETE, declareBroken, false, 0, true);
|
115
|
+
timeOut.start();
|
116
|
+
|
117
|
+
try
|
118
|
+
{
|
119
|
+
socket.connect(server, port);
|
120
|
+
timeOut.stop();
|
121
|
+
}
|
122
|
+
catch (e:Error)
|
123
|
+
{
|
124
|
+
//This needs to be more than a trace
|
125
|
+
trace(e.message);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
private function securityErrorHandler(e:SecurityErrorEvent):void
|
130
|
+
{
|
131
|
+
log(e.text);
|
132
|
+
errorHandler(e);
|
133
|
+
}
|
134
|
+
|
135
|
+
private function ioerrorHandler(e:IOErrorEvent):void
|
136
|
+
{
|
137
|
+
log("IOError port:" + port + " server:" + server);
|
138
|
+
log(e.text);
|
139
|
+
errorHandler(e);
|
140
|
+
}
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
private function declareBroken(event:TimerEvent):void
|
145
|
+
{
|
146
|
+
|
147
|
+
errorHandler(new Event("broken"));
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
[Bindable(event="listenerReady")]
|
153
|
+
public function get ready():Boolean
|
154
|
+
{
|
155
|
+
return _ready;
|
156
|
+
}
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
private function setStatusReady():void
|
161
|
+
{
|
162
|
+
_ready = true;
|
163
|
+
dispatchEvent(new Event(AsyncListenerWatcher.LISTENER_READY));
|
164
|
+
}
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
private function getTestCount(description:IDescription):int
|
169
|
+
{
|
170
|
+
return description.testCount;
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
public function testTimed(description:IDescription, runTime:Number):void
|
176
|
+
{
|
177
|
+
if (!runTime || isNaN(runTime))
|
178
|
+
{
|
179
|
+
lastTestTime = 0;
|
180
|
+
}
|
181
|
+
else
|
182
|
+
{
|
183
|
+
lastTestTime = runTime;
|
184
|
+
}
|
185
|
+
|
186
|
+
//trace( description.displayName + " took " + runTime + " ms " );
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
public function testRunStarted(description:IDescription):void
|
192
|
+
{
|
193
|
+
//Since description tells us nothing about failure, error, and skip counts, this is
|
194
|
+
//computed by the Ant task as the process executes and no work is needed to signify
|
195
|
+
//the start of a test run.
|
196
|
+
}
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
public function testRunFinished(result:Result):void
|
201
|
+
{
|
202
|
+
sendResults(END_OF_TEST_RUN);
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
public function testStarted(description:IDescription):void
|
208
|
+
{
|
209
|
+
// called before each test
|
210
|
+
}
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
public function testFinished(description:IDescription):void
|
215
|
+
{
|
216
|
+
// called after each test
|
217
|
+
if (!lastFailedTest || description.displayName != lastFailedTest.displayName)
|
218
|
+
{
|
219
|
+
var desc:Descriptor = getDescriptorFromDescription(description);
|
220
|
+
sendResults("<testcase classname=\"" + desc.suite + "\" name=\"" + desc.method + "\" time=\"" + lastTestTime + "\" status=\"" + SUCCESS + "\" />");
|
221
|
+
}
|
222
|
+
}
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
public function testAssumptionFailure(failure:Failure):void
|
227
|
+
{
|
228
|
+
// called on assumptionFail
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
public function testIgnored(description:IDescription):void
|
234
|
+
{
|
235
|
+
// called on ignored test if we want to send ignore to ant.
|
236
|
+
var descriptor:Descriptor = getDescriptorFromDescription(description);
|
237
|
+
|
238
|
+
var xml:String = "<testcase classname=\"" + descriptor.suite + "\" name=\"" + descriptor.method + "\" time=\"" + lastTestTime + "\" status=\"" + IGNORE + "\">" + "<skipped />" + "</testcase>";
|
239
|
+
|
240
|
+
sendResults(xml);
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
public function testFailure(failure:Failure):void
|
246
|
+
{
|
247
|
+
// called on a test failure
|
248
|
+
lastFailedTest = failure.description;
|
249
|
+
var descriptor:Descriptor = getDescriptorFromDescription(failure.description);
|
250
|
+
var type:String = failure.description.displayName
|
251
|
+
var message:String = failure.message;
|
252
|
+
var stackTrace:String = failure.stackTrace;
|
253
|
+
var methodName:String = descriptor.method;
|
254
|
+
|
255
|
+
if (stackTrace != null)
|
256
|
+
stackTrace = stackTrace.toString();
|
257
|
+
|
258
|
+
stackTrace = FailureFormatter.xmlEscapeMessage(stackTrace);
|
259
|
+
message = FailureFormatter.xmlEscapeMessage(message);
|
260
|
+
|
261
|
+
var xml:String = null;
|
262
|
+
|
263
|
+
if (FailureFormatter.isError(failure.exception))
|
264
|
+
{
|
265
|
+
xml = "<testcase classname=\"" + descriptor.suite + "\" name=\"" + descriptor.method + "\" time=\"" + lastTestTime + "\" status=\"" + ERROR + "\">" + "<error message=\"" + message + "\" type=\"" + type + "\" >" + "<![CDATA[" + stackTrace + "]]>" + "</error>" + "</testcase>";
|
266
|
+
}
|
267
|
+
else
|
268
|
+
{
|
269
|
+
xml = "<testcase classname=\"" + descriptor.suite + "\" name=\"" + descriptor.method + "\" time=\"" + lastTestTime + "\" status=\"" + FAILURE + "\">" + "<failure message=\"" + message + "\" type=\"" + type + "\" >" + "<![CDATA[" + stackTrace + "]]>" + "</failure>" + "</testcase>";
|
270
|
+
}
|
271
|
+
|
272
|
+
sendResults(xml);
|
273
|
+
}
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
/*
|
278
|
+
* Internal methods
|
279
|
+
*/
|
280
|
+
private function getDescriptorFromDescription(description:IDescription):Descriptor
|
281
|
+
{
|
282
|
+
// reads relavent data from descriptor
|
283
|
+
/**
|
284
|
+
* JAdkins - 7/27/07 - FXU-53 - Listener was returning a null value for the test class
|
285
|
+
* causing no data to be returned. If length of array is greater than 1, then class is
|
286
|
+
* not in the default package. If array length is 1, then test class is default package
|
287
|
+
* and formats accordingly.
|
288
|
+
**/
|
289
|
+
var descriptor:Descriptor = new Descriptor();
|
290
|
+
var descriptionArray:Array = description.displayName.split("::");
|
291
|
+
var classMethod:String;
|
292
|
+
|
293
|
+
if (descriptionArray.length > 1)
|
294
|
+
{
|
295
|
+
descriptor.path = descriptionArray[0];
|
296
|
+
classMethod = descriptionArray[1];
|
297
|
+
}
|
298
|
+
else
|
299
|
+
{
|
300
|
+
classMethod = descriptionArray[0];
|
301
|
+
}
|
302
|
+
var classMethodArray:Array = classMethod.split(".");
|
303
|
+
descriptor.suite = (descriptor.path == "") ? classMethodArray[0] : descriptor.path + "::" + classMethodArray[0];
|
304
|
+
descriptor.method = classMethodArray[1];
|
305
|
+
return descriptor;
|
306
|
+
}
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
protected function sendResults(msg:String):void
|
311
|
+
{
|
312
|
+
if (socket.connected)
|
313
|
+
{
|
314
|
+
socket.send(msg);
|
315
|
+
}
|
316
|
+
|
317
|
+
trace(msg);
|
318
|
+
}
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
private function handleConnect(event:Event):void
|
323
|
+
{
|
324
|
+
//This is a good start, but we are no longer considering this a valid
|
325
|
+
//time to begin sending results
|
326
|
+
//We are going to wait until we get some data first
|
327
|
+
//_ready = true;
|
328
|
+
//dispatchEvent( new Event( AsyncListenerWatcher.LISTENER_READY ) );
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
private function errorHandler(event:Event):void
|
334
|
+
{
|
335
|
+
log(event.type);
|
336
|
+
|
337
|
+
if (!ready)
|
338
|
+
{
|
339
|
+
//If we are not yet ready and received this, just inform the core so it can move on
|
340
|
+
dispatchEvent(new Event(AsyncListenerWatcher.LISTENER_FAILED));
|
341
|
+
}
|
342
|
+
else
|
343
|
+
{
|
344
|
+
//If on the other hand we were ready once, then the core is counting on us... so, if something goes
|
345
|
+
//wrong now, we are likely hung up. For now we are simply going to bail out of this process
|
346
|
+
exit();
|
347
|
+
}
|
348
|
+
}
|
349
|
+
|
350
|
+
private function log(msg:String):void
|
351
|
+
{
|
352
|
+
trace(msg);
|
353
|
+
if (debugTxt != null)
|
354
|
+
{
|
355
|
+
debugTxt.appendText(msg + "\n");
|
356
|
+
}
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
private function dataHandler(event:DataEvent):void
|
362
|
+
{
|
363
|
+
var data:String = event.data;
|
364
|
+
|
365
|
+
// If we received an acknowledgement on startup, the java server is read and we can start sending.
|
366
|
+
if (data == START_OF_TEST_RUN_ACK)
|
367
|
+
{
|
368
|
+
setStatusReady();
|
369
|
+
}
|
370
|
+
else if (data == END_OF_TEST_ACK)
|
371
|
+
{
|
372
|
+
// If we received an acknowledgement finish-up.
|
373
|
+
// Close the socket.
|
374
|
+
socket.close();
|
375
|
+
exit();
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Exit the test runner by calling the ApplicationCloser.
|
383
|
+
*/
|
384
|
+
protected function exit():void
|
385
|
+
{
|
386
|
+
this.closer.close();
|
387
|
+
}
|
388
|
+
}
|
389
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
package listeners
|
2
|
+
{
|
3
|
+
import org.flexunit.runner.notification.Failure;
|
4
|
+
import org.flexunit.runner.Result;
|
5
|
+
import flash.events.EventDispatcher;
|
6
|
+
import org.flexunit.runner.IDescription;
|
7
|
+
import org.flexunit.runner.notification.IAsyncStartupRunListener;
|
8
|
+
import org.flexunit.runner.notification.ITemporalRunListener;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* ...
|
12
|
+
* @author Victor Rosales
|
13
|
+
*/
|
14
|
+
public class TraceListener extends EventDispatcher implements IAsyncStartupRunListener, ITemporalRunListener
|
15
|
+
{
|
16
|
+
|
17
|
+
public function TraceListener()
|
18
|
+
{
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
private function log(... args):void
|
23
|
+
{
|
24
|
+
trace("[FlexUnit] " + args.join(","));
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
/* INTERFACE org.flexunit.runner.notification.ITemporalRunListener */
|
29
|
+
|
30
|
+
public function testTimed(description:IDescription, runTime:Number):void
|
31
|
+
{
|
32
|
+
log("Test timed", description.displayName, runTime);
|
33
|
+
}
|
34
|
+
|
35
|
+
public function testRunStarted(description:IDescription):void
|
36
|
+
{
|
37
|
+
log("Test run started", description.displayName);
|
38
|
+
}
|
39
|
+
|
40
|
+
public function testRunFinished(result:Result):void
|
41
|
+
{
|
42
|
+
log("Test run finished", result);
|
43
|
+
}
|
44
|
+
|
45
|
+
public function testStarted(description:IDescription):void
|
46
|
+
{
|
47
|
+
log("Test started", description.displayName);
|
48
|
+
}
|
49
|
+
|
50
|
+
public function testFinished(description:IDescription):void
|
51
|
+
{
|
52
|
+
log("Test finished", description.displayName);
|
53
|
+
}
|
54
|
+
|
55
|
+
public function testFailure(failure:Failure):void
|
56
|
+
{
|
57
|
+
log("Test failed", failure.toString());
|
58
|
+
}
|
59
|
+
|
60
|
+
public function testAssumptionFailure(failure:Failure):void
|
61
|
+
{
|
62
|
+
log("Test assumption failure", failure.toString());
|
63
|
+
}
|
64
|
+
|
65
|
+
public function testIgnored(description:IDescription):void
|
66
|
+
{
|
67
|
+
log("Test ignored", description.displayName);
|
68
|
+
}
|
69
|
+
|
70
|
+
/* INTERFACE org.flexunit.runner.notification.IAsyncStartupRunListener */
|
71
|
+
|
72
|
+
public function get ready():Boolean
|
73
|
+
{
|
74
|
+
return true;
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
package transforms
|
2
|
+
{
|
3
|
+
import org.flexunit.Assert;
|
4
|
+
import transforms.LeetTransform;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* ...
|
8
|
+
* @author @@AUTHOR@@
|
9
|
+
*/
|
10
|
+
public class LeetTransformTest
|
11
|
+
{
|
12
|
+
|
13
|
+
[Test]
|
14
|
+
public function leetTest1():void
|
15
|
+
{
|
16
|
+
var t:LeetTransform = new LeetTransform();
|
17
|
+
Assert.assertEquals("1337", t.run("leet"));
|
18
|
+
}
|
19
|
+
|
20
|
+
[Test]
|
21
|
+
public function leetTest2():void
|
22
|
+
{
|
23
|
+
var t:LeetTransform = new LeetTransform();
|
24
|
+
Assert.assertEquals("h3110", t.run("hello"));
|
25
|
+
}
|
26
|
+
|
27
|
+
[Test]
|
28
|
+
public function leetTest3():void
|
29
|
+
{
|
30
|
+
var t:LeetTransform = new LeetTransform();
|
31
|
+
Assert.assertEquals("n00b", t.run("noob"));
|
32
|
+
}
|
33
|
+
|
34
|
+
[Test]
|
35
|
+
public function leetTest4():void
|
36
|
+
{
|
37
|
+
var t:LeetTransform = new LeetTransform();
|
38
|
+
Assert.assertEquals("haxor", t.run("hacker"));
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|