asproject 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +0 -0
- data/History.txt +0 -0
- data/MIT-LICENSE.txt +20 -0
- data/Manifest.txt +16 -0
- data/README.txt +3 -0
- data/TODO.txt +10 -0
- data/bin/asclass +16 -0
- data/bin/asproject +16 -0
- data/lib/asclass.rb +254 -0
- data/lib/asclass_arguments.rb +147 -0
- data/lib/asproject.rb +248 -0
- data/lib/asproject/version.rb +9 -0
- data/lib/asproject_arguments.rb +175 -0
- data/lib/asproject_base.rb +43 -0
- data/lib/asproject_utils.rb +57 -0
- data/lib/eclipse_project.rb +32 -0
- data/lib/path_finder.rb +286 -0
- data/lib/platform.rb +107 -0
- data/lib/project.rb +82 -0
- data/lib/template_resolver.rb +144 -0
- data/lib/test_suite_generator.rb +128 -0
- data/rakefile.rb +85 -0
- data/setup.rb +1585 -0
- data/templates/asclass/as2/Class.as +11 -0
- data/templates/asclass/as2/Component.as +8 -0
- data/templates/asclass/as2/Interface.as +3 -0
- data/templates/asclass/as2/TestCase.as +30 -0
- data/templates/asclass/as2/TestSuite.as +15 -0
- data/templates/asclass/as3/Class.as +9 -0
- data/templates/asclass/as3/Component.as +9 -0
- data/templates/asclass/as3/Component.mxml +1 -0
- data/templates/asclass/as3/Interface.as +6 -0
- data/templates/asclass/as3/TestCase.as +30 -0
- data/templates/asclass/as3/TestSuite.as +18 -0
- data/templates/asproject/as2/project/rakefile.rb +18 -0
- data/templates/asproject/as2/project/src/AsProject.as +13 -0
- data/templates/asproject/as2/project/test/AsProjectRunner.as +12 -0
- data/templates/asproject/as3/project/rakefile.rb +18 -0
- data/templates/asproject/as3/project/src/AsProject.as +9 -0
- data/templates/asproject/as3/project/src/AsProjectRunner.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/AsUnitUi.swf +0 -0
- data/templates/asproject/asunit2/project/lib/asunit/Sys.as +70 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanel.as +182 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTest.as +84 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextArea.as +111 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTextAreaTest.as +26 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/LocalOutputPanelTitleBar.as +81 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ResizeHandle.as +35 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollArrow.as +34 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollHandle.as +43 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/ScrollListener.as +10 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/TextScroller.as +169 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Rectangle.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/controls/shapes/Triangle.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/AsUnit.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assert.as +408 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Assertion.as +27 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Reflection.as +68 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/Test.as +3 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCase.as +191 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestCaseXml.as +31 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestFailure.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestResult.as +15 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestRunner.as +41 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSetup.as +19 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/framework/TestSuite.as +22 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/Main.as +325 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/RemoteVersion.as +24 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/ui/SuccessMeter.as +32 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Comparable.as +7 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventListener.as +29 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/EventSource.as +89 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnClient.as +42 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnGateway.as +47 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalConnServer.as +61 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/LocalMessageBroker.as +58 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/Observable.as +11 -0
- data/templates/asproject/asunit2/project/lib/asunit/com/asunit/util/TextFile.as +30 -0
- data/templates/asproject/asunit25/project/lib/asunit/AsUnitTestRunner.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionFailedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/AssertionPassedError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/ClassNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/IllegalOperationError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/InvocationTargetError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +7 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Assert.as +376 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertMock.as +15 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/AssertTest.as +59 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/ITestListener.as +13 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/Test.as +11 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCase.as +277 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseMock.as +23 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseTest.as +29 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestCaseXml.as +38 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestResult.as +168 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/framework/TestSuite.as +102 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/BaseTestRunner.as +101 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/runner/IResultPrinter.as +8 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/ResultPrinter.as +254 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/SuccessBar.as +41 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/textui/TestRunner.as +17 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIterator.as +24 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/ArrayIteratorTest.as +52 -0
- data/templates/asproject/asunit25/project/lib/asunit/asunit/util/Iterator.as +5 -0
- data/templates/asproject/asunit3/project/lib/asunit/AsUnitTestRunner.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AbstractMemberCalledError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/AssertionFailedError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/ClassNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/InstanceNotFoundError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/errors/UnimplementedFeatureError.as +10 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Assert.as +271 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCase.as +52 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/AsynchronousTestCaseExample.as +71 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/Test.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCase.as +351 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestCaseExample.as +73 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestFailure.as +47 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestListener.as +22 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestResult.as +158 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/framework/TestSuite.as +115 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/BaseTestRunner.as +15 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/TestSuiteLoader.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/runner/Version.as +11 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexRunner.as +19 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/FlexTestRunner.as +55 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/ResultPrinter.as +245 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/textui/TestRunner.as +121 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/ArrayIterator.as +26 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Iterator.as +9 -0
- data/templates/asproject/asunit3/project/lib/asunit/asunit/util/Properties.as +30 -0
- data/templates/asproject/asunit3/project/lib/asunit/mx/managers/LayoutManager.as +945 -0
- data/templates/asproject/config/project/config/asclass_config.rb +58 -0
- data/templates/asproject/fb2as/project/.actionScriptProperties +21 -0
- data/templates/asproject/fb2as/project/.project +29 -0
- data/templates/asproject/fdt/project/.as2_classpath +6 -0
- data/templates/asproject/fdt/project/.project +19 -0
- data/templates/ide/mate/Create Class.tmCommand +37 -0
- data/templates/ide/mate/Rebuild Test Suites.tmCommand +33 -0
- data/templates/ide/mate/Run Rake Task.tmCommand +127 -0
- metadata +266 -0
@@ -0,0 +1,29 @@
|
|
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
|
+
}
|
@@ -0,0 +1,27 @@
|
|
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
|
+
}
|
@@ -0,0 +1,19 @@
|
|
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
|
+
}
|
@@ -0,0 +1,408 @@
|
|
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
|
+
}
|