asproject 0.1.92 → 0.1.118
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/lib/asclass_arguments.rb +1 -1
- data/lib/asproject.rb +3 -1
- data/lib/asproject/version.rb +1 -1
- data/lib/asproject_arguments.rb +5 -5
- data/lib/path_finder.rb +17 -7
- data/lib/tasks/asunit.rb +8 -0
- data/lib/tasks/flash_log.rb +2 -1
- data/lib/tasks/flash_player.rb +10 -6
- data/lib/tasks/mxmlc.rb +13 -2
- data/lib/tasks/remote_file_loader.rb +144 -0
- data/lib/tasks/remote_file_task.rb +2 -128
- data/lib/tasks/remote_library_task.rb +75 -0
- data/templates/asclass/as2/Class.as +1 -1
- data/templates/asproject/as2/{art → assets}/.crap_file +0 -0
- data/templates/asproject/as2/project/rakefile.rb +3 -2
- data/templates/asproject/as3/{art → assets}/.crap_file +0 -0
- data/templates/asproject/as3/project/rakefile.rb +3 -3
- data/templates/asproject/fdt/project/.as2_classpath +1 -1
- metadata +9 -129
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +0 -70
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +0 -182
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +0 -84
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +0 -111
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +0 -26
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +0 -81
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +0 -35
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +0 -34
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +0 -43
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +0 -10
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +0 -169
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +0 -29
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +0 -27
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +0 -19
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +0 -408
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +0 -27
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +0 -68
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +0 -3
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +0 -191
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +0 -31
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +0 -15
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +0 -15
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +0 -41
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +0 -19
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +0 -22
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +0 -325
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +0 -24
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +0 -32
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +0 -7
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +0 -29
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +0 -89
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +0 -42
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +0 -47
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +0 -61
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +0 -58
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +0 -11
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +0 -30
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +0 -13
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -7
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +0 -376
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +0 -15
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +0 -59
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +0 -13
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +0 -11
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +0 -278
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +0 -23
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +0 -29
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +0 -38
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +0 -168
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +0 -102
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -101
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +0 -8
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -254
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +0 -41
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +0 -17
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +0 -24
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +0 -52
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +0 -5
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +0 -10
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +0 -271
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +0 -52
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +0 -71
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +0 -15
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +0 -354
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +0 -73
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +0 -47
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +0 -22
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +0 -158
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +0 -115
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +0 -15
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +0 -9
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +0 -11
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +0 -19
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +0 -55
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +0 -245
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +0 -121
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +0 -26
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +0 -9
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +0 -30
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
import com.asunit.controls.shapes.*;
|
3
|
-
|
4
|
-
class com.asunit.controls.shapes.Rectangle extends MovieClip {
|
5
|
-
private var strokeSize:Number = 0;
|
6
|
-
private var bgColor:Number = 0xEEEEEE;
|
7
|
-
private var borderColor:Number = 0x666666;
|
8
|
-
public var width:Number;
|
9
|
-
public var height:Number;
|
10
|
-
|
11
|
-
public function Rectangle() {
|
12
|
-
}
|
13
|
-
|
14
|
-
public function onLoad():Void {
|
15
|
-
refreshLayout();
|
16
|
-
}
|
17
|
-
|
18
|
-
public function refreshLayout():Void {
|
19
|
-
clear();
|
20
|
-
lineStyle(strokeSize, borderColor, 100);
|
21
|
-
beginFill(bgColor, 100);
|
22
|
-
moveTo(0, 0);
|
23
|
-
lineTo(width, 0);
|
24
|
-
lineTo(width, height);
|
25
|
-
lineTo(0, height);
|
26
|
-
lineTo(0, 0);
|
27
|
-
}
|
28
|
-
|
29
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
|
2
|
-
import com.asunit.controls.shapes.*;
|
3
|
-
|
4
|
-
class com.asunit.controls.shapes.Triangle extends MovieClip {
|
5
|
-
private var strokeSize:Number = 0;
|
6
|
-
private var bgColor:Number = 0xCCCCCC;
|
7
|
-
private var borderColor:Number = 0x666666;
|
8
|
-
private var width:Number;
|
9
|
-
private var height:Number;
|
10
|
-
|
11
|
-
public function Triangle() {
|
12
|
-
}
|
13
|
-
|
14
|
-
public function onLoad():Void {
|
15
|
-
refreshLayout();
|
16
|
-
}
|
17
|
-
|
18
|
-
public function refreshLayout():Void {
|
19
|
-
clear();
|
20
|
-
lineStyle(strokeSize, borderColor, 100);
|
21
|
-
beginFill(bgColor, 100);
|
22
|
-
moveTo(0, 0);
|
23
|
-
lineTo(width, 0);
|
24
|
-
lineTo(width/2, height);
|
25
|
-
lineTo(0,0);
|
26
|
-
}
|
27
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
import com.asunit.framework.*;
|
3
|
-
|
4
|
-
class com.asunit.framework.AsUnit extends TestSuite {
|
5
|
-
private var className:String = "asunit.framework.AsUnit";
|
6
|
-
private var output:Sys;
|
7
|
-
private var testCase:TestCase;
|
8
|
-
private var testSuite:TestSuite;
|
9
|
-
|
10
|
-
public function AsUnit() {
|
11
|
-
init();
|
12
|
-
}
|
13
|
-
|
14
|
-
private function init():Void {
|
15
|
-
testSuite = new TestSuite();
|
16
|
-
testCase = new TestCase();
|
17
|
-
}
|
18
|
-
|
19
|
-
}
|
@@ -1,408 +0,0 @@
|
|
1
|
-
|
2
|
-
import com.asunit.framework.*;
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Provides assert methods and other utility methods which are inherited by
|
6
|
-
* the {@link TestCase} subclass. Since all user-defined test cases should
|
7
|
-
* extend {@link TestCase} you should never have to use this class
|
8
|
-
* directly.
|
9
|
-
*
|
10
|
-
* @see TestCase
|
11
|
-
*/
|
12
|
-
class com.asunit.framework.Assert {
|
13
|
-
private static var testRunner:TestRunner;
|
14
|
-
private static var defaultClassName:String = "[ClassName Unknown]";
|
15
|
-
private static var currentClassName:String;
|
16
|
-
private static var currentMethod:String;
|
17
|
-
private static var lastDepth:Number = 1;
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Sets the name of the currently running {@link TestCase}. This method
|
21
|
-
* is intended for use by the AsUnit framework and should never have
|
22
|
-
* to be called directly.
|
23
|
-
*
|
24
|
-
* @param cName
|
25
|
-
* A fully qualified class name.
|
26
|
-
* Ex. <code>"com.mycompany.EmployeeTest"</code>.
|
27
|
-
*/
|
28
|
-
public static function setCurrentClassName(cName:String) {
|
29
|
-
if(cName == Assert.defaultClassName) {
|
30
|
-
trace(">> Any class that extends Assert should have an instance member named [className] because there is no reflection in AS 2.0");
|
31
|
-
trace(">> This member should be defined as follows: private var className:String = [com.package.package.ClassName];");
|
32
|
-
}
|
33
|
-
else currentClassName = cName;
|
34
|
-
}
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Returns the next available depth for attaching a MovieClip.
|
38
|
-
*
|
39
|
-
* @return
|
40
|
-
* Number of next available depth.
|
41
|
-
*/
|
42
|
-
private static function nextDepth():Number {
|
43
|
-
return Assert.lastDepth++;
|
44
|
-
}
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Returns the name of the currently running {@link TestCase}. This
|
48
|
-
* method is intended for use by the AsUnit framework and should never
|
49
|
-
* have to be called directly.
|
50
|
-
*
|
51
|
-
* @return
|
52
|
-
* A fully qualified class name.
|
53
|
-
* Ex. <code>"com.mycompany.EmployeeTest"</code>.
|
54
|
-
*/
|
55
|
-
public static function getCurrentClassName():String {
|
56
|
-
return currentClassName;
|
57
|
-
}
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Sets the name of the currently running test method. This method is
|
61
|
-
* intended for use by the AsUnit framework and should never
|
62
|
-
* have to be called directly.
|
63
|
-
*
|
64
|
-
* @param meth
|
65
|
-
* A method name as a string. Ex. <code>"testGetValue"</code>.
|
66
|
-
*/
|
67
|
-
public static function setCurrentMethod(meth:String) {
|
68
|
-
currentMethod = meth;
|
69
|
-
}
|
70
|
-
|
71
|
-
/**
|
72
|
-
* Returns the name of the currently running test method. This
|
73
|
-
* method is intended for use by the AsUnit framework and should never
|
74
|
-
* have to be called directly.
|
75
|
-
*
|
76
|
-
* @return
|
77
|
-
* A method name. Ex. <code>"testGetValue"</code>.
|
78
|
-
*/
|
79
|
-
public static function getCurrentMethod():String {
|
80
|
-
return currentMethod;
|
81
|
-
}
|
82
|
-
|
83
|
-
/**
|
84
|
-
* Appends a test result to the {@link TestRunner} which manages test
|
85
|
-
* result output. This method is intended for use by the AsUnit
|
86
|
-
* framework and should never have to be called directly.
|
87
|
-
*
|
88
|
-
* @param msg
|
89
|
-
* The message associated with the assertion.
|
90
|
-
* @param assertType
|
91
|
-
* The assertion type.
|
92
|
-
* @param passFail
|
93
|
-
* Indicates whether the test passed (<code>true</code>) or
|
94
|
-
* failed (<code>false</code>).
|
95
|
-
*
|
96
|
-
*/
|
97
|
-
public static function addTestResult(msg:String, assertType:String, passFail:Boolean) {
|
98
|
-
var list:TestRunner = getTestRunner();
|
99
|
-
var res:Test;
|
100
|
-
if(passFail) {
|
101
|
-
res = new TestResult(getCurrentClassName(), getCurrentMethod(), msg, assertType);
|
102
|
-
} else {
|
103
|
-
res = new TestFailure(getCurrentClassName(), getCurrentMethod(), msg, assertType);
|
104
|
-
}
|
105
|
-
list.push(Object(res));
|
106
|
-
}
|
107
|
-
|
108
|
-
/**
|
109
|
-
* Returns a reference to the {@link TestRunner} instance which manages
|
110
|
-
* the output of test results. This method is intended for use by the
|
111
|
-
* AsUnit framework and should never have to be called directly.
|
112
|
-
*/
|
113
|
-
private static function getTestRunner():TestRunner {
|
114
|
-
if(testRunner == null) {
|
115
|
-
testRunner = new TestRunner();
|
116
|
-
}
|
117
|
-
return testRunner;
|
118
|
-
}
|
119
|
-
|
120
|
-
/**
|
121
|
-
* Returns the number of {@link TestCases} that have completed.
|
122
|
-
*/
|
123
|
-
public static function countTestCases():Number {
|
124
|
-
return testRunner.length;
|
125
|
-
}
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Asserts that two objects are equal. If either of the
|
129
|
-
* objects provides an <code>equals()</code> method it will be used to
|
130
|
-
* determine equality. Otherwise, equality will be evaluated using the
|
131
|
-
* strict equality operator (<code>===</code>).<br />
|
132
|
-
* <br />
|
133
|
-
* The method below tests the <code>getFullName()</code> method of the
|
134
|
-
* <code>Person</code> class to make sure that the formatting of its
|
135
|
-
* return value is correct.<br />
|
136
|
-
*
|
137
|
-
* <pre>
|
138
|
-
* public function testGetFullName():Void {
|
139
|
-
* var person:Person = new Person("John", "Alan", "Smith");
|
140
|
-
* assertEquals("full name should be formatted: [first] [middleInitial]. [last]",
|
141
|
-
* "John A. Smith",
|
142
|
-
* person.getFullName());
|
143
|
-
* }
|
144
|
-
* </pre>
|
145
|
-
*
|
146
|
-
* @param msg
|
147
|
-
* Optional; Message to display should the test fail. It is
|
148
|
-
* recommended that this message describe what is asserted to be
|
149
|
-
* true rather than describing what went wrong.
|
150
|
-
* @param assertion1
|
151
|
-
* First object to use in evaluation.
|
152
|
-
* @param assertion2
|
153
|
-
* Second object to use in evaluation.
|
154
|
-
*/
|
155
|
-
public static function assertEquals(msg:Object, assertion1:Object, assertion2:Object):Void {
|
156
|
-
if(arguments.length == 2) {
|
157
|
-
assertion2 = assertion1;
|
158
|
-
assertion1 = msg;
|
159
|
-
msg = "";
|
160
|
-
}
|
161
|
-
if(assertion1["equals"] instanceof Function) {
|
162
|
-
addTestResult(String(msg), "assertEquals", assertion1["equals"](assertion2));
|
163
|
-
} else if(assertion2["equals"] != undefined) {
|
164
|
-
addTestResult(String(msg), "assertEquals", assertion2["equals"](assertion1));
|
165
|
-
} else {
|
166
|
-
addTestResult(String(msg), "assertEquals", assertion1 === assertion2);
|
167
|
-
}
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
/**
|
172
|
-
* Asserts that a value is <code>null</code>.<br />
|
173
|
-
* <br />
|
174
|
-
* The method below tests to confirm that the parameter passed to the
|
175
|
-
* <code>getProductBySku</code> method of the
|
176
|
-
* <code>ProductCatalog</code> is treated as case sensitive.<br />
|
177
|
-
*
|
178
|
-
* <pre>
|
179
|
-
* public function testGetProductBySku():Void {
|
180
|
-
* // Set up a fixture to test against.
|
181
|
-
* var productCatalog:ProductCatalog = new ProductCatalog();
|
182
|
-
* productCatalog.addProduct(new Product("sku123a"));
|
183
|
-
*
|
184
|
-
* // Try retrieving a product using improper text case.
|
185
|
-
* var product:Product = productCatalog.getProductBySku("SKU123A");
|
186
|
-
* assertNull("the SKU parameter should be case sensitive",
|
187
|
-
* product);
|
188
|
-
* }
|
189
|
-
* </pre>
|
190
|
-
*
|
191
|
-
* @param msg
|
192
|
-
* Optional; Message to display should the test fail. It is
|
193
|
-
* recommended that this message describe what is asserted to be
|
194
|
-
* true rather than describing what went wrong.
|
195
|
-
* @param assertion
|
196
|
-
* Object to be evaluated.
|
197
|
-
*/
|
198
|
-
public static function assertNull(msg:Object, assertion:Object):Void {
|
199
|
-
if(arguments.length == 1) {
|
200
|
-
assertion = msg;
|
201
|
-
msg = "";
|
202
|
-
}
|
203
|
-
addTestResult(String(msg), "assertNull", (assertion === null));
|
204
|
-
}
|
205
|
-
|
206
|
-
/**
|
207
|
-
* Asserts that a value is not <code>null</code>.<br />
|
208
|
-
* <br />
|
209
|
-
* The method below tests to confirm that the parameter passed to the
|
210
|
-
* <code>getColorByName</code> method of the <code>ColorManager</code>
|
211
|
-
* class is treated as case insensitive.<br />
|
212
|
-
*
|
213
|
-
* <pre>
|
214
|
-
* public function testGetColorByName():Void {
|
215
|
-
* // Set up a fixture to test against.
|
216
|
-
* var colorManager:ColorManager = new ColorManager();
|
217
|
-
* colorManager.addColor(new Color("blue"));
|
218
|
-
*
|
219
|
-
* // Try retrieving a color using alternate text case.
|
220
|
-
* var color:Color = colorManager.getColorByName("Blue");
|
221
|
-
* assertNotNull("color name parameter should not be case sensitive",
|
222
|
-
* color);
|
223
|
-
* }
|
224
|
-
* </pre>
|
225
|
-
*
|
226
|
-
* @param msg
|
227
|
-
* Optional; Message to display should the test fail. It is
|
228
|
-
* recommended that this message describe what is asserted to be
|
229
|
-
* true rather than describing what went wrong.
|
230
|
-
* @param assertion
|
231
|
-
* Object to be evaluated.
|
232
|
-
*/
|
233
|
-
public static function assertNotNull(msg:Object, assertion:Object):Void {
|
234
|
-
if(arguments.length == 1) {
|
235
|
-
assertion = msg;
|
236
|
-
msg = "";
|
237
|
-
}
|
238
|
-
addTestResult(String(msg), "assertNotNull", (assertion !== null));
|
239
|
-
}
|
240
|
-
|
241
|
-
/**
|
242
|
-
* Asserts that a value is <code>undefined</code>.
|
243
|
-
*
|
244
|
-
* @param msg
|
245
|
-
* Optional; Message to display should the test fail. It is
|
246
|
-
* recommended that this message describe what is asserted to be
|
247
|
-
* true rather than describing what went wrong.
|
248
|
-
* @param assertion
|
249
|
-
* Object to be evaluated.
|
250
|
-
public static function assertUndefined(msg:Object, assertion:Object):Void {
|
251
|
-
if(arguments.length == 1) {
|
252
|
-
assertion = msg;
|
253
|
-
msg = "";
|
254
|
-
}
|
255
|
-
addTestResult(String(msg), "assertUndefined", (assertion === undefined));
|
256
|
-
}
|
257
|
-
|
258
|
-
/**
|
259
|
-
* Asserts that a value is not <code>undefined</code>.
|
260
|
-
*
|
261
|
-
* @param msg
|
262
|
-
* Optional; Message to display should the test fail. It is
|
263
|
-
* recommended that this message describe what is asserted to be
|
264
|
-
* true rather than describing what went wrong.
|
265
|
-
* @param assertion
|
266
|
-
* Object to be evaluated.
|
267
|
-
*/
|
268
|
-
public static function assertNotUndefined(msg:Object, assertion:Object):Void {
|
269
|
-
if(arguments.length == 1) {
|
270
|
-
assertion = msg;
|
271
|
-
msg = "";
|
272
|
-
}
|
273
|
-
addTestResult(String(msg), "assertNotUndefined", (assertion !== undefined));
|
274
|
-
}
|
275
|
-
|
276
|
-
/**
|
277
|
-
* Asserts that two variables are pointing to the same object in
|
278
|
-
* memory.<br />
|
279
|
-
* <br />
|
280
|
-
* The method below tests to confirm that the static
|
281
|
-
* <code>getInstance()</code> method of the <code>ServiceLocator</code>
|
282
|
-
* class always returns a reference to the same instance of
|
283
|
-
* <code>ServiceLocator</code>.<br />
|
284
|
-
*
|
285
|
-
* <pre>
|
286
|
-
* public function testGetInstance():Void {
|
287
|
-
* var instance1:ServiceLocator = ServiceLocator.getInstance();
|
288
|
-
* var instance2:ServiceLocator = ServiceLocator.getInstance();
|
289
|
-
* assertSame("getInstance() should always return the same ServiceLocator instance",
|
290
|
-
* instance1,
|
291
|
-
* instance2);
|
292
|
-
* }
|
293
|
-
* </code>
|
294
|
-
*
|
295
|
-
* @param msg
|
296
|
-
* Optional; Message to display should the test fail. It is
|
297
|
-
* recommended that this message describe what is asserted to be
|
298
|
-
* true rather than describing what went wrong.
|
299
|
-
* @param object1
|
300
|
-
* First object to use in evaluation.
|
301
|
-
* @param object2
|
302
|
-
* Second object to use in evaluation.
|
303
|
-
*/
|
304
|
-
public static function assertSame(msg:Object, object1:Object, object2:Object):Void {
|
305
|
-
if(arguments.length == 2) {
|
306
|
-
object2 = object1;
|
307
|
-
object1 = msg;
|
308
|
-
msg = "";
|
309
|
-
}
|
310
|
-
addTestResult(String(msg), "assertSame", (object1 === object2));
|
311
|
-
}
|
312
|
-
|
313
|
-
/**
|
314
|
-
* Asserts that a statement evaluates to <code>true</code>. Since this
|
315
|
-
* method lets you pass in any expression that evaluates to a boolean
|
316
|
-
* value, it is a good method to fall back on when the other
|
317
|
-
* <code>assert<i>XXX</i></code> methods don't provide the kind of
|
318
|
-
* functionality your test requires.<br />
|
319
|
-
* <br />
|
320
|
-
* The method below test to confirm that new <code>Product</code> objects
|
321
|
-
* are assigned ascending catalog numbers when created by the
|
322
|
-
* <code>ProductGenerator</code> class.<br />
|
323
|
-
*
|
324
|
-
* <pre>
|
325
|
-
* public function testMakeProductCatalogNumberAssignement():Void {
|
326
|
-
* var generator:ProductGenerator = ProductGenerator.getInstance();
|
327
|
-
* var product1:Product = generator.makeProduct("sku123");
|
328
|
-
* var product2:Product = generator.makeProduct("sku456");
|
329
|
-
* assertTrue("products should be assigned ascending catalog numbers",
|
330
|
-
* product1.catNumber < product2.catNumber);
|
331
|
-
* }
|
332
|
-
* </code>
|
333
|
-
*
|
334
|
-
* @param msg
|
335
|
-
* Optional; Message to display should the test fail. It is
|
336
|
-
* recommended that this message describe what is asserted to be
|
337
|
-
* true rather than describing what went wrong.
|
338
|
-
* @param assertion
|
339
|
-
* A statement that evaluates to a boolean value.
|
340
|
-
public static function assertTrue(msg:Object, assertion:Boolean):Void {
|
341
|
-
if(arguments.length == 1) {
|
342
|
-
assertion = Boolean(msg);
|
343
|
-
msg = "";
|
344
|
-
}
|
345
|
-
addTestResult(String(msg), "assertTrue", assertion);
|
346
|
-
}
|
347
|
-
|
348
|
-
/**
|
349
|
-
* Asserts that a statement evaluates to <code>false</code>. Since this
|
350
|
-
* method lets you pass in any expression that evaluates to a boolean
|
351
|
-
* value, it is a good method to fall back on when the other
|
352
|
-
* <code>assert<i>XXX</i></code> methods don't provide the kind of
|
353
|
-
* functionality your test requires.<br />
|
354
|
-
* <br />
|
355
|
-
* The method below tests to confirm that the return value of the
|
356
|
-
* <code>truncate()</code> method of the <code>TextUtil</code>
|
357
|
-
* class is no longer than the specified limit<br />
|
358
|
-
*
|
359
|
-
* <pre>
|
360
|
-
* public function testTruncate():Void {
|
361
|
-
* var limit:Number = 30;
|
362
|
-
* var text:String = "As a reviewer, I got an early opportunity to read the book you are holding.";
|
363
|
-
* var clippedText:String = TextUtil.truncate(text, limit);
|
364
|
-
* assertFalse("return value should be no more than 30 characters",
|
365
|
-
* clippedText.length > 30);
|
366
|
-
* }
|
367
|
-
* </code>
|
368
|
-
*
|
369
|
-
* @param msg
|
370
|
-
* Optional; Message to display should the test fail. It is
|
371
|
-
* recommended that this message describe what is asserted to be
|
372
|
-
* true rather than describing what went wrong.
|
373
|
-
* @param assertion
|
374
|
-
* A statement that evaluates to a boolean value.
|
375
|
-
*/
|
376
|
-
public static function assertFalse(msg:Object, assertion:Boolean):Void {
|
377
|
-
if(arguments.length == 1) {
|
378
|
-
assertion = Boolean(msg);
|
379
|
-
msg = "";
|
380
|
-
}
|
381
|
-
addTestResult(String(msg), "assertFalse", !assertion);
|
382
|
-
}
|
383
|
-
|
384
|
-
/**
|
385
|
-
* Forces a failing test result to be recorded. This method is useful
|
386
|
-
* in the rare circumstances where the <code>assert<i>XXX</i></code>
|
387
|
-
* methods can not be used, for example, when testing error
|
388
|
-
* handling.<br>
|
389
|
-
* <br />
|
390
|
-
* The method below tests to confirm that a "gifts" product category can
|
391
|
-
* be accessed through a <code>Catalog</code> instance.<br />
|
392
|
-
*
|
393
|
-
* <pre>
|
394
|
-
* public function testGiftsProductCategoryAccess():Void {
|
395
|
-
* var catalog:ProductCatalog = CatalogFactory.getCatalog("fall2005");
|
396
|
-
*
|
397
|
-
* // Try accessing the "gifts" product category.
|
398
|
-
* try {
|
399
|
-
* var products:Array = catalog.getProducts("gifts");
|
400
|
-
* } catch (error:com.mycompany.errors.InvalidProductCategoryError) {
|
401
|
-
* fail("catalog should contain 'gifts' products");
|
402
|
-
* }
|
403
|
-
* }
|
404
|
-
* </pre>
|
405
|
-
public static function fail(msg:Object):Void {
|
406
|
-
addTestResult(String(msg), "fail", false);
|
407
|
-
}
|
408
|
-
}
|