@@ -9,16 +9,16 @@ use Mojo::File qw(path tempdir);
99
1010subtest ' File asset' => sub {
1111 my $file = Mojo::Asset::File-> new;
12- is $file -> size, 0, ' file is empty' ;
12+ is $file -> size, 0, ' file is empty' ;
1313 is $file -> mtime, (stat $file -> handle)[9], ' right mtime' ;
14- is $file -> slurp, ' ' , ' file is empty' ;
14+ is $file -> slurp, ' ' , ' file is empty' ;
1515 $file -> add_chunk(' abc' );
1616 is $file -> contains(' abc' ), 0, ' "abc" at position 0' ;
1717 is $file -> contains(' bc' ), 1, ' "bc" at position 1' ;
1818 is $file -> contains(' db' ), -1, ' does not contain "db"' ;
19- is $file -> size, 3, ' right size' ;
19+ is $file -> size, 3, ' right size' ;
2020 is $file -> mtime, (stat $file -> handle)[9], ' right mtime' ;
21- is $file -> to_file, $file , ' same object' ;
21+ is $file -> to_file, $file , ' same object' ;
2222
2323 my $path = $file -> path;
2424 ok -e $path , ' temporary file exists' ;
@@ -29,12 +29,12 @@ subtest 'File asset' => sub {
2929subtest ' Memory asset' => sub {
3030 my $mem = Mojo::Asset::Memory-> new;
3131 $mem -> add_chunk(' abc' );
32- is $mem -> contains(' abc' ), 0, ' "abc" at position 0' ;
33- is $mem -> contains(' bc' ), 1, ' "bc" at position 1' ;
34- is $mem -> contains(' db' ), -1, ' does not contain "db"' ;
35- is $mem -> size, 3, ' right size' ;
36- is $mem -> mtime, $^T, ' right mtime' ;
37- is $mem -> mtime, Mojo::Asset::Memory-> new-> mtime, ' same mtime' ;
32+ is $mem -> contains(' abc' ), 0, ' "abc" at position 0' ;
33+ is $mem -> contains(' bc' ), 1, ' "bc" at position 1' ;
34+ is $mem -> contains(' db' ), -1, ' does not contain "db"' ;
35+ is $mem -> size, 3, ' right size' ;
36+ is $mem -> mtime, $^T, ' right mtime' ;
37+ is $mem -> mtime, Mojo::Asset::Memory-> new-> mtime, ' same mtime' ;
3838 my $mtime = $mem -> mtime;
3939 is $mem -> mtime($mtime + 23)-> mtime, $mtime + 23, ' right mtime' ;
4040};
@@ -53,17 +53,17 @@ subtest 'Asset upgrade from memory to file' => sub {
5353
5454subtest ' Empty file asset' => sub {
5555 my $file = Mojo::Asset::File-> new;
56- is $file -> size, 0, ' asset is empty' ;
57- is $file -> get_chunk(0), ' ' , ' no content' ;
58- is $file -> slurp, ' ' , ' no content' ;
56+ is $file -> size, 0, ' asset is empty' ;
57+ is $file -> get_chunk(0), ' ' , ' no content' ;
58+ is $file -> slurp, ' ' , ' no content' ;
5959 is $file -> contains(' a' ), -1, ' does not contain "a"' ;
6060};
6161
6262subtest ' Empty memory asset' => sub {
6363 my $mem = Mojo::Asset::Memory-> new;
64- is $mem -> size, 0, ' asset is empty' ;
64+ is $mem -> size, 0, ' asset is empty' ;
6565 is $mem -> get_chunk(0), ' ' , ' no content' ;
66- is $mem -> slurp, ' ' , ' no content' ;
66+ is $mem -> slurp, ' ' , ' no content' ;
6767 ok !$mem -> is_range, ' no range' ;
6868 is $mem -> contains(' a' ), -1, ' does not contain "a"' ;
6969};
@@ -100,10 +100,10 @@ subtest 'File asset range support (ab[cdefghi]jk)' => sub {
100100 is $file -> get_chunk(0), ' cdefghi' , ' chunk from position 0' ;
101101 is $file -> get_chunk(1), ' defghi' , ' chunk from position 1' ;
102102 is $file -> get_chunk(5), ' hi' , ' chunk from position 5' ;
103- is $file -> get_chunk(0, 2), ' cd' , ' chunk from position 0 (2 bytes)' ;
104- is $file -> get_chunk(1, 3), ' def' , ' chunk from position 1 (3 bytes)' ;
105- is $file -> get_chunk(5, 1), ' h' , ' chunk from position 5 (1 byte)' ;
106- is $file -> get_chunk(5, 3), ' hi' , ' chunk from position 5 (2 byte)' ;
103+ is $file -> get_chunk(0, 2), ' cd' , ' chunk from position 0 (2 bytes)' ;
104+ is $file -> get_chunk(1, 3), ' def' , ' chunk from position 1 (3 bytes)' ;
105+ is $file -> get_chunk(5, 1), ' h' , ' chunk from position 5 (1 byte)' ;
106+ is $file -> get_chunk(5, 3), ' hi' , ' chunk from position 5 (2 byte)' ;
107107};
108108
109109subtest ' Memory asset range support (ab[cdefghi]jk)' => sub {
@@ -119,10 +119,10 @@ subtest 'Memory asset range support (ab[cdefghi]jk)' => sub {
119119 is $mem -> get_chunk(0), ' cdefghi' , ' chunk from position 0' ;
120120 is $mem -> get_chunk(1), ' defghi' , ' chunk from position 1' ;
121121 is $mem -> get_chunk(5), ' hi' , ' chunk from position 5' ;
122- is $mem -> get_chunk(0, 2), ' cd' , ' chunk from position 0 (2 bytes)' ;
123- is $mem -> get_chunk(1, 3), ' def' , ' chunk from position 1 (3 bytes)' ;
124- is $mem -> get_chunk(5, 1), ' h' , ' chunk from position 5 (1 byte)' ;
125- is $mem -> get_chunk(5, 3), ' hi' , ' chunk from position 5 (2 byte)' ;
122+ is $mem -> get_chunk(0, 2), ' cd' , ' chunk from position 0 (2 bytes)' ;
123+ is $mem -> get_chunk(1, 3), ' def' , ' chunk from position 1 (3 bytes)' ;
124+ is $mem -> get_chunk(5, 1), ' h' , ' chunk from position 5 (1 byte)' ;
125+ is $mem -> get_chunk(5, 3), ' hi' , ' chunk from position 5 (2 byte)' ;
126126};
127127
128128subtest ' Huge file asset' => sub {
@@ -132,16 +132,16 @@ subtest 'Huge file asset' => sub {
132132 $file -> add_chunk(' b' );
133133 $file -> add_chunk(' c' x 131072 );
134134 $file -> add_chunk(' ddd' );
135- is $file -> contains(' a' ), 0, ' "a" at position 0' ;
136- is $file -> contains(' b' ), 131072, ' "b" at position 131072' ;
137- is $file -> contains(' c' ), 131073, ' "c" at position 131073' ;
138- is $file -> contains(' abc' ), 131071, ' "abc" at position 131071' ;
139- is $file -> contains(' ccdd' ), 262143, ' "ccdd" at position 262143' ;
140- is $file -> contains(' dd' ), 262145, ' "dd" at position 262145' ;
141- is $file -> contains(' ddd' ), 262145, ' "ddd" at position 262145' ;
142- is $file -> contains(' e' ), -1, ' does not contain "e"' ;
143- is $file -> contains(' a' x 131072 ), 0, ' "a" x 131072 at position 0' ;
144- is $file -> contains(' c' x 131072 ), 131073, ' "c" x 131072 at position 131073' ;
135+ is $file -> contains(' a' ), 0, ' "a" at position 0' ;
136+ is $file -> contains(' b' ), 131072, ' "b" at position 131072' ;
137+ is $file -> contains(' c' ), 131073, ' "c" at position 131073' ;
138+ is $file -> contains(' abc' ), 131071, ' "abc" at position 131071' ;
139+ is $file -> contains(' ccdd' ), 262143, ' "ccdd" at position 262143' ;
140+ is $file -> contains(' dd' ), 262145, ' "dd" at position 262145' ;
141+ is $file -> contains(' ddd' ), 262145, ' "ddd" at position 262145' ;
142+ is $file -> contains(' e' ), -1, ' does not contain "e"' ;
143+ is $file -> contains(' a' x 131072 ), 0, ' "a" x 131072 at position 0' ;
144+ is $file -> contains(' c' x 131072 ), 131073, ' "c" x 131072 at position 131073' ;
145145 is $file -> contains(' b' . (' c' x 131072 ) . " ddd" ), 131072, ' "b" . ("c" x 131072) . "ddd" at position 131072' ;
146146};
147147
@@ -151,14 +151,14 @@ subtest 'Huge file asset with range' => sub {
151151 $file -> add_chunk(' b' );
152152 $file -> add_chunk(' c' x 131072 );
153153 $file -> add_chunk(' ddd' );
154- is $file -> contains(' a' ), 0, ' "a" at position 0' ;
155- is $file -> contains(' b' ), 131071, ' "b" at position 131071' ;
156- is $file -> contains(' c' ), 131072, ' "c" at position 131072' ;
157- is $file -> contains(' abc' ), 131070, ' "abc" at position 131070' ;
158- is $file -> contains(' ccdd' ), 262142, ' "ccdd" at position 262142' ;
159- is $file -> contains(' dd' ), 262144, ' "dd" at position 262144' ;
160- is $file -> contains(' ddd' ), -1, ' does not contain "ddd"' ;
161- is $file -> contains(' b' . (' c' x 131072 ) . ' ddd' ), -1, ' does not contain "b" . ("c" x 131072) . "ddd"' ;
154+ is $file -> contains(' a' ), 0, ' "a" at position 0' ;
155+ is $file -> contains(' b' ), 131071, ' "b" at position 131071' ;
156+ is $file -> contains(' c' ), 131072, ' "c" at position 131072' ;
157+ is $file -> contains(' abc' ), 131070, ' "abc" at position 131070' ;
158+ is $file -> contains(' ccdd' ), 262142, ' "ccdd" at position 262142' ;
159+ is $file -> contains(' dd' ), 262144, ' "dd" at position 262144' ;
160+ is $file -> contains(' ddd' ), -1, ' does not contain "ddd"' ;
161+ is $file -> contains(' b' . (' c' x 131072 ) . ' ddd' ), -1, ' does not contain "b" . ("c" x 131072) . "ddd"' ;
162162};
163163
164164subtest ' Move memory asset to file' => sub {
@@ -169,13 +169,13 @@ subtest 'Move memory asset to file' => sub {
169169 undef $tmp ;
170170 ok !-e $path , ' file has been cleaned up' ;
171171 is $mem -> move_to($path )-> slurp, ' abc' , ' right content' ;
172- ok -e $path , ' file exists' ;
172+ ok -e $path , ' file exists' ;
173173 ok unlink ($path ), ' unlinked file' ;
174- ok !-e $path , ' file has been cleaned up' ;
174+ ok !-e $path , ' file has been cleaned up' ;
175175 is(Mojo::Asset::Memory-> new-> move_to($path )-> slurp, ' ' , ' no content' );
176- ok -e $path , ' file exists' ;
176+ ok -e $path , ' file exists' ;
177177 ok unlink ($path ), ' unlinked file' ;
178- ok !-e $path , ' file has been cleaned up' ;
178+ ok !-e $path , ' file has been cleaned up' ;
179179};
180180
181181subtest ' Move file asset to file' => sub {
@@ -190,29 +190,29 @@ subtest 'Move file asset to file' => sub {
190190 ok !-e $path , ' file has been cleaned up' ;
191191 is $file -> move_to($path )-> slurp, ' bcd' , ' right content' ;
192192 undef $file ;
193- ok -e $path , ' file exists' ;
193+ ok -e $path , ' file exists' ;
194194 ok unlink ($path ), ' unlinked file' ;
195- ok !-e $path , ' file has been cleaned up' ;
195+ ok !-e $path , ' file has been cleaned up' ;
196196 is(Mojo::Asset::File-> new-> move_to($path )-> slurp, ' ' , ' no content' );
197- ok -e $path , ' file exists' ;
197+ ok -e $path , ' file exists' ;
198198 ok unlink ($path ), ' unlinked file' ;
199- ok !-e $path , ' file has been cleaned up' ;
199+ ok !-e $path , ' file has been cleaned up' ;
200200};
201201
202202subtest ' Upgrade' => sub {
203203 my $asset = Mojo::Asset::Memory-> new(max_memory_size => 5, auto_upgrade => 1);
204204 my $upgrade ;
205205 $asset -> on(upgrade => sub { $upgrade ++ });
206206 $asset = $asset -> add_chunk(' lala' );
207- ok !$upgrade , ' upgrade event has not been emitted' ;
207+ ok !$upgrade , ' upgrade event has not been emitted' ;
208208 ok !$asset -> is_file, ' stored in memory' ;
209209 $asset = $asset -> add_chunk(' lala' );
210210 is $upgrade , 1, ' upgrade event has been emitted once' ;
211211 ok $asset -> is_file, ' stored in file' ;
212212 $asset = $asset -> add_chunk(' lala' );
213213 is $upgrade , 1, ' upgrade event was not emitted again' ;
214214 ok $asset -> is_file, ' stored in file' ;
215- is $asset -> slurp, ' lalalalalala' , ' right content' ;
215+ is $asset -> slurp, ' lalalalalala' , ' right content' ;
216216 ok $asset -> cleanup, ' file will be cleaned up' ;
217217 $asset = Mojo::Asset::Memory-> new(max_memory_size => 5);
218218 $asset = $asset -> add_chunk(' lala' );
@@ -232,17 +232,17 @@ subtest 'Change temporary directory during upgrade' => sub {
232232 );
233233 my $file = $mem -> add_chunk(' aaaaaaaaaaa' );
234234 ok $file -> is_file, ' stored in file' ;
235- is $file -> slurp, ' aaaaaaaaaaa' , ' right content' ;
236- is path($file -> path)-> dirname, $tmpdir , ' right directory' ;
235+ is $file -> slurp, ' aaaaaaaaaaa' , ' right content' ;
236+ is path($file -> path)-> dirname, $tmpdir , ' right directory' ;
237237};
238238
239239subtest ' Temporary directory' => sub {
240240 local $ENV {MOJO_TMPDIR } = my $tmpdir = tempdir;
241241 my $file = Mojo::Asset::File-> new;
242242 is($file -> tmpdir, $tmpdir , ' same directory' );
243243 $file -> add_chunk(' works!' );
244- is $file -> slurp, ' works!' , ' right content' ;
245- is path($file -> path)-> dirname, $tmpdir , ' same directory' ;
244+ is $file -> slurp, ' works!' , ' right content' ;
245+ is path($file -> path)-> dirname, $tmpdir , ' same directory' ;
246246};
247247
248248subtest ' Custom temporary file' => sub {
@@ -262,15 +262,15 @@ subtest 'Custom temporary file' => sub {
262262subtest ' Temporary file without cleanup' => sub {
263263 my $file = Mojo::Asset::File-> new(cleanup => 0)-> add_chunk(' test' );
264264 ok $file -> is_file, ' stored in file' ;
265- is $file -> slurp, ' test' , ' right content' ;
266- is $file -> size, 4, ' right size' ;
265+ is $file -> slurp, ' test' , ' right content' ;
266+ is $file -> size, 4, ' right size' ;
267267 is $file -> mtime, (stat $file -> handle)[9], ' right mtime' ;
268- is $file -> contains(' es' ), 1, ' "es" at position 1' ;
268+ is $file -> contains(' es' ), 1, ' "es" at position 1' ;
269269 my $path = $file -> path;
270270 undef $file ;
271- ok -e $path , ' file exists' ;
271+ ok -e $path , ' file exists' ;
272272 ok unlink ($path ), ' unlinked file' ;
273- ok !-e $path , ' file has been cleaned up' ;
273+ ok !-e $path , ' file has been cleaned up' ;
274274};
275275
276276subtest ' Incomplete write' => sub {
0 commit comments