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,41 +0,0 @@
|
|
1
|
-
|
2
|
-
class asunit.textui.SuccessBar extends MovieClip {
|
3
|
-
public static var linkageId:String = "__Packages.asunit.textui.SuccessBar";
|
4
|
-
public static var classRef:Function = SuccessBar;
|
5
|
-
|
6
|
-
private var myWidth:Number = 0;
|
7
|
-
private var myHeight:Number = 0;
|
8
|
-
private var bgColor:Number;
|
9
|
-
private var passingColor:Number = 0x00FF00;
|
10
|
-
private var failingColor:Number = 0xFD0000;
|
11
|
-
|
12
|
-
public function SuccessBar() {
|
13
|
-
}
|
14
|
-
|
15
|
-
public function setSuccess(success:Boolean):Void {
|
16
|
-
bgColor = (success) ? passingColor : failingColor;
|
17
|
-
draw();
|
18
|
-
}
|
19
|
-
|
20
|
-
public function set width(num:Number):Void {
|
21
|
-
myWidth = num;
|
22
|
-
draw();
|
23
|
-
}
|
24
|
-
|
25
|
-
public function set height(num:Number):Void {
|
26
|
-
myHeight = num;
|
27
|
-
draw();
|
28
|
-
}
|
29
|
-
|
30
|
-
private function draw():Void {
|
31
|
-
clear();
|
32
|
-
beginFill(bgColor);
|
33
|
-
lineTo(myWidth, 0);
|
34
|
-
lineTo(myWidth, myHeight);
|
35
|
-
lineTo(0, myHeight);
|
36
|
-
lineTo(0, 0);
|
37
|
-
endFill();
|
38
|
-
}
|
39
|
-
|
40
|
-
public static var serializable:Boolean = Object.registerClass(linkageId, classRef);
|
41
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import asunit.runner.BaseTestRunner;
|
2
|
-
import asunit.textui.ResultPrinter;
|
3
|
-
|
4
|
-
/*
|
5
|
-
* This concrete TestRunner is simply created in order
|
6
|
-
* to choose a concrete ResultPrinter... This was
|
7
|
-
* set up so that we can easily output results
|
8
|
-
* to any target desired - this should include
|
9
|
-
* XMLSocket, LocalConnection, trace window,
|
10
|
-
* file system, etc.
|
11
|
-
*/
|
12
|
-
class asunit.textui.TestRunner extends BaseTestRunner {
|
13
|
-
|
14
|
-
public function TestRunner() {
|
15
|
-
super(ResultPrinter);
|
16
|
-
}
|
17
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
import asunit.util.Iterator;
|
3
|
-
import asunit.errors.IllegalOperationError;
|
4
|
-
|
5
|
-
class asunit.util.ArrayIterator implements Iterator {
|
6
|
-
|
7
|
-
private var list:Array;
|
8
|
-
private var index:Number = 0;
|
9
|
-
|
10
|
-
public function ArrayIterator(list:Array) {
|
11
|
-
if(list == null) {
|
12
|
-
throw new IllegalOperationError("ArrayIterator needs an array in it's constructor");
|
13
|
-
}
|
14
|
-
this.list = list;
|
15
|
-
}
|
16
|
-
|
17
|
-
public function hasNext():Boolean {
|
18
|
-
return (list[index] != null);
|
19
|
-
}
|
20
|
-
|
21
|
-
public function next():Object {
|
22
|
-
return list[index++];
|
23
|
-
}
|
24
|
-
}
|
@@ -1,52 +0,0 @@
|
|
1
|
-
|
2
|
-
import asunit.util.ArrayIterator;
|
3
|
-
import asunit.framework.TestCase;
|
4
|
-
|
5
|
-
class asunit.util.ArrayIteratorTest extends TestCase {
|
6
|
-
private var className:String = "asunit.util.ArrayIteratorTest";
|
7
|
-
private var instance:ArrayIterator;
|
8
|
-
|
9
|
-
public function ArrayIteratorTest(testMethod:String) {
|
10
|
-
super(testMethod);
|
11
|
-
}
|
12
|
-
|
13
|
-
public function setUp():Void {
|
14
|
-
var arr:Array = new Array("one", "two", "three", "four", "five");
|
15
|
-
instance = new ArrayIterator(arr);
|
16
|
-
}
|
17
|
-
|
18
|
-
public function tearDown():Void {
|
19
|
-
delete instance;
|
20
|
-
}
|
21
|
-
|
22
|
-
public function testInstantiated():Void {
|
23
|
-
assertTrue("ArrayIterator instantiated", instance instanceof ArrayIterator);
|
24
|
-
}
|
25
|
-
|
26
|
-
public function testIterate():Void {
|
27
|
-
assertTrue("1", instance.hasNext());
|
28
|
-
assertEquals("2", "one", instance.next());
|
29
|
-
assertTrue("3", instance.hasNext());
|
30
|
-
assertEquals("4", "two", instance.next());
|
31
|
-
assertTrue("5", instance.hasNext());
|
32
|
-
assertEquals("6", "three", instance.next());
|
33
|
-
assertTrue("7", instance.hasNext());
|
34
|
-
assertEquals("8", "four", instance.next());
|
35
|
-
assertTrue("9", instance.hasNext());
|
36
|
-
assertEquals("10", "five", instance.next());
|
37
|
-
assertFalse("11", instance.hasNext());
|
38
|
-
}
|
39
|
-
|
40
|
-
public function testEmpty():Void {
|
41
|
-
var itr:ArrayIterator = new ArrayIterator(new Array());
|
42
|
-
assertFalse("1", itr.hasNext());
|
43
|
-
}
|
44
|
-
|
45
|
-
public function testSingleItem():Void {
|
46
|
-
var itr:ArrayIterator = new ArrayIterator(new Array("one"));
|
47
|
-
assertTrue(itr.hasNext());
|
48
|
-
assertEquals("2", "one", itr.next());
|
49
|
-
assertFalse("3", itr.hasNext());
|
50
|
-
|
51
|
-
}
|
52
|
-
}
|
@@ -1,271 +0,0 @@
|
|
1
|
-
package asunit.framework {
|
2
|
-
import asunit.errors.AssertionFailedError;
|
3
|
-
|
4
|
-
import flash.errors.IllegalOperationError;
|
5
|
-
import flash.events.EventDispatcher;
|
6
|
-
import flash.utils.Proxy;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* A set of assert methods. Messages are only displayed when an assert fails.
|
10
|
-
*/
|
11
|
-
|
12
|
-
public class Assert extends EventDispatcher {
|
13
|
-
/**
|
14
|
-
* Protect constructor since it is a static only class
|
15
|
-
*/
|
16
|
-
public function Assert() {
|
17
|
-
}
|
18
|
-
|
19
|
-
/**
|
20
|
-
* Asserts that a condition is true. If it isn't it throws
|
21
|
-
* an AssertionFailedError with the given message.
|
22
|
-
*/
|
23
|
-
static public function assertTrue(...args:Array):void {
|
24
|
-
var message:String;
|
25
|
-
var condition:Boolean;
|
26
|
-
|
27
|
-
if(args.length == 1) {
|
28
|
-
message = "";
|
29
|
-
condition = Boolean(args[0]);
|
30
|
-
}
|
31
|
-
else if(args.length == 2) {
|
32
|
-
message = args[0];
|
33
|
-
condition = Boolean(args[1]);
|
34
|
-
}
|
35
|
-
else {
|
36
|
-
throw new IllegalOperationError("Invalid argument count");
|
37
|
-
}
|
38
|
-
|
39
|
-
if(!condition) {
|
40
|
-
fail(message);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
/**
|
44
|
-
* Asserts that a condition is false. If it isn't it throws
|
45
|
-
* an AssertionFailedError with the given message.
|
46
|
-
*/
|
47
|
-
static public function assertFalse(...args:Array):void {
|
48
|
-
var message:String;
|
49
|
-
var condition:Boolean;
|
50
|
-
|
51
|
-
if(args.length == 1) {
|
52
|
-
message = "";
|
53
|
-
condition = Boolean(args[0]);
|
54
|
-
}
|
55
|
-
else if(args.length == 2) {
|
56
|
-
message = args[0];
|
57
|
-
condition = Boolean(args[1]);
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
throw new IllegalOperationError("Invalid argument count");
|
61
|
-
}
|
62
|
-
|
63
|
-
assertTrue(message, !condition);
|
64
|
-
}
|
65
|
-
/**
|
66
|
-
* Fails a test with the given message.
|
67
|
-
*/
|
68
|
-
static public function fail(message:String):void {
|
69
|
-
throw new AssertionFailedError(message);
|
70
|
-
}
|
71
|
-
/**
|
72
|
-
* Asserts that two objects are equal. If they are not
|
73
|
-
* an AssertionFailedError is thrown with the given message.
|
74
|
-
*/
|
75
|
-
static public function assertEquals(...args:Array):void {
|
76
|
-
var message:String;
|
77
|
-
var expected:Object;
|
78
|
-
var actual:Object;
|
79
|
-
|
80
|
-
if(args.length == 2) {
|
81
|
-
message = "";
|
82
|
-
expected = args[0];
|
83
|
-
actual = args[1];
|
84
|
-
}
|
85
|
-
else if(args.length == 3) {
|
86
|
-
message = args[0];
|
87
|
-
expected = args[1];
|
88
|
-
actual = args[2];
|
89
|
-
}
|
90
|
-
else {
|
91
|
-
throw new IllegalOperationError("Invalid argument count");
|
92
|
-
}
|
93
|
-
|
94
|
-
if(expected == null && actual == null) {
|
95
|
-
return;
|
96
|
-
}
|
97
|
-
|
98
|
-
try {
|
99
|
-
if(expected != null && expected.equals(actual)) {
|
100
|
-
return;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
catch(e:Error) {
|
104
|
-
if(expected != null && expected == actual) {
|
105
|
-
return;
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
failNotEquals(message, expected, actual);
|
110
|
-
}
|
111
|
-
/**
|
112
|
-
* Asserts that an object isn't null. If it is
|
113
|
-
* an AssertionFailedError is thrown with the given message.
|
114
|
-
*/
|
115
|
-
static public function assertNotNull(...args:Array):void {
|
116
|
-
var message:String;
|
117
|
-
var object:Object;
|
118
|
-
|
119
|
-
if(args.length == 1) {
|
120
|
-
message = "";
|
121
|
-
object = args[0];
|
122
|
-
}
|
123
|
-
else if(args.length == 2) {
|
124
|
-
message = args[0];
|
125
|
-
object = args[1];
|
126
|
-
}
|
127
|
-
else {
|
128
|
-
throw new IllegalOperationError("Invalid argument count");
|
129
|
-
}
|
130
|
-
|
131
|
-
assertTrue(message, object != null);
|
132
|
-
}
|
133
|
-
/**
|
134
|
-
* Asserts that an object is null. If it is not
|
135
|
-
* an AssertionFailedError is thrown with the given message.
|
136
|
-
*/
|
137
|
-
static public function assertNull(...args:Array):void {
|
138
|
-
var message:String;
|
139
|
-
var object:Object;
|
140
|
-
|
141
|
-
if(args.length == 1) {
|
142
|
-
message = "";
|
143
|
-
object = args[0];
|
144
|
-
}
|
145
|
-
else if(args.length == 2) {
|
146
|
-
message = args[0];
|
147
|
-
object = args[1];
|
148
|
-
}
|
149
|
-
else {
|
150
|
-
throw new IllegalOperationError("Invalid argument count");
|
151
|
-
}
|
152
|
-
|
153
|
-
assertTrue(message, object == null);
|
154
|
-
}
|
155
|
-
/**
|
156
|
-
* Asserts that two objects refer to the same object. If they are not
|
157
|
-
* an AssertionFailedError is thrown with the given message.
|
158
|
-
*/
|
159
|
-
static public function assertSame(...args:Array):void {
|
160
|
-
var message:String;
|
161
|
-
var expected:Object;
|
162
|
-
var actual:Object;
|
163
|
-
|
164
|
-
if(args.length == 2) {
|
165
|
-
message = "";
|
166
|
-
expected = args[0];
|
167
|
-
actual = args[1];
|
168
|
-
}
|
169
|
-
else if(args.length == 3) {
|
170
|
-
message = args[0];
|
171
|
-
expected = args[1];
|
172
|
-
actual = args[2];
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
throw new IllegalOperationError("Invalid argument count");
|
176
|
-
}
|
177
|
-
|
178
|
-
if(expected === actual) {
|
179
|
-
return;
|
180
|
-
}
|
181
|
-
failNotSame(message, expected, actual);
|
182
|
-
}
|
183
|
-
/**
|
184
|
-
* Asserts that two objects refer to the same object. If they are not
|
185
|
-
* an AssertionFailedError is thrown with the given message.
|
186
|
-
*/
|
187
|
-
static public function assertNotSame(...args:Array):void {
|
188
|
-
var message:String;
|
189
|
-
var expected:Object;
|
190
|
-
var actual:Object;
|
191
|
-
|
192
|
-
if(args.length == 2) {
|
193
|
-
message = "";
|
194
|
-
expected = args[0];
|
195
|
-
actual = args[1];
|
196
|
-
}
|
197
|
-
else if(args.length == 3) {
|
198
|
-
message = args[0];
|
199
|
-
expected = args[1];
|
200
|
-
actual = args[2];
|
201
|
-
}
|
202
|
-
else {
|
203
|
-
throw new IllegalOperationError("Invalid argument count");
|
204
|
-
}
|
205
|
-
|
206
|
-
if(expected === actual)
|
207
|
-
failSame(message);
|
208
|
-
}
|
209
|
-
|
210
|
-
/**
|
211
|
-
* Asserts that two numerical values are equal within a tolerance range.
|
212
|
-
* If they are not an AssertionFailedError is thrown with the given message.
|
213
|
-
*/
|
214
|
-
static public function assertEqualsFloat(...args:Array):void {
|
215
|
-
var message:String;
|
216
|
-
var expected:Number;
|
217
|
-
var actual:Number;
|
218
|
-
var tolerance:Number = 0;
|
219
|
-
|
220
|
-
if(args.length == 3) {
|
221
|
-
message = "";
|
222
|
-
expected = args[0];
|
223
|
-
actual = args[1];
|
224
|
-
tolerance = args[2];
|
225
|
-
}
|
226
|
-
else if(args.length == 4) {
|
227
|
-
message = args[0];
|
228
|
-
expected = args[1];
|
229
|
-
actual = args[2];
|
230
|
-
tolerance = args[3];
|
231
|
-
}
|
232
|
-
else {
|
233
|
-
throw new IllegalOperationError("Invalid argument count");
|
234
|
-
}
|
235
|
-
if (isNaN(tolerance)) tolerance = 0;
|
236
|
-
if(Math.abs(expected - actual) <= tolerance) {
|
237
|
-
return;
|
238
|
-
}
|
239
|
-
failNotEquals(message, expected, actual);
|
240
|
-
}
|
241
|
-
|
242
|
-
|
243
|
-
static private function failSame(message:String):void {
|
244
|
-
var formatted:String = "";
|
245
|
-
if(message != null) {
|
246
|
-
formatted = message + " ";
|
247
|
-
}
|
248
|
-
fail(formatted + "expected not same");
|
249
|
-
}
|
250
|
-
|
251
|
-
static private function failNotSame(message:String, expected:Object, actual:Object):void {
|
252
|
-
var formatted:String = "";
|
253
|
-
if(message != null) {
|
254
|
-
formatted = message + " ";
|
255
|
-
}
|
256
|
-
fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">");
|
257
|
-
}
|
258
|
-
|
259
|
-
static private function failNotEquals(message:String, expected:Object, actual:Object):void {
|
260
|
-
fail(format(message, expected, actual));
|
261
|
-
}
|
262
|
-
|
263
|
-
static private function format(message:String, expected:Object, actual:Object):String {
|
264
|
-
var formatted:String = "";
|
265
|
-
if(message != null) {
|
266
|
-
formatted = message + " ";
|
267
|
-
}
|
268
|
-
return formatted + "expected:<" + expected + "> but was:<" + actual + ">";
|
269
|
-
}
|
270
|
-
}
|
271
|
-
}
|