asunit4 4.2.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/Gemfile +5 -0
  2. data/MIT-LICENSE.txt +22 -0
  3. data/README.textile +6 -0
  4. data/air/AIR2Runner.mxml +22 -0
  5. data/air/AIR2RunnerDescriptor.xml +38 -0
  6. data/asunit4.gemspec +20 -0
  7. data/asunit4.rb +16 -0
  8. data/bin/AsUnit-4.1.pre.swc +0 -0
  9. data/bin/AsUnitRunner.swf +0 -0
  10. data/build.xml +46 -0
  11. data/lib/Reflection.swc +0 -0
  12. data/rakefile.rb +169 -0
  13. data/script/generate +21 -0
  14. data/src/asunit/asserts/assertEquals.as +5 -0
  15. data/src/asunit/asserts/assertEqualsArrays.as +5 -0
  16. data/src/asunit/asserts/assertEqualsArraysIgnoringOrder.as +5 -0
  17. data/src/asunit/asserts/assertEqualsFloat.as +5 -0
  18. data/src/asunit/asserts/assertFalse.as +5 -0
  19. data/src/asunit/asserts/assertNotNull.as +5 -0
  20. data/src/asunit/asserts/assertNotSame.as +5 -0
  21. data/src/asunit/asserts/assertNull.as +5 -0
  22. data/src/asunit/asserts/assertSame.as +5 -0
  23. data/src/asunit/asserts/assertThrows.as +5 -0
  24. data/src/asunit/asserts/assertTrue.as +5 -0
  25. data/src/asunit/asserts/fail.as +5 -0
  26. data/src/asunit/core/AsUnitCore.as +177 -0
  27. data/src/asunit/core/FlashBuilderCore.as +22 -0
  28. data/src/asunit/core/FlashDevelopCore.as +21 -0
  29. data/src/asunit/core/TextCore.as +54 -0
  30. data/src/asunit/errors/AbstractError.as +10 -0
  31. data/src/asunit/errors/AssertionFailedError.as +10 -0
  32. data/src/asunit/errors/ClassNotFoundError.as +11 -0
  33. data/src/asunit/errors/InstanceNotFoundError.as +10 -0
  34. data/src/asunit/errors/UnimplementedFeatureError.as +10 -0
  35. data/src/asunit/errors/UsageError.as +11 -0
  36. data/src/asunit/events/TimeoutCommandEvent.as +27 -0
  37. data/src/asunit/framework/Assert.as +408 -0
  38. data/src/asunit/framework/Async.as +138 -0
  39. data/src/asunit/framework/CallbackBridge.as +175 -0
  40. data/src/asunit/framework/Command.as +6 -0
  41. data/src/asunit/framework/ErrorEvent.as +20 -0
  42. data/src/asunit/framework/IAsync.as +21 -0
  43. data/src/asunit/framework/IResult.as +36 -0
  44. data/src/asunit/framework/IRunListener.as +11 -0
  45. data/src/asunit/framework/IRunner.as +15 -0
  46. data/src/asunit/framework/IRunnerFactory.as +9 -0
  47. data/src/asunit/framework/ITestFailure.as +32 -0
  48. data/src/asunit/framework/ITestListener.as +15 -0
  49. data/src/asunit/framework/ITestResult.as +21 -0
  50. data/src/asunit/framework/ITestSuccess.as +22 -0
  51. data/src/asunit/framework/ITestWarning.as +14 -0
  52. data/src/asunit/framework/InjectionDelegate.as +96 -0
  53. data/src/asunit/framework/LegacyTestIterator.as +40 -0
  54. data/src/asunit/framework/MessageBridge.as +24 -0
  55. data/src/asunit/framework/Method.as +80 -0
  56. data/src/asunit/framework/Result.as +181 -0
  57. data/src/asunit/framework/RunnerFactory.as +179 -0
  58. data/src/asunit/framework/SuiteIterator.as +71 -0
  59. data/src/asunit/framework/TestCase.as +106 -0
  60. data/src/asunit/framework/TestFailure.as +65 -0
  61. data/src/asunit/framework/TestIterator.as +282 -0
  62. data/src/asunit/framework/TestObserver.as +12 -0
  63. data/src/asunit/framework/TestSuccess.as +38 -0
  64. data/src/asunit/framework/TestWarning.as +40 -0
  65. data/src/asunit/framework/TimeoutCommand.as +103 -0
  66. data/src/asunit/printers/FlashBuilderPrinter.as +134 -0
  67. data/src/asunit/printers/FlashDevelopPrinter.as +81 -0
  68. data/src/asunit/printers/TextPrinter.as +324 -0
  69. data/src/asunit/runners/LegacyRunner.as +13 -0
  70. data/src/asunit/runners/SuiteRunner.as +125 -0
  71. data/src/asunit/runners/TestRunner.as +403 -0
  72. data/src/asunit/util/ArrayIterator.as +30 -0
  73. data/src/asunit/util/Iterator.as +10 -0
  74. data/test/AllTests.as +73 -0
  75. data/test/AsUnitRunner.as +15 -0
  76. data/test/Flex3Runner.mxml +24 -0
  77. data/test/Flex4Runner.mxml +27 -0
  78. data/test/asunit/core/AsUnitCoreTest.as +97 -0
  79. data/test/asunit/framework/AssertEqualsArraysIgnoringOrderTest.as +88 -0
  80. data/test/asunit/framework/AssertEqualsArraysTest.as +102 -0
  81. data/test/asunit/framework/AssertTest.as +184 -0
  82. data/test/asunit/framework/AssertThrowsTest.as +42 -0
  83. data/test/asunit/framework/AsyncMethodTest.as +69 -0
  84. data/test/asunit/framework/AsyncTest.as +104 -0
  85. data/test/asunit/framework/CallbackBridgeTest.as +73 -0
  86. data/test/asunit/framework/InjectionDelegateTest.as +79 -0
  87. data/test/asunit/framework/MockData.xml +8 -0
  88. data/test/asunit/framework/NestedSuiteIteratorTest.as +59 -0
  89. data/test/asunit/framework/ProceedOnEventTest.as +109 -0
  90. data/test/asunit/framework/ResultTest.as +92 -0
  91. data/test/asunit/framework/RunnerFactoryTest.as +54 -0
  92. data/test/asunit/framework/SuiteIteratorTest.as +67 -0
  93. data/test/asunit/framework/TestCaseMock.as +24 -0
  94. data/test/asunit/framework/TestIteratorIgnoredMethodTest.as +62 -0
  95. data/test/asunit/framework/TestIteratorMethodByNameTest.as +50 -0
  96. data/test/asunit/framework/TestIteratorMultiMethodTest.as +186 -0
  97. data/test/asunit/framework/TestIteratorOrderedTestMethodTest.as +57 -0
  98. data/test/asunit/framework/TestIteratorSingleMethodTest.as +56 -0
  99. data/test/asunit/framework/VisualTestCaseTest.as +43 -0
  100. data/test/asunit/framework/assertAssertionFailed.as +19 -0
  101. data/test/asunit/printers/TextPrinterTest.as +122 -0
  102. data/test/asunit/runners/LegacyRunnerTest.as +40 -0
  103. data/test/asunit/runners/SuiteRunnerTest.as +40 -0
  104. data/test/asunit/runners/TestRunnerAsyncMethodTest.as +107 -0
  105. data/test/asunit/runners/TestRunnerErrorMethodTest.as +56 -0
  106. data/test/asunit/runners/TestRunnerExpectsErrorTest.as +98 -0
  107. data/test/asunit/runners/TestRunnerIgnoredMethodTest.as +42 -0
  108. data/test/asunit/runners/TestRunnerTest.as +171 -0
  109. data/test/asunit/support/AnnotatedSubClass.as +18 -0
  110. data/test/asunit/support/AnnotatedSuperClass.as +15 -0
  111. data/test/asunit/support/CustomParameters.as +13 -0
  112. data/test/asunit/support/CustomTestRunner.as +22 -0
  113. data/test/asunit/support/DoubleFailSuite.as +8 -0
  114. data/test/asunit/support/DoubleNestedSuite.as +14 -0
  115. data/test/asunit/support/ErrorInMethod.as +11 -0
  116. data/test/asunit/support/FailAssertEquals.as +29 -0
  117. data/test/asunit/support/FailAssertTrue.as +28 -0
  118. data/test/asunit/support/FakeObserver.as +42 -0
  119. data/test/asunit/support/FakeRunner.as +32 -0
  120. data/test/asunit/support/IgnoredMethod.as +26 -0
  121. data/test/asunit/support/InjectTimeoutOnAsync.as +14 -0
  122. data/test/asunit/support/InjectionFailure.as +18 -0
  123. data/test/asunit/support/InjectionVerification.as +69 -0
  124. data/test/asunit/support/LegacyTestCase.as +38 -0
  125. data/test/asunit/support/MultiMethod.as +77 -0
  126. data/test/asunit/support/OrderedTestMethod.as +36 -0
  127. data/test/asunit/support/RunWithButNoType.as +14 -0
  128. data/test/asunit/support/RunWithSuiteButNoType.as +11 -0
  129. data/test/asunit/support/SingleErrorSuite.as +7 -0
  130. data/test/asunit/support/SingleSuccessSuite.as +7 -0
  131. data/test/asunit/support/SucceedAssertTrue.as +31 -0
  132. data/test/asunit/support/SuiteOfTwoSuites.as +8 -0
  133. data/test/asunit/support/SuiteWithCustomRunner.as +12 -0
  134. data/test/asunit/support/SuiteWithOneCustomChildSuite.as +10 -0
  135. data/test/asunit/support/TestForFakeRunner.as +14 -0
  136. data/test/asunit/util/ArrayIteratorTest.as +65 -0
  137. data/vendor/as3reflection/README +7 -0
  138. data/vendor/as3reflection/p2/reflect/Reflection.as +417 -0
  139. data/vendor/as3reflection/p2/reflect/ReflectionAccessor.as +14 -0
  140. data/vendor/as3reflection/p2/reflect/ReflectionBase.as +52 -0
  141. data/vendor/as3reflection/p2/reflect/ReflectionMember.as +16 -0
  142. data/vendor/as3reflection/p2/reflect/ReflectionMetaData.as +69 -0
  143. data/vendor/as3reflection/p2/reflect/ReflectionMethod.as +36 -0
  144. data/vendor/as3reflection/p2/reflect/ReflectionMethodParameter.as +19 -0
  145. data/vendor/as3reflection/p2/reflect/ReflectionVariable.as +15 -0
  146. data/vendor/as3reflection/p2/reflect/findFirst.as +14 -0
  147. data/vendor/generators/suite/USAGE +0 -0
  148. data/vendor/generators/suite/suite_generator.rb +17 -0
  149. data/vendor/generators/suite/templates/TestSuite.as +17 -0
  150. metadata +216 -0
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'sprout'
4
+ #gem 'as3', '>= 1.0.pre'
5
+
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) <year> <copyright holders>
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,6 @@
1
+
2
+ h1. AsUnit 4.x
3
+
4
+ This build of the AsUnit test framework works with Flash Players 9, 10 and Adobe AIR and any version of the Flex framework.
5
+
6
+
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <mx:WindowedApplication
3
+ xmlns:mx="http://www.adobe.com/2006/mxml"
4
+ layout="absolute"
5
+ backgroundColor="#333333"
6
+ backgroundImage=""
7
+ creationComplete="creationCompleteHandler(event)"
8
+ >
9
+ <mx:Script>
10
+ <![CDATA[
11
+ import asunit.core.TextCore;
12
+
13
+ private var core:TextCore;
14
+
15
+ private function creationCompleteHandler(event:Event):void {
16
+ core = new TextCore();
17
+ core.start(AllTests, null, visualContext);
18
+ }
19
+ ]]>
20
+ </mx:Script>
21
+ <mx:UIComponent id="visualContext" width="100%" height="100%" />
22
+ </mx:WindowedApplication>
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <application xmlns="http://ns.adobe.com/air/application/1.5">
3
+ <id>AsUnitAIRRunner</id>
4
+ <version>2.0</version>
5
+ <filename>AsUnitAIRRunner</filename>
6
+ <name>AsUnit AIR Runner</name>
7
+ <description>
8
+ <text xml:lang="en">AsUnit AIR Runner</text>
9
+ </description>
10
+ <copyright>Copyright (c) 2010 Example Co.</copyright>
11
+ <initialWindow>
12
+ <title>AsUnit</title>
13
+ <content>
14
+ bin/AIR2AsUnitRunner.swf
15
+ </content>
16
+ <systemChrome>standard</systemChrome>
17
+ <transparent>false</transparent>
18
+ <visible>true</visible>
19
+ <minimizable>true</minimizable>
20
+ <maximizable>true</maximizable>
21
+ <resizable>true</resizable>
22
+ <width>900</width>
23
+ <height>500</height>
24
+ <minSize>640 480</minSize>
25
+ <maxSize>1280 960</maxSize>
26
+ </initialWindow>
27
+ <installFolder>AsUnit/AIR2Runner</installFolder>
28
+ <programMenuFolder>AsUnit/AIR2Runner</programMenuFolder>
29
+ <icon>
30
+ <image16x16>icons/smallIcon.png</image16x16>
31
+ <image32x32>icons/mediumIcon.png</image32x32>
32
+ <image48x48>icons/bigIcon.png</image48x48>
33
+ <image128x128>icons/biggestIcon.png</image128x128>
34
+ </icon>
35
+ <customUpdateUI>true</customUpdateUI>
36
+ <allowBrowserInvocation>false</allowBrowserInvocation>
37
+ </application>
38
+
data/asunit4.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/asunit4'
4
+ require 'rake'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = AsUnit::NAME
8
+ s.version = AsUnit::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Luke Bayes", "Ali Mills", "Robert Penner"]
11
+ s.email = ["asunit-users@lists.sourceforge.net"]
12
+ s.homepage = "http://asunit.org"
13
+ s.summary = "The fastest and most flexible ActionScript unit test framework"
14
+ s.description = "AsUnit is the only ActionScript unit test framework that support every development and runtime environment that is currently available. This includes Flex 2, 3, 4, AIR 1 and 2, Flash Lite, and of course the Flash Authoring tool"
15
+ s.rubyforge_project = "sprout"
16
+ s.required_rubygems_version = ">= 1.3.6"
17
+ s.require_path = "."
18
+ s.files = FileList["**/*"].exclude /docs|.DS_Store|generated|.svn|.git|airglobal.swc|airframework.swc/
19
+ end
20
+
data/asunit4.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'sprout'
2
+
3
+ module AsUnit
4
+ NAME = 'asunit4'
5
+ VERSION = '4.2.1.pre'
6
+ end
7
+
8
+ Sprout::Specification.new do |s|
9
+ s.name = AsUnit::NAME
10
+ s.version = AsUnit::VERSION
11
+ s.add_file_target do |f|
12
+ f.add_library :swc, 'bin/AsUnit-4.1.pre.swc'
13
+ f.add_library :src, ['src', 'vendor/as3reflection']
14
+ end
15
+ end
16
+
Binary file
Binary file
data/build.xml ADDED
@@ -0,0 +1,46 @@
1
+ <project name="AsUnit" default="swc">
2
+
3
+ <!-- Set up a prefix for all environment variables. -->
4
+ <property environment="env."/>
5
+ <fail unless="env.FLEX_HOME" message="FLEX_HOME needs to be defined as an environment variable or in the Ant build." />
6
+ <!-- Copy Flex SDK location from environment variable. This can be set manually as well. -->
7
+ <property name="FLEX_HOME" value="${env.FLEX_HOME}" />
8
+
9
+ <!-- project paths -->
10
+ <property name="root.dir" location="."/>
11
+ <property name="src.dir" location="${root.dir}/src"/>
12
+ <property name="vendor.dir" location="${root.dir}/vendor"/>
13
+ <property name="test.dir" location="${root.dir}/test"/>
14
+ <property name="libs.dir" location="${root.dir}/lib"/>
15
+ <property name="output.dir" location="${root.dir}/bin"/>
16
+ <property name="output.swc" location="${output.dir}/asunit.swc"/>
17
+
18
+ <target name="swc" depends="" description="Compile AS3 code into a SWC">
19
+ <echo>Using Flex SDK at: ${FLEX_HOME}</echo>
20
+
21
+ <java jar="${FLEX_HOME}/lib/compc.jar" dir="." fork="true" failonerror="true">
22
+ <arg value="+flexlib=${FLEX_HOME}/frameworks" />
23
+ <arg value="-incremental=true" />
24
+
25
+ <arg value="-source-path+=${src.dir}" />
26
+ <arg value="-source-path+=${vendor.dir}/as3reflection" />
27
+
28
+ <!-- Include all classes in this path. -->
29
+ <arg value="-include-sources=${src.dir}" />
30
+
31
+ <!-- Link in classes from swc library (only those used). -->
32
+ <!--<arg value="-library-path+=${libs.dir}" />-->
33
+
34
+ <!-- Exclude Flex and AIR framework classes from swc. -->
35
+ <arg value="-external-library-path+=${FLEX_HOME}/frameworks/libs" />
36
+ <!--
37
+ <arg value="-external-library-path+=${libs.dir}/airframework.swc" />
38
+ <arg value="-external-library-path+=${libs.dir}/airglobal.swc" />
39
+ -->
40
+
41
+ <arg value="-output=${output.swc}" />
42
+ </java>
43
+
44
+ </target>
45
+
46
+ </project>
Binary file
data/rakefile.rb ADDED
@@ -0,0 +1,169 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'sprout'
5
+ sprout 'as3'
6
+
7
+ require File.dirname(__FILE__) + '/asunit4'
8
+
9
+ test_input = "AsUnitRunner"
10
+
11
+ ##########################################
12
+ # To build from this file, install Ruby (http://ruby-lang.org)
13
+ # and RubyGems (http://rubygems.org/), then run:
14
+ # gem install rake
15
+ # gem install sprout
16
+ # rake
17
+ # This should walk you through the installation
18
+ # of required gems, compilers and vms
19
+
20
+ ##########################################
21
+ # Define the known Meta Data tags:
22
+
23
+ def apply_as3_meta_data_args(t)
24
+ [
25
+ "After",
26
+ "AfterClass",
27
+ "Before",
28
+ "BeforeClass",
29
+ "Ignore",
30
+ "Inject",
31
+ "RunWith",
32
+ "Suite",
33
+ "Test"
34
+ ].each do |arg|
35
+ t.keep_as3_metadata << arg
36
+ end
37
+ end
38
+
39
+ ##########################################
40
+ # Configure a Test Build:
41
+
42
+ def configure_test_task(t)
43
+ t.default_size = '1000 600'
44
+ t.source_path << 'src'
45
+ t.library_path << 'lib/Reflection.swc'
46
+ t.debug = true
47
+ t.static_link_runtime_shared_libraries = true
48
+ apply_as3_meta_data_args(t)
49
+ end
50
+
51
+ ##########################################
52
+ # Compile the Test Harness(es)
53
+
54
+ desc "Compile the ActionScript test harness"
55
+ mxmlc "bin/#{test_input}.swf" do |t|
56
+ t.input = "test/AsUnitRunner.as"
57
+ t.gem_name = 'sprout-flex4sdk-tool'
58
+ configure_test_task t
59
+ end
60
+
61
+ desc "Compile the Flex 3 test harness"
62
+ mxmlc "bin/Flex3#{test_input}.swf" do |t|
63
+ t.input = "test/Flex3Runner.mxml"
64
+ t.gem_name = 'sprout-flex3sdk-tool'
65
+ configure_test_task t
66
+ end
67
+
68
+ desc "Compile the Flex 4 test harness"
69
+ mxmlc "bin/Flex4#{test_input}.swf" do |t|
70
+ t.input = "test/Flex4Runner.mxml"
71
+ t.gem_name = 'sprout-flex4sdk-tool'
72
+ configure_test_task t
73
+ end
74
+
75
+ desc "Compile the AIR 2 test harness"
76
+ mxmlc "bin/AIR2#{test_input}.swf" do |t|
77
+ t.input = "air/AIR2Runner.mxml"
78
+ t.gem_name = 'sprout-flex4sdk-tool'
79
+ t.source_path << 'air'
80
+ t.source_path << 'test'
81
+ t.library_path << 'lib/airglobal.swc'
82
+ t.library_path << 'lib/airframework.swc'
83
+ configure_test_task t
84
+ end
85
+
86
+ ##########################################
87
+ # Launch the selected Test Harness
88
+
89
+ desc "Compile and run the test harness"
90
+ flashplayer :test_as3 => "bin/#{test_input}.swf"
91
+
92
+ desc "Compile and run the Flex 3 Harness"
93
+ flashplayer :test_flex3 => "bin/Flex3#{test_input}.swf"
94
+
95
+ desc "Compile and run the Flex 4 Harness"
96
+ flashplayer :test_flex4 => "bin/Flex4#{test_input}.swf"
97
+
98
+ desc "Compile and run the AIR 2 Harness"
99
+ adl :test_air2 => "bin/AIR2#{test_input}.swf" do |t|
100
+ t.gem_name = "sprout-flex4sdk-tool"
101
+ t.root_directory = Dir.pwd
102
+ t.application_descriptor = "air/AIR2RunnerDescriptor.xml"
103
+ end
104
+
105
+ desc "Compile and run the ActionScript 3 test harness"
106
+ task :test => :test_as3
107
+
108
+ desc "Compile and run test harnesses for all supported environments"
109
+ task :test_all => [:test_as3, :test_flex3, :test_flex4, :test_air2]
110
+
111
+ ##########################################
112
+ # Compile the SWC
113
+
114
+ def configure_swc_task(t)
115
+ t.gem_name = 'sprout-flex4sdk-tool'
116
+ t.include_sources << 'src'
117
+ t.source_path << 'src'
118
+ t.library_path << 'lib/Reflection.swc'
119
+ t.static_link_runtime_shared_libraries = true
120
+ apply_as3_meta_data_args(t)
121
+ end
122
+
123
+ compc "bin/AsUnit-#{AsUnit::VERSION}.swc" do |t|
124
+ configure_swc_task t
125
+ end
126
+
127
+ task :swc => "bin/AsUnit-#{AsUnit::VERSION}.swc"
128
+
129
+ ##########################################
130
+ # Generate documentation
131
+
132
+ desc "Generate documentation"
133
+ asdoc 'doc' do |t|
134
+ t.appended_args = '-examples-path=examples'
135
+ t.source_path << 'src'
136
+ t.doc_classes << 'AsUnit'
137
+ t.library_path << 'lib/Reflection.swc'
138
+
139
+ # Not on asdoc?
140
+ #t.static_link_runtime_shared_libraries = true
141
+ end
142
+
143
+ ##########################################
144
+ # Package framework ZIPs
145
+
146
+
147
+ desc "Create the gem package"
148
+ task :package_gem => :swc do
149
+ sh "gem build asunit4.gemspec"
150
+ end
151
+
152
+ CLEAN.add '*.gem'
153
+
154
+ archive = "AsUnit-#{AsUnit::VERSION}.zip"
155
+
156
+ zip archive do |t|
157
+ t.input = './*'
158
+ end
159
+
160
+ CLEAN.add '*.zip'
161
+
162
+ desc "Create zip archives"
163
+ task :zip => [:clean, :test_all, archive]
164
+
165
+ ##########################################
166
+ # Set up task wrappers
167
+
168
+ task :default => :test
169
+
data/script/generate ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'sprout'
4
+ sprout 'sprout-as3-bundle'
5
+
6
+ # Add a class name if TestSuites were generated
7
+ if(ARGV.size == 1 && ARGV[0] == 'suite')
8
+ ARGV << 'AllTests'
9
+ end
10
+
11
+ # Insert class type by default
12
+ if(ARGV.size == 1)
13
+ ARGV.unshift('class')
14
+ end
15
+
16
+ # Execute generators like this:
17
+ # script/generate class utils.MathUtil
18
+ # script/generate suite
19
+ # script/generate test utils.MathUtilTest
20
+
21
+ Sprout::Sprout.generate('as3', ARGV.shift, ARGV, File.dirname(File.dirname(__FILE__)))
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public const assertEquals:Function = Assert.assertEquals;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertEqualsArrays:Function = Assert.assertEqualsArrays;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertEqualsArraysIgnoringOrder:Function = Assert.assertEqualsArraysIgnoringOrder;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertEqualsFloat:Function = Assert.assertEqualsFloat;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertFalse:Function = Assert.assertFalse;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertNotNull:Function = Assert.assertNotNull;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertNotSame:Function = Assert.assertNotSame;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertNull:Function = Assert.assertNull;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertSame:Function = Assert.assertSame;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertThrows:Function = Assert.assertThrows;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public var assertTrue:Function = Assert.assertTrue;
5
+ }
@@ -0,0 +1,5 @@
1
+ package asunit.asserts {
2
+ import asunit.framework.Assert;
3
+
4
+ public const fail:Function = Assert.fail;
5
+ }
@@ -0,0 +1,177 @@
1
+ package asunit.core {
2
+
3
+ import asunit.framework.IResult;
4
+ import asunit.framework.IRunListener;
5
+ import asunit.framework.IRunner;
6
+ import asunit.framework.Result;
7
+ import asunit.framework.RunnerFactory;
8
+ import asunit.framework.TestObserver;
9
+ import asunit.runners.LegacyRunner;
10
+
11
+ import flash.display.DisplayObjectContainer;
12
+ import flash.events.Event;
13
+ import flash.events.EventDispatcher;
14
+ import flash.events.IEventDispatcher;
15
+ import asunit.framework.InjectionDelegate;
16
+ import asunit.framework.CallbackBridge;
17
+
18
+ public class AsUnitCore implements IEventDispatcher {
19
+
20
+ [Inject]
21
+ public var bridge:CallbackBridge;
22
+
23
+ protected var bridgeInjector:InjectionDelegate;
24
+ protected var dispatcher:IEventDispatcher;
25
+ protected var legacyRunnerReference:LegacyRunner;
26
+ protected var observers:Array;
27
+ protected var runner:IRunner;
28
+ protected var _visualContext:DisplayObjectContainer;
29
+
30
+ public function AsUnitCore() {
31
+ super();
32
+ initializeBridgeInjector();
33
+ initializeDispatcher();
34
+ initializeObservers();
35
+ initialize();
36
+ }
37
+
38
+ protected function initializeBridgeInjector():void {
39
+ bridgeInjector = new InjectionDelegate();
40
+ }
41
+
42
+ protected function initializeDispatcher():void {
43
+ dispatcher = new EventDispatcher();
44
+ }
45
+
46
+ /**
47
+ * Template method for subclasses to override,
48
+ * and use to create default observers.
49
+ */
50
+ protected function initializeObservers():void {
51
+ }
52
+
53
+ /**
54
+ * A template method that concrete sub classes
55
+ * can override to auto-configure their own
56
+ * observers or other settings before start
57
+ * is called.
58
+ */
59
+ protected function initialize():void {
60
+ }
61
+
62
+ /**
63
+ * Add a new Observer instance to this test run.
64
+ *
65
+ * The TestObserver interface is simply a marker interface
66
+ * that indicates your observer has at least one [Inject]
67
+ * variable where a bridge will be injected.
68
+ *
69
+ * Concrete observers are coupled to concrete runners
70
+ * by using [Inject] metadata and Bridges for message passing.
71
+ *
72
+ * The primary TestRunner, CallbackBridge and TextPrinter
73
+ * are good examples of how to build this relationship.
74
+ *
75
+ * To use a different TestRunner on a Suite or Test, simply set:
76
+ *
77
+ * [RunWith("fully.qualified.ClassName")]
78
+ *
79
+ * If you call RunWith on a Suite, it should change the
80
+ * default TestRunner for all subsequent tests.
81
+ *
82
+ * A Printer can inject any number of concrete Bridges,
83
+ * so you can still subscribe to the standard test execution
84
+ * callbacks, while also handling some new functionality
85
+ * provided by a couple of concrete runners.
86
+ *
87
+ */
88
+ public function addObserver(observer:TestObserver):void {
89
+ bridgeInjector.updateInjectionPoints(observer, InjectionDelegate.THROW_ERROR_ON_MISSING_INJECTION_POINT);
90
+ }
91
+
92
+ /**
93
+ * Set the visual context that will parent all injected
94
+ * visual entities.
95
+ *
96
+ * This DisplayObjectContainer should be provided and
97
+ * attached to the Display List before start is called if
98
+ * you have any tests that [Inject] DisplayObject instances.
99
+ *
100
+ */
101
+ public function set visualContext(context:DisplayObjectContainer):void {
102
+ _visualContext = context;
103
+ }
104
+
105
+ public function get visualContext():DisplayObjectContainer {
106
+ return _visualContext;
107
+ }
108
+
109
+ /**
110
+ * Start the test run using the provided Test or Suite class and
111
+ * optional test method name (String).
112
+ *
113
+ * If a test method name is provided, all [BeforeClass], and [Before]
114
+ * methods will be called, then the test method will be called,
115
+ * but no [After] or [AfterClass] methods will be called.
116
+ *
117
+ * This gives you the ability to see visual entities in isolation
118
+ * while test-driving their development.
119
+ */
120
+ public function start(testOrSuite:Class, testMethodName:String=null, visualContext:DisplayObjectContainer=null):void {
121
+
122
+ // Will instantiate a new CallbackBridge:
123
+ // and set it on this instance - but share it
124
+ // with any Runners or Observers that also
125
+ // use the CallbackBridge.
126
+ bridgeInjector.updateInjectionPoints(this, InjectionDelegate.THROW_ERROR_ON_MISSING_INJECTION_POINT);
127
+ // Must use the accessor, not the _ value:
128
+ if(visualContext) this.visualContext = visualContext;
129
+
130
+ var factory:RunnerFactory = new RunnerFactory();
131
+ factory.injector = bridgeInjector;
132
+ runner = factory.runnerFor(testOrSuite);
133
+ runner.addEventListener(Event.COMPLETE, runCompleteHandler);
134
+ bridge.onRunStarted();
135
+ runner.run(testOrSuite, testMethodName, this.visualContext);
136
+ }
137
+
138
+ private function runCompleteHandler(event:Event):void {
139
+ runner.removeEventListener(Event.COMPLETE, onRunCompleted);
140
+ bridge.onRunCompleted(bridge);
141
+ onRunCompleted();
142
+ dispatchEvent(event);
143
+ }
144
+
145
+
146
+ /**
147
+ * Template method that subclasses can override to perform some
148
+ * operation when the run is complete.
149
+ */
150
+ protected function onRunCompleted():void {
151
+ }
152
+
153
+ // BEGIN: Implement the IEvent Dispatcher Interface:
154
+
155
+ public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void {
156
+ dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
157
+ }
158
+
159
+ public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void {
160
+ dispatcher.removeEventListener(type, listener, useCapture);
161
+ }
162
+
163
+ public function dispatchEvent(event:Event):Boolean {
164
+ return dispatcher.dispatchEvent(event);
165
+ }
166
+
167
+ public function hasEventListener(type:String):Boolean {
168
+ return dispatcher.hasEventListener(type);
169
+ }
170
+
171
+ public function willTrigger(type:String):Boolean {
172
+ return dispatcher.willTrigger(type);
173
+ }
174
+
175
+ // END: Implement the IEvent Dispatcher Interface:
176
+ }
177
+ }
@@ -0,0 +1,22 @@
1
+ package asunit.core {
2
+
3
+ import asunit.printers.FlashBuilderPrinter;
4
+
5
+ import flash.system.fscommand;
6
+
7
+ public class FlashBuilderCore extends TextCore {
8
+
9
+ override protected function initializeObservers():void {
10
+ super.initializeObservers();
11
+
12
+ var projectName:String = 'SomeProject';
13
+ addObserver(new FlashBuilderPrinter(projectName));
14
+ }
15
+ override protected function onRunCompleted():void {
16
+ super.onRunCompleted();
17
+ fscommand('quit'); // fails silently if not in debug player
18
+ //System.exit(0); // generates SecurityError if not in debug player
19
+ }
20
+ }
21
+ }
22
+