| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::prove4air; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
1
|
|
|
1
|
|
75914
|
$App::prove4air::VERSION = '0.0013'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Test ActionScript (.as) with prove, Adobe Air, and tap4air |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
644
|
use Path::Class; |
|
|
1
|
|
|
|
|
80226
|
|
|
|
1
|
|
|
|
|
68
|
|
|
11
|
1
|
|
|
1
|
|
7
|
use File::Temp qw/ tempdir /; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
63
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use File::Copy qw/ copy /; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
53
|
|
|
13
|
1
|
|
|
1
|
|
960
|
use IPC::System::Simple(); |
|
|
1
|
|
|
|
|
14279
|
|
|
|
1
|
|
|
|
|
30
|
|
|
14
|
1
|
|
|
1
|
|
1173
|
use Getopt::Long qw/ GetOptions :config pass_through /; |
|
|
1
|
|
|
|
|
10773
|
|
|
|
1
|
|
|
|
|
5
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub run { |
|
17
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
18
|
0
|
|
|
|
|
|
my @arguments = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my ( $build_air, $run_air, $exit ); |
|
21
|
0
|
0
|
|
|
|
|
$build_air = $ENV{ BUILD_AIR } or do { |
|
22
|
0
|
|
|
|
|
|
print STDERR <<_END_; |
|
23
|
|
|
|
|
|
|
*** Missing \$BUILD_AIR, try: |
|
24
|
|
|
|
|
|
|
# BUILD_AIR=\$AIR_SDK/bin/mxmlc -incremental +configname=air -compiler.source-path=src/ -debug |
|
25
|
|
|
|
|
|
|
_END_ |
|
26
|
0
|
|
|
|
|
|
$build_air = ''; |
|
27
|
0
|
|
|
|
|
|
$exit = 1 |
|
28
|
|
|
|
|
|
|
}; |
|
29
|
0
|
0
|
|
|
|
|
$run_air = $ENV{ RUN_AIR } or do { |
|
30
|
0
|
|
|
|
|
|
print STDERR <<_END_; |
|
31
|
|
|
|
|
|
|
*** Missing \$RUN_AIR, try: |
|
32
|
|
|
|
|
|
|
# RUN_AIR=AIR_SDK/bin/adl |
|
33
|
|
|
|
|
|
|
_END_ |
|
34
|
0
|
|
|
|
|
|
$run_air = ''; |
|
35
|
0
|
|
|
|
|
|
$exit = 1 |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if ( $exit ) { |
|
39
|
0
|
|
|
|
|
|
exit 64; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my ( $exec ); |
|
43
|
0
|
0
|
|
|
|
|
$exec = $ENV{TAP_VERSION} ? 1 : 0; |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
0
|
|
|
|
|
|
local @ARGV = @arguments; |
|
|
0
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
GetOptions( exec => \$exec ); |
|
47
|
0
|
|
|
|
|
|
@arguments = @ARGV; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ( $exec ) { |
|
51
|
0
|
|
|
|
|
|
$self->test( $arguments[ 0 ], |
|
52
|
|
|
|
|
|
|
build_air => $build_air, |
|
53
|
|
|
|
|
|
|
run_air => $run_air, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
else { |
|
57
|
0
|
|
|
|
|
|
require App::Prove; |
|
58
|
0
|
|
|
|
|
|
my $prove = App::Prove->new; |
|
59
|
0
|
|
|
|
|
|
$prove->process_args( @arguments ); |
|
60
|
0
|
|
0
|
|
|
|
$prove->{exec} ||= "$0 --exec"; |
|
61
|
0
|
|
0
|
|
|
|
$prove->{extension} ||= '.t.as'; |
|
62
|
0
|
|
|
|
|
|
$prove->run; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub test { |
|
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
68
|
0
|
|
|
|
|
|
my $script = shift; |
|
69
|
0
|
|
|
|
|
|
my %context = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
0
|
|
|
|
die "*** Missing test (.t.as) script" unless defined $script && length $script; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$script = file $script; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my %test; |
|
76
|
0
|
|
|
|
|
|
$test{ dir } = dir( '.t', (join '-', $script->parent->dir_list, $script->basename ) ); |
|
77
|
0
|
|
|
|
|
|
$test{ dir }->mkpath; |
|
78
|
0
|
|
|
|
|
|
$test{ script } = $test{dir}->file( 'test.as' ); |
|
79
|
0
|
|
|
|
|
|
$test{ xml } = $test{dir}->file( 'test.xml' ); |
|
80
|
0
|
|
|
|
|
|
$test{ result } = $test{dir}->file( 'result.tap' ); |
|
81
|
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
my ( @content, @import_content, @test_content ); |
|
83
|
0
|
0
|
0
|
|
|
|
if ( ! -s $test{ script } || $test{ script }->stat->mtime < $script->stat->mtime ) { |
|
84
|
0
|
|
|
|
|
|
@content = $script->slurp; |
|
85
|
0
|
0
|
|
|
|
|
if ( $content[ 0 ] =~ m/^\s*\/\/\s*!(?:tap4air|prove4air)\b/ ) { |
|
86
|
0
|
|
|
|
|
|
my $split = -1; |
|
87
|
0
|
|
|
|
|
|
my $found = 0; |
|
88
|
0
|
|
|
|
|
|
for ( @content ) { |
|
89
|
0
|
|
|
|
|
|
$split += 1; |
|
90
|
0
|
0
|
|
|
|
|
if ( m/^\s*\/\/\s*\-\-\-\s*$/ ) { |
|
91
|
0
|
|
|
|
|
|
$found = 1; |
|
92
|
0
|
|
|
|
|
|
last; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
0
|
|
|
|
|
if ( $found ) { |
|
97
|
0
|
|
|
|
|
|
@import_content = @content[ 1 .. $split - 1 ]; |
|
98
|
0
|
|
|
|
|
|
@test_content = @content[ $split + 1 .. @content - 1 ]; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
else { |
|
101
|
0
|
|
|
|
|
|
@test_content = @content[ 1 .. @content - 1 ]; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $xmlns; |
|
106
|
0
|
|
|
|
|
|
$xmlns = "http://ns.adobe.com/air/application/1.5"; |
|
107
|
0
|
|
|
|
|
|
$xmlns = "http://ns.adobe.com/air/application/2.0"; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
if ( @test_content ) { |
|
110
|
0
|
|
|
|
|
|
$test{ script }->openw->print( <<_END_ ); |
|
111
|
|
|
|
|
|
|
package { |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
import yzzy.tap4air.Test; |
|
114
|
|
|
|
|
|
|
import mx.core.UIComponent; |
|
115
|
|
|
|
|
|
|
import flash.desktop.NativeApplication; |
|
116
|
0
|
|
|
|
|
|
@{[ join '', @import_content ]} |
|
|
0
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
public class test extends UIComponent { |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
public function test() { |
|
121
|
|
|
|
|
|
|
var \$:* = Test.singleton(); |
|
122
|
|
|
|
|
|
|
@{[ join '', @test_content ]} |
|
123
|
|
|
|
|
|
|
\$.exit(); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
_END_ |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
$test{ xml }->openw->print( <<_END_ ); |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
test |
|
133
|
|
|
|
|
|
|
0.0 |
|
134
|
|
|
|
|
|
|
test |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
test.swf |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
_END_ |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
else { |
|
142
|
0
|
|
|
|
|
|
my $xml = $script->parent->file( 'test.xml' ); |
|
143
|
0
|
0
|
|
|
|
|
die "*** Missing .xml file" unless -s $xml; |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
copy "$xml", "$test{ xml }" or die "Failed copy => $xml"; |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
0
|
0
|
|
|
|
if ( ! -s $test{ script } || $test{ script }->stat->mtime < $script->stat->mtime ) { |
|
148
|
0
|
0
|
|
|
|
|
copy "$script", "$test{ script }" or die "Failed copy $script => $test{ script }"; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
IPC::System::Simple::run( "$context{ build_air } $test{ script }" ); |
|
154
|
0
|
|
|
|
|
|
IPC::System::Simple::run( "$context{ run_air } $test{ xml } > $test{ result }" ); |
|
155
|
0
|
|
|
|
|
|
print $test{ result }->slurp; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=pod |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 NAME |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
App::prove4air - Test ActionScript (.as) with prove, Adobe Air, and tap4air |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 VERSION |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
version 0.0013 |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
$ git clone git://github.com/robertkrimen/tap4air.git tap4air |
|
175
|
|
|
|
|
|
|
$ export BUILD_AIR="$AIR_SDK/bin/mxmlc -incremental +configname=air -compiler.source-path=tap4air/src/ -debug" |
|
176
|
|
|
|
|
|
|
$ export RUN_AIR="$AIR_SDK/bin/adl" |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# Run against every .t.as in t/ |
|
179
|
|
|
|
|
|
|
$ prove4air t/ |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
App::prove4air integrates with App::Prove and tap4air to provide prove-like TAP-testing in Adobe Air |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 An example test file |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
// !prove4air |
|
188
|
|
|
|
|
|
|
// --- |
|
189
|
|
|
|
|
|
|
$.ok( 1, 'ok' ); |
|
190
|
|
|
|
|
|
|
$.equal( 1, 1, 'equal' ); |
|
191
|
|
|
|
|
|
|
$.unequal( 1, 2, 'unequal' ); |
|
192
|
|
|
|
|
|
|
$.like( 'Xyzzy', /yzzy/, 'like' ); |
|
193
|
|
|
|
|
|
|
$.unlike( 'Xyzzy', /Y/, 'unlike' ); |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 An example test with an import |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
// !prove4air |
|
198
|
|
|
|
|
|
|
import com.example.Example; |
|
199
|
|
|
|
|
|
|
// --- |
|
200
|
|
|
|
|
|
|
$.ok( 1, 'ok' ); |
|
201
|
|
|
|
|
|
|
$.equal( 1, 1, 'equal' ); |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 A test example in another (more traditional) style |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
package { |
|
206
|
|
|
|
|
|
|
import yzzy.tap4air.Test; |
|
207
|
|
|
|
|
|
|
import mx.core.UIComponent; |
|
208
|
|
|
|
|
|
|
import flash.desktop.NativeApplication; |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
public class test extends UIComponent { |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
public function test() { |
|
213
|
|
|
|
|
|
|
Test.ok( 1, 'ok' ); |
|
214
|
|
|
|
|
|
|
Test.equal( 1, 1, 'equal' ); |
|
215
|
|
|
|
|
|
|
Test.unequal( 1, 2, 'unequal' ); |
|
216
|
|
|
|
|
|
|
Test.like( 'Xyzzy', /yzzy/, 'like' ); |
|
217
|
|
|
|
|
|
|
Test.unlike( 'Xyzzy', /Y/, 'unlike' ); |
|
218
|
|
|
|
|
|
|
Test.exit(); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
L |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
L |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head1 AUTHOR |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Robert Krimen |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Robert Krimen. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
238
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=cut |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
__END__ |