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,7 @@
1
+
2
+ class asunit.errors.AssertionFailedError extends Error {
3
+
4
+ public function AssertionFailedError(msg:String) {
5
+ super(msg);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+
2
+ class asunit.errors.AssertionPassedError extends Error {
3
+
4
+ public function AssertionPassedError(msg:String) {
5
+ super(msg);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+
2
+ class asunit.errors.ClassNotFoundError extends Error {
3
+
4
+ public function ClassNotFoundError(msg:String) {
5
+ super(msg);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+
2
+ class asunit.errors.IllegalOperationError extends Error {
3
+
4
+ public function IllegalOperationError(msg:String) {
5
+ super(msg);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+
2
+ class asunit.errors.InstanceNotFoundError extends Error {
3
+
4
+ public function InstanceNotFoundError(msg:String) {
5
+ super(msg);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+
2
+ class asunit.errors.InvocationTargetError extends Error {
3
+
4
+ public function InvocationTargetError(msg:String) {
5
+ super(msg);
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+
2
+ class asunit.errors.UnimplementedFeatureError extends Error {
3
+
4
+ public function UnimplementedFeatureError(msg:String) {
5
+ super(msg);
6
+ }
7
+ }
@@ -0,0 +1,376 @@
1
+ import asunit.errors.AssertionFailedError;
2
+ import asunit.errors.IllegalOperationError;
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 asunit.framework.Assert {
13
+ private static var defaultClassName:String = "[ClassName Unknown]";
14
+ private static var lastDepth:Number = 10;
15
+
16
+ private function Assert() {
17
+ }
18
+
19
+ /**
20
+ * Returns the next available depth for attaching a MovieClip.
21
+ *
22
+ * @return
23
+ * Number of next available depth.
24
+ */
25
+ public static function nextDepth():Number {
26
+ return Assert.lastDepth++;
27
+ }
28
+
29
+ /**
30
+ * Appends a test result to the {@link TestRunner} which manages test
31
+ * result output. This method is intended for use by the AsUnit
32
+ * framework and should never have to be called directly.
33
+ *
34
+ * @param msg
35
+ * The message associated with the assertion.
36
+ * @param assertType
37
+ * The assertion type.
38
+ * @param passFail
39
+ * Indicates whether the test passed (<code>true</code>) or
40
+ * failed (<code>false</code>).
41
+ *
42
+ */
43
+ public static function addTestResult(msg:String, assertType:String, passed:Boolean) {
44
+ if(!passed) {
45
+ var str:String = "";
46
+ if(msg != "") {
47
+ str += assertType + ".message: " + msg;
48
+ }
49
+ fail(str);
50
+ }
51
+ }
52
+
53
+ /**
54
+ * Returns a reference to the {@link TestRunner} instance which manages
55
+ * the output of test results. This method is intended for use by the
56
+ * AsUnit framework and should never have to be called directly.
57
+ private static function getTestRunner():TestRunner {
58
+ if(testRunner == null) {
59
+ testRunner = new TestRunner();
60
+ }
61
+ return testRunner;
62
+ }
63
+ */
64
+
65
+ /**
66
+ * Returns the number of {@link TestCases} that have completed.
67
+ public static function countTestCases():Number {
68
+ return testRunner.length;
69
+ }
70
+ */
71
+
72
+ /**
73
+ * Asserts that two objects are equal. If either of the
74
+ * objects provides an <code>equals()</code> method it will be used to
75
+ * determine equality. Otherwise, equality will be evaluated using the
76
+ * strict equality operator (<code>===</code>).<br />
77
+ * <br />
78
+ * The method below tests the <code>getFullName()</code> method of the
79
+ * <code>Person</code> class to make sure that the formatting of its
80
+ * return value is correct.<br />
81
+ *
82
+ * <pre>
83
+ * public function testGetFullName():Void {
84
+ * var person:Person = new Person("John", "Alan", "Smith");
85
+ * assertEquals("full name should be formatted: [first] [middleInitial]. [last]",
86
+ * "John A. Smith",
87
+ * person.getFullName());
88
+ * }
89
+ * </pre>
90
+ *
91
+ * @param msg
92
+ * Optional; Message to display should the test fail. It is
93
+ * recommended that this message describe what is asserted to be
94
+ * true rather than describing what went wrong.
95
+ * @param assertion1
96
+ * First object to use in evaluation.
97
+ * @param assertion2
98
+ * Second object to use in evaluation.
99
+ */
100
+ public static function assertEquals(msg:Object, assertion1:Object, assertion2:Object):Void {
101
+ if(arguments.length == 2) {
102
+ assertion2 = assertion1;
103
+ assertion1 = msg;
104
+ msg = "";
105
+ }
106
+ if(assertion1["equals"] instanceof Function) {
107
+ addTestResult(String(msg), "assertEquals", assertion1["equals"](assertion2));
108
+ } else if(assertion2["equals"] != undefined) {
109
+ addTestResult(String(msg), "assertEquals", assertion2["equals"](assertion1));
110
+ } else {
111
+ addTestResult(format(String(msg), assertion1, assertion2), "assertEquals", assertion1 == assertion2);
112
+ }
113
+
114
+ }
115
+
116
+ /**
117
+ * Asserts that a value is <code>null</code>.<br />
118
+ * <br />
119
+ * The method below tests to confirm that the parameter passed to the
120
+ * <code>getProductBySku</code> method of the
121
+ * <code>ProductCatalog</code> is treated as case sensitive.<br />
122
+ *
123
+ * <pre>
124
+ * public function testGetProductBySku():Void {
125
+ * // Set up a fixture to test against.
126
+ * var productCatalog:ProductCatalog = new ProductCatalog();
127
+ * productCatalog.addProduct(new Product("sku123a"));
128
+ *
129
+ * // Try retrieving a product using improper text case.
130
+ * var product:Product = productCatalog.getProductBySku("SKU123A");
131
+ * assertNull("the SKU parameter should be case sensitive",
132
+ * product);
133
+ * }
134
+ * </pre>
135
+ *
136
+ * @param msg
137
+ * Optional; Message to display should the test fail. It is
138
+ * recommended that this message describe what is asserted to be
139
+ * true rather than describing what went wrong.
140
+ * @param assertion
141
+ * Object to be evaluated.
142
+ */
143
+ public static function assertNull(msg:Object, assertion:Object):Void {
144
+ if(arguments.length == 1) {
145
+ assertion = msg;
146
+ msg = "";
147
+ }
148
+ addTestResult(String(msg), "assertNull", (assertion === null));
149
+ }
150
+
151
+ /**
152
+ * Asserts that a value is not <code>null</code>.<br />
153
+ * <br />
154
+ * The method below tests to confirm that the parameter passed to the
155
+ * <code>getColorByName</code> method of the <code>ColorManager</code>
156
+ * class is treated as case insensitive.<br />
157
+ *
158
+ * <pre>
159
+ * public function testGetColorByName():Void {
160
+ * // Set up a fixture to test against.
161
+ * var colorManager:ColorManager = new ColorManager();
162
+ * colorManager.addColor(new Color("blue"));
163
+ *
164
+ * // Try retrieving a color using alternate text case.
165
+ * var color:Color = colorManager.getColorByName("Blue");
166
+ * assertNotNull("color name parameter should not be case sensitive",
167
+ * color);
168
+ * }
169
+ * </pre>
170
+ *
171
+ * @param msg
172
+ * Optional; Message to display should the test fail. It is
173
+ * recommended that this message describe what is asserted to be
174
+ * true rather than describing what went wrong.
175
+ * @param assertion
176
+ * Object to be evaluated.
177
+ */
178
+ public static function assertNotNull(msg:Object, assertion:Object):Void {
179
+ if(arguments.length == 1) {
180
+ assertion = msg;
181
+ msg = "";
182
+ }
183
+ addTestResult(String(msg), "assertNotNull", (assertion !== null));
184
+ }
185
+
186
+ /**
187
+ * Asserts that a value is <code>undefined</code>.
188
+ *
189
+ * @param msg
190
+ * Optional; Message to display should the test fail. It is
191
+ * recommended that this message describe what is asserted to be
192
+ * true rather than describing what went wrong.
193
+ * @param assertion
194
+ * Object to be evaluated.
195
+ */
196
+ public static function assertUndefined(msg:Object, assertion:Object):Void {
197
+ if(arguments.length == 1) {
198
+ assertion = msg;
199
+ msg = "";
200
+ }
201
+ addTestResult(String(msg), "assertUndefined", (assertion === undefined));
202
+ }
203
+
204
+ /**
205
+ * Asserts that a value is not <code>undefined</code>.
206
+ *
207
+ * @param msg
208
+ * Optional; Message to display should the test fail. It is
209
+ * recommended that this message describe what is asserted to be
210
+ * true rather than describing what went wrong.
211
+ * @param assertion
212
+ * Object to be evaluated.
213
+ */
214
+ public static function assertNotUndefined(msg:Object, assertion:Object):Void {
215
+ if(arguments.length == 1) {
216
+ assertion = msg;
217
+ msg = "";
218
+ }
219
+ addTestResult(String(msg), "assertNotUndefined", (assertion !== undefined));
220
+ }
221
+
222
+ /**
223
+ * Asserts that two variables are pointing to the same object in
224
+ * memory.<br />
225
+ * <br />
226
+ * The method below tests to confirm that the static
227
+ * <code>getInstance()</code> method of the <code>ServiceLocator</code>
228
+ * class always returns a reference to the same instance of
229
+ * <code>ServiceLocator</code>.<br />
230
+ *
231
+ * <pre>
232
+ * public function testGetInstance():Void {
233
+ * var instance1:ServiceLocator = ServiceLocator.getInstance();
234
+ * var instance2:ServiceLocator = ServiceLocator.getInstance();
235
+ * assertSame("getInstance() should always return the same ServiceLocator instance",
236
+ * instance1,
237
+ * instance2);
238
+ * }
239
+ * </code>
240
+ *
241
+ * @param msg
242
+ * Optional; Message to display should the test fail. It is
243
+ * recommended that this message describe what is asserted to be
244
+ * true rather than describing what went wrong.
245
+ * @param object1
246
+ * First object to use in evaluation.
247
+ * @param object2
248
+ * Second object to use in evaluation.
249
+ */
250
+ public static function assertSame(msg:Object, object1:Object, object2:Object):Void {
251
+ if(arguments.length == 2) {
252
+ object2 = object1;
253
+ object1 = msg;
254
+ msg = "";
255
+ }
256
+ addTestResult(String(msg), "assertSame", (object1 === object2));
257
+ }
258
+
259
+ /**
260
+ * Asserts that a statement evaluates to <code>true</code>. Since this
261
+ * method lets you pass in any expression that evaluates to a boolean
262
+ * value, it is a good method to fall back on when the other
263
+ * <code>assert<i>XXX</i></code> methods don't provide the kind of
264
+ * functionality your test requires.<br />
265
+ * <br />
266
+ * The method below test to confirm that new <code>Product</code> objects
267
+ * are assigned ascending catalog numbers when created by the
268
+ * <code>ProductGenerator</code> class.<br />
269
+ *
270
+ * <pre>
271
+ * public function testMakeProductCatalogNumberAssignement():Void {
272
+ * var generator:ProductGenerator = ProductGenerator.getInstance();
273
+ * var product1:Product = generator.makeProduct("sku123");
274
+ * var product2:Product = generator.makeProduct("sku456");
275
+ * assertTrue("products should be assigned ascending catalog numbers",
276
+ * product1.catNumber &lt; product2.catNumber);
277
+ * }
278
+ * </code>
279
+ *
280
+ * @param msg
281
+ * Optional; Message to display should the test fail. It is
282
+ * recommended that this message describe what is asserted to be
283
+ * true rather than describing what went wrong.
284
+ * @param assertion
285
+ * A statement that evaluates to a boolean value.
286
+ */
287
+ public static function assertTrue(msg:Object, assertion:Boolean):Void {
288
+ if(arguments.length == 1) {
289
+ assertion = Boolean(msg);
290
+ msg = "";
291
+ }
292
+
293
+ if(arguments.length > 2) {
294
+ failError("Argument Count Exceeded " + String(msg), "assertTrue");
295
+ }
296
+ addTestResult(String(msg), "assertTrue", assertion);
297
+ }
298
+
299
+ /**
300
+ * Asserts that a statement evaluates to <code>false</code>. Since this
301
+ * method lets you pass in any expression that evaluates to a boolean
302
+ * value, it is a good method to fall back on when the other
303
+ * <code>assert<i>XXX</i></code> methods don't provide the kind of
304
+ * functionality your test requires.<br />
305
+ * <br />
306
+ * The method below tests to confirm that the return value of the
307
+ * <code>truncate()</code> method of the <code>TextUtil</code>
308
+ * class is no longer than the specified limit<br />
309
+ *
310
+ * <pre>
311
+ * public function testTruncate():Void {
312
+ * var limit:Number = 30;
313
+ * var text:String = "As a reviewer, I got an early opportunity to read the book you are holding.";
314
+ * var clippedText:String = TextUtil.truncate(text, limit);
315
+ * assertFalse("return value should be no more than 30 characters",
316
+ * clippedText.length &gt; 30);
317
+ * }
318
+ * </code>
319
+ *
320
+ * @param msg
321
+ * Optional; Message to display should the test fail. It is
322
+ * recommended that this message describe what is asserted to be
323
+ * true rather than describing what went wrong.
324
+ * @param assertion
325
+ * A statement that evaluates to a boolean value.
326
+ */
327
+ public static function assertFalse(msg:Object, assertion:Boolean):Void {
328
+ if(arguments.length == 1) {
329
+ assertion = Boolean(msg);
330
+ msg = "";
331
+ }
332
+ addTestResult(String(msg), "assertFalse", !assertion);
333
+ }
334
+
335
+ /**
336
+ * Forces a failing test result to be recorded. This method is useful
337
+ * in the rare circumstances where the <code>assert<i>XXX</i></code>
338
+ * methods can not be used, for example, when testing error
339
+ * handling.<br>
340
+ * <br />
341
+ * The method below tests to confirm that a "gifts" product category can
342
+ * be accessed through a <code>Catalog</code> instance.<br />
343
+ *
344
+ * <pre>
345
+ * public function testGiftsProductCategoryAccess():Void {
346
+ * var catalog:ProductCatalog = CatalogFactory.getCatalog("fall2005");
347
+ *
348
+ * // Try accessing the "gifts" product category.
349
+ * try {
350
+ * var products:Array = catalog.getProducts("gifts");
351
+ * } catch (error:com.mycompany.errors.InvalidProductCategoryError) {
352
+ * fail("catalog should contain 'gifts' products");
353
+ * }
354
+ * }
355
+ * </pre>
356
+ */
357
+ public static function fail(msg:String):Void {
358
+ throw new AssertionFailedError(msg);
359
+ }
360
+
361
+ // private static function failNotEquals(message:String, expected:Object, actual:Object):Void {
362
+ // fail(format(message, expected, actual));
363
+ // }
364
+
365
+ private static function format(message:String, expected:Object, actual:Object):String {
366
+ var formatted:String = "";
367
+ if(message != null) {
368
+ formatted = message + " ";
369
+ }
370
+ return formatted + "expected:<" + expected + "> but was:<" + actual + ">";
371
+ }
372
+
373
+ public static function failError(msg:String):Void {
374
+ throw new IllegalOperationError(msg);
375
+ }
376
+ }
@@ -0,0 +1,15 @@
1
+ import asunit.framework.Assert;
2
+
3
+ class asunit.framework.AssertMock extends Assert {
4
+
5
+ public function AssertMock() {
6
+ }
7
+
8
+ public function assertTrue():Void {
9
+ Assert.assertTrue.apply(Assert, arguments);
10
+ }
11
+
12
+ public function assertEquals():Void {
13
+ Assert.assertEquals.apply(arguments);
14
+ }
15
+ }