Commit | Line | Data |
129318bd |
1 | #! /usr/local/perl -w |
a7ad731c |
2 | # Before `make install' is performed this script should be runnable with |
3 | # `make test'. After `make install' it should work as `perl test.pl' |
a7ad731c |
4 | |
5 | ######################### |
6 | |
34ba6322 |
7 | use Test::More qw(no_plan); |
c8a14fb6 |
8 | require Test::Harness; |
9 | no warnings 'once'; |
10 | *Verbose = \$Test::Harness::Verbose; |
a7ad731c |
11 | |
137d6fc0 |
12 | diag "Tests with base class" unless $ENV{PERL_CORE}; |
a7ad731c |
13 | |
5eb567df |
14 | BEGIN { |
43eaf59d |
15 | use_ok("version", 0.50); # If we made it this far, we are ok. |
5eb567df |
16 | } |
17 | |
137d6fc0 |
18 | BaseTests("version"); |
19 | |
20 | diag "Tests with empty derived class" unless $ENV{PERL_CORE}; |
21 | |
22 | package version::Empty; |
43eaf59d |
23 | use base version; |
137d6fc0 |
24 | $VERSION = 0.01; |
43eaf59d |
25 | no warnings 'redefine'; |
26 | *::qv = sub { return bless version::qv(shift), __PACKAGE__; }; |
137d6fc0 |
27 | |
e0218a61 |
28 | package version::Bad; |
29 | use base version; |
30 | sub new { my($self,$n)=@_; bless \$n, $self } |
31 | |
137d6fc0 |
32 | package main; |
e0218a61 |
33 | my $testobj = version::Empty->new(1.002_003); |
137d6fc0 |
34 | isa_ok( $testobj, "version::Empty" ); |
35 | ok( $testobj->numify == 1.002003, "Numified correctly" ); |
9137345a |
36 | ok( $testobj->stringify eq "1.002003", "Stringified correctly" ); |
37 | ok( $testobj->normal eq "v1.2.3", "Normalified correctly" ); |
137d6fc0 |
38 | |
e0218a61 |
39 | my $verobj = version->new("1.2.4"); |
137d6fc0 |
40 | ok( $verobj > $testobj, "Comparison vs parent class" ); |
41 | ok( $verobj gt $testobj, "Comparison vs parent class" ); |
42 | BaseTests("version::Empty"); |
43 | |
e0218a61 |
44 | diag "tests with bad subclass" unless $ENV{PERL_CORE}; |
45 | $testobj = version::Bad->new(1.002_003); |
46 | isa_ok( $testobj, "version::Bad" ); |
47 | eval { my $string = $testobj->numify }; |
48 | like($@, qr/Invalid version object/, |
49 | "Bad subclass numify"); |
50 | eval { my $string = $testobj->normal }; |
51 | like($@, qr/Invalid version object/, |
52 | "Bad subclass normal"); |
53 | eval { my $string = $testobj->stringify }; |
54 | like($@, qr/Invalid version object/, |
55 | "Bad subclass stringify"); |
56 | eval { my $test = $testobj > 1.0 }; |
57 | like($@, qr/Invalid version object/, |
58 | "Bad subclass vcmp"); |
59 | |
c0b17f21 |
60 | # dummy up a redundant call to satify David Wheeler |
61 | local $SIG{__WARN__} = sub { die $_[0] }; |
62 | eval 'use version;'; |
63 | unlike ($@, qr/^Subroutine main::qv redefined/, |
64 | "Only export qv once per package (to prevent redefined warnings)."); |
65 | |
137d6fc0 |
66 | sub BaseTests { |
67 | |
317f7c8a |
68 | my ($CLASS, $no_qv) = @_; |
69 | |
70 | # Insert your test code below, the Test module is use()ed here so read |
71 | # its man page ( perldoc Test ) for help writing this test script. |
72 | |
73 | # Test bare number processing |
74 | diag "tests with bare numbers" if $Verbose; |
75 | $version = $CLASS->new(5.005_03); |
76 | is ( "$version" , "5.005030" , '5.005_03 eq 5.5.30' ); |
77 | $version = $CLASS->new(1.23); |
78 | is ( "$version" , "1.230" , '1.23 eq "1.230"' ); |
79 | |
80 | # Test quoted number processing |
81 | diag "tests with quoted numbers" if $Verbose; |
82 | $version = $CLASS->new("5.005_03"); |
83 | is ( "$version" , "5.005_030" , '"5.005_03" eq "5.005_030"' ); |
84 | $version = $CLASS->new("v1.23"); |
85 | is ( "$version" , "v1.23.0" , '"v1.23" eq "v1.23.0"' ); |
86 | |
87 | # Test stringify operator |
88 | diag "tests with stringify" if $Verbose; |
89 | $version = $CLASS->new("5.005"); |
90 | is ( "$version" , "5.005" , '5.005 eq "5.005"' ); |
91 | $version = $CLASS->new("5.006.001"); |
92 | is ( "$version" , "v5.6.1" , '5.006.001 eq v5.6.1' ); |
93 | $version = $CLASS->new("1.2.3_4"); |
94 | is ( "$version" , "v1.2.3_4" , 'alpha version 1.2.3_4 eq v1.2.3_4' ); |
95 | |
96 | # test illegal formats |
97 | diag "test illegal formats" if $Verbose; |
98 | eval {my $version = $CLASS->new("1.2_3_4")}; |
99 | like($@, qr/multiple underscores/, |
100 | "Invalid version format (multiple underscores)"); |
101 | |
102 | eval {my $version = $CLASS->new("1.2_3.4")}; |
103 | like($@, qr/underscores before decimal/, |
104 | "Invalid version format (underscores before decimal)"); |
105 | |
106 | eval {my $version = $CLASS->new("1_2")}; |
107 | like($@, qr/alpha without decimal/, |
108 | "Invalid version format (alpha without decimal)"); |
109 | |
110 | # for this first test, just upgrade the warn() to die() |
111 | eval { |
112 | local $SIG{__WARN__} = sub { die $_[0] }; |
113 | $version = $CLASS->new("1.2b3"); |
114 | }; |
115 | my $warnregex = "Version string '.+' contains invalid data; ". |
116 | "ignoring: '.+'"; |
117 | |
118 | like($@, qr/$warnregex/, |
119 | "Version string contains invalid data; ignoring"); |
120 | |
121 | # from here on out capture the warning and test independently |
122 | my $warning; |
123 | local $SIG{__WARN__} = sub { $warning = $_[0] }; |
124 | $version = $CLASS->new("99 and 44/100 pure"); |
125 | |
126 | like($warning, qr/$warnregex/, |
127 | "Version string contains invalid data; ignoring"); |
128 | ok ("$version" eq "99.000", '$version eq "99.000"'); |
129 | ok ($version->numify == 99.0, '$version->numify == 99.0'); |
130 | ok ($version->normal eq "v99.0.0", '$version->normal eq v99.0.0'); |
131 | |
132 | $version = $CLASS->new("something"); |
133 | like($warning, qr/$warnregex/, |
134 | "Version string contains invalid data; ignoring"); |
135 | ok (defined $version, 'defined $version'); |
136 | |
137 | # reset the test object to something reasonable |
138 | $version = $CLASS->new("1.2.3"); |
139 | |
140 | # Test boolean operator |
141 | ok ($version, 'boolean'); |
142 | |
143 | # Test class membership |
144 | isa_ok ( $version, $CLASS ); |
145 | |
146 | # Test comparison operators with self |
147 | diag "tests with self" if $Verbose; |
148 | ok ( $version eq $version, '$version eq $version' ); |
149 | is ( $version cmp $version, 0, '$version cmp $version == 0' ); |
150 | ok ( $version == $version, '$version == $version' ); |
151 | |
152 | # test first with non-object |
153 | $version = $CLASS->new("5.006.001"); |
154 | $new_version = "5.8.0"; |
155 | diag "tests with non-objects" if $Verbose; |
156 | ok ( $version ne $new_version, '$version ne $new_version' ); |
157 | ok ( $version lt $new_version, '$version lt $new_version' ); |
158 | ok ( $new_version gt $version, '$new_version gt $version' ); |
159 | ok ( ref(\$new_version) eq 'SCALAR', 'no auto-upgrade'); |
160 | $new_version = "$version"; |
161 | ok ( $version eq $new_version, '$version eq $new_version' ); |
162 | ok ( $new_version eq $version, '$new_version eq $version' ); |
163 | |
164 | # now test with existing object |
165 | $new_version = $CLASS->new("5.8.0"); |
166 | diag "tests with objects" if $Verbose; |
167 | ok ( $version ne $new_version, '$version ne $new_version' ); |
168 | ok ( $version lt $new_version, '$version lt $new_version' ); |
169 | ok ( $new_version gt $version, '$new_version gt $version' ); |
170 | $new_version = $CLASS->new("$version"); |
171 | ok ( $version eq $new_version, '$version eq $new_version' ); |
172 | |
173 | # Test Numeric Comparison operators |
174 | # test first with non-object |
175 | $new_version = "5.8.0"; |
176 | diag "numeric tests with non-objects" if $Verbose; |
177 | ok ( $version == $version, '$version == $version' ); |
178 | ok ( $version < $new_version, '$version < $new_version' ); |
179 | ok ( $new_version > $version, '$new_version > $version' ); |
180 | ok ( $version != $new_version, '$version != $new_version' ); |
181 | |
182 | # now test with existing object |
183 | $new_version = $CLASS->new($new_version); |
184 | diag "numeric tests with objects" if $Verbose; |
185 | ok ( $version < $new_version, '$version < $new_version' ); |
186 | ok ( $new_version > $version, '$new_version > $version' ); |
187 | ok ( $version != $new_version, '$version != $new_version' ); |
188 | |
189 | # now test with actual numbers |
190 | diag "numeric tests with numbers" if $Verbose; |
191 | ok ( $version->numify() == 5.006001, '$version->numify() == 5.006001' ); |
192 | ok ( $version->numify() <= 5.006001, '$version->numify() <= 5.006001' ); |
193 | ok ( $version->numify() < 5.008, '$version->numify() < 5.008' ); |
194 | #ok ( $version->numify() > v5.005_02, '$version->numify() > 5.005_02' ); |
195 | |
196 | # test with long decimals |
197 | diag "Tests with extended decimal versions" if $Verbose; |
198 | $version = $CLASS->new(1.002003); |
199 | ok ( $version eq "1.2.3", '$version eq "1.2.3"'); |
200 | ok ( $version->numify == 1.002003, '$version->numify == 1.002003'); |
201 | $version = $CLASS->new("2002.09.30.1"); |
202 | ok ( $version eq "2002.9.30.1",'$version eq 2002.9.30.1'); |
203 | ok ( $version->numify == 2002.009030001, |
204 | '$version->numify == 2002.009030001'); |
205 | |
206 | # now test with alpha version form with string |
207 | $version = $CLASS->new("1.2.3"); |
208 | $new_version = "1.2.3_4"; |
209 | diag "tests with alpha-style non-objects" if $Verbose; |
210 | ok ( $version lt $new_version, '$version lt $new_version' ); |
211 | ok ( $new_version gt $version, '$new_version gt $version' ); |
212 | ok ( $version ne $new_version, '$version ne $new_version' ); |
213 | |
214 | $version = $CLASS->new("1.2.4"); |
215 | diag "numeric tests with alpha-style non-objects" |
216 | if $Verbose; |
217 | ok ( $version > $new_version, '$version > $new_version' ); |
218 | ok ( $new_version < $version, '$new_version < $version' ); |
219 | ok ( $version != $new_version, '$version != $new_version' ); |
220 | |
221 | # now test with alpha version form with object |
222 | $version = $CLASS->new("1.2.3"); |
223 | $new_version = $CLASS->new("1.2.3_4"); |
224 | diag "tests with alpha-style objects" if $Verbose; |
225 | ok ( $version < $new_version, '$version < $new_version' ); |
226 | ok ( $new_version > $version, '$new_version > $version' ); |
227 | ok ( $version != $new_version, '$version != $new_version' ); |
228 | ok ( !$version->is_alpha, '!$version->is_alpha'); |
229 | ok ( $new_version->is_alpha, '$new_version->is_alpha'); |
230 | |
231 | $version = $CLASS->new("1.2.4"); |
232 | diag "tests with alpha-style objects" if $Verbose; |
233 | ok ( $version > $new_version, '$version > $new_version' ); |
234 | ok ( $new_version < $version, '$new_version < $version' ); |
235 | ok ( $version != $new_version, '$version != $new_version' ); |
236 | |
237 | $version = $CLASS->new("1.2.3.4"); |
238 | $new_version = $CLASS->new("1.2.3_4"); |
239 | diag "tests with alpha-style objects with same subversion" |
240 | if $Verbose; |
241 | ok ( $version > $new_version, '$version > $new_version' ); |
242 | ok ( $new_version < $version, '$new_version < $version' ); |
243 | ok ( $version != $new_version, '$version != $new_version' ); |
244 | |
245 | diag "test implicit [in]equality" if $Verbose; |
246 | $version = $CLASS->new("v1.2.3"); |
247 | $new_version = $CLASS->new("1.2.3.0"); |
248 | ok ( $version == $new_version, '$version == $new_version' ); |
249 | $new_version = $CLASS->new("1.2.3_0"); |
250 | ok ( $version == $new_version, '$version == $new_version' ); |
251 | $new_version = $CLASS->new("1.2.3.1"); |
252 | ok ( $version < $new_version, '$version < $new_version' ); |
253 | $new_version = $CLASS->new("1.2.3_1"); |
254 | ok ( $version < $new_version, '$version < $new_version' ); |
255 | $new_version = $CLASS->new("1.1.999"); |
256 | ok ( $version > $new_version, '$version > $new_version' ); |
257 | |
258 | # that which is not expressly permitted is forbidden |
259 | diag "forbidden operations" if $Verbose; |
260 | ok ( !eval { ++$version }, "noop ++" ); |
261 | ok ( !eval { --$version }, "noop --" ); |
262 | ok ( !eval { $version/1 }, "noop /" ); |
263 | ok ( !eval { $version*3 }, "noop *" ); |
264 | ok ( !eval { abs($version) }, "noop abs" ); |
137d6fc0 |
265 | |
c8a14fb6 |
266 | SKIP: { |
317f7c8a |
267 | skip "version require'd instead of use'd, cannot test qv", 3 |
268 | if defined $no_qv; |
269 | # test the qv() sub |
270 | diag "testing qv" if $Verbose; |
271 | $version = qv("1.2"); |
272 | cmp_ok ( $version, "eq", "v1.2.0", 'qv("1.2") eq "1.2.0"' ); |
273 | $version = qv(1.2); |
274 | cmp_ok ( $version, "eq", "v1.2.0", 'qv(1.2) eq "1.2.0"' ); |
275 | isa_ok( qv('5.008'), $CLASS ); |
c8a14fb6 |
276 | } |
137d6fc0 |
277 | |
317f7c8a |
278 | # test creation from existing version object |
279 | diag "create new from existing version" if $Verbose; |
280 | ok (eval {$new_version = $CLASS->new($version)}, |
281 | "new from existing object"); |
282 | ok ($new_version == $version, "class->new($version) identical"); |
283 | $new_version = $version->new(); |
284 | isa_ok ($new_version, $CLASS ); |
285 | is ($new_version, "0.000", "version->new() doesn't clone"); |
286 | $new_version = $version->new("1.2.3"); |
287 | is ($new_version, "v1.2.3" , '$version->new("1.2.3") works too'); |
288 | |
289 | # test the CVS revision mode |
290 | diag "testing CVS Revision" if $Verbose; |
291 | $version = new $CLASS qw$Revision: 1.2$; |
292 | ok ( $version eq "1.2.0", 'qw$Revision: 1.2$ eq 1.2.0' ); |
293 | $version = new $CLASS qw$Revision: 1.2.3.4$; |
294 | ok ( $version eq "1.2.3.4", 'qw$Revision: 1.2.3.4$ eq 1.2.3.4' ); |
295 | |
296 | # test the CPAN style reduced significant digit form |
297 | diag "testing CPAN-style versions" if $Verbose; |
298 | $version = $CLASS->new("1.23_01"); |
299 | is ( "$version" , "1.23_0100", "CPAN-style alpha version" ); |
300 | ok ( $version > 1.23, "1.23_01 > 1.23"); |
301 | ok ( $version < 1.24, "1.23_01 < 1.24"); |
302 | |
303 | # test reformed UNIVERSAL::VERSION |
304 | diag "Replacement UNIVERSAL::VERSION tests" if $Verbose; |
305 | |
306 | # we know this file is here since we require it ourselves |
307 | $version = $Test::More::VERSION; |
308 | eval "use Test::More $version"; |
309 | unlike($@, qr/Test::More version $version/, |
310 | 'Replacement eval works with exact version'); |
c8a14fb6 |
311 | |
317f7c8a |
312 | # test as class method |
313 | $new_version = Test::More->VERSION; |
314 | cmp_ok($new_version,'cmp',$version, "Called as class method"); |
315 | |
316 | # this should fail even with old UNIVERSAL::VERSION |
317 | $version = $Test::More::VERSION+0.01; |
318 | eval "use Test::More $version"; |
319 | like($@, qr/Test::More version $version/, |
320 | 'Replacement eval works with incremented version'); |
321 | |
8dd04980 |
322 | TODO: { |
323 | local $TODO = "Test fails with Test::More versions ending in _0X"; |
324 | $version =~ s/\.0$//; #convert to string and remove trailing '.0' |
325 | chop($version); # shorten by 1 digit, should still succeed |
326 | eval "use Test::More $version"; |
327 | unlike($@, qr/Test::More version $version/, |
317f7c8a |
328 | 'Replacement eval works with single digit'); |
8dd04980 |
329 | } |
330 | |
317f7c8a |
331 | $version += 0.1; # this would fail with old UNIVERSAL::VERSION |
332 | eval "use Test::More $version"; |
333 | like($@, qr/Test::More version $version/, |
334 | 'Replacement eval works with incremented digit'); |
335 | |
336 | { # dummy up some variously broken modules for testing |
337 | open F, ">xxx.pm" or die "Cannot open xxx.pm: $!\n"; |
338 | print F "1;\n"; |
339 | close F; |
340 | my $error_regex; |
341 | if ( $] < 5.008 ) { |
342 | $error_regex = 'xxx does not define \$xxx::VERSION'; |
c8a14fb6 |
343 | } |
317f7c8a |
344 | else { |
345 | $error_regex = 'xxx defines neither package nor VERSION'; |
c8a14fb6 |
346 | } |
347 | |
317f7c8a |
348 | eval "use lib '.'; use xxx 3;"; |
349 | like ($@, qr/$error_regex/, |
350 | 'Replacement handles modules without package or VERSION'); |
351 | eval "use lib '.'; use xxx; $version = xxx->VERSION"; |
352 | unlike ($@, qr/$error_regex/, |
353 | 'Replacement handles modules without package or VERSION'); |
354 | ok (defined($version), "Called as class method"); |
355 | unlink 'xxx.pm'; |
356 | } |
357 | |
358 | { # dummy up some variously broken modules for testing |
359 | open F, ">yyy.pm" or die "Cannot open yyy.pm: $!\n"; |
360 | print F "package yyy;\n#look ma no VERSION\n1;\n"; |
361 | close F; |
362 | eval "use lib '.'; use yyy 3;"; |
363 | like ($@, qr/^yyy does not define \$yyy::VERSION/, |
364 | 'Replacement handles modules without VERSION'); |
365 | eval "use lib '.'; use yyy; print yyy->VERSION"; |
366 | unlike ($@, qr/^yyy does not define \$yyy::VERSION/, |
367 | 'Replacement handles modules without VERSION'); |
368 | unlink 'yyy.pm'; |
369 | } |
370 | |
371 | { # dummy up some variously broken modules for testing |
372 | open F, ">zzz.pm" or die "Cannot open zzz.pm: $!\n"; |
373 | print F "package zzz;\n\@VERSION = ();\n1;\n"; |
374 | close F; |
375 | eval "use lib '.'; use zzz 3;"; |
376 | like ($@, qr/^zzz does not define \$zzz::VERSION/, |
377 | 'Replacement handles modules without VERSION'); |
378 | eval "use lib '.'; use zzz; print zzz->VERSION"; |
379 | unlike ($@, qr/^zzz does not define \$zzz::VERSION/, |
380 | 'Replacement handles modules without VERSION'); |
381 | unlink 'zzz.pm'; |
382 | } |
383 | |
137d6fc0 |
384 | SKIP: { |
317f7c8a |
385 | skip 'Cannot test bare v-strings with Perl < 5.8.1', 4 |
386 | if $] < 5.008_001; |
387 | diag "Tests with v-strings" if $Verbose; |
388 | $version = $CLASS->new(1.2.3); |
389 | ok("$version" eq "v1.2.3", '"$version" eq 1.2.3'); |
390 | $version = $CLASS->new(1.0.0); |
391 | $new_version = $CLASS->new(1); |
392 | ok($version == $new_version, '$version == $new_version'); |
393 | ok($version eq $new_version, '$version eq $new_version'); |
394 | skip "version require'd instead of use'd, cannot test qv", 1 |
395 | if defined $no_qv; |
396 | $version = qv(1.2.3); |
397 | ok("$version" eq "v1.2.3", 'v-string initialized qv()'); |
398 | } |
399 | |
400 | diag "Tests with real-world (malformed) data" if $Verbose; |
401 | |
402 | # trailing zero testing (reported by Andreas Koenig). |
403 | $version = $CLASS->new("1"); |
404 | ok($version->numify eq "1.000", "trailing zeros preserved"); |
405 | $version = $CLASS->new("1.0"); |
406 | ok($version->numify eq "1.000", "trailing zeros preserved"); |
407 | $version = $CLASS->new("1.0.0"); |
408 | ok($version->numify eq "1.000000", "trailing zeros preserved"); |
409 | $version = $CLASS->new("1.0.0.0"); |
410 | ok($version->numify eq "1.000000000", "trailing zeros preserved"); |
411 | |
412 | # leading zero testing (reported by Andreas Koenig). |
413 | $version = $CLASS->new(".7"); |
414 | ok($version->numify eq "0.700", "leading zero inferred"); |
415 | |
416 | # leading space testing (reported by Andreas Koenig). |
417 | $version = $CLASS->new(" 1.7"); |
418 | ok($version->numify eq "1.700", "leading space ignored"); |
419 | |
420 | # RT 19517 - deal with undef and 'undef' initialization |
421 | ok($version ne 'undef', "Undef version comparison #1"); |
422 | ok($version ne undef, "Undef version comparison #2"); |
423 | $version = $CLASS->new('undef'); |
424 | unlike($warning, qr/^Version string 'undef' contains invalid data/, |
425 | "Version string 'undef'"); |
426 | |
427 | $version = $CLASS->new(undef); |
428 | like($warning, qr/^Use of uninitialized value/, |
429 | "Version string 'undef'"); |
430 | ok($version eq 'undef', "Undef version comparison #3"); |
431 | ok($version eq undef, "Undef version comparison #4"); |
432 | eval "\$version = \$CLASS->new()"; # no parameter at all |
433 | unlike($@, qr/^Bizarre copy of CODE/, "No initializer at all"); |
434 | ok($version eq 'undef', "Undef version comparison #5"); |
435 | ok($version eq undef, "Undef version comparison #6"); |
436 | |
437 | $version = $CLASS->new(0.000001); |
438 | unlike($warning, qr/^Version string '1e-06' contains invalid data/, |
439 | "Very small version objects"); |
e0218a61 |
440 | |
317f7c8a |
441 | SKIP: { |
442 | # dummy up a legal module for testing RT#19017 |
443 | open F, ">www.pm" or die "Cannot open www.pm: $!\n"; |
444 | print F <<"EOF"; |
c8a14fb6 |
445 | package www; |
446 | use version; \$VERSION = qv('0.0.4'); |
447 | 1; |
448 | EOF |
317f7c8a |
449 | close F; |
450 | |
451 | eval "use lib '.'; use www 0.000008;"; |
452 | like ($@, qr/^www version 0.000008 \(v0.0.8\) required/, |
453 | "Make sure very small versions don't freak"); |
454 | eval "use lib '.'; use www 1;"; |
455 | like ($@, qr/^www version 1.000 \(v1.0.0\) required/, |
456 | "Comparing vs. version with no decimal"); |
457 | eval "use lib '.'; use www 1.;"; |
458 | like ($@, qr/^www version 1.000 \(v1.0.0\) required/, |
459 | "Comparing vs. version with decimal only"); |
460 | |
d69f6151 |
461 | if ( $] < 5.006_002 ) { |
462 | unlink 'www.pm'; |
463 | skip 'Cannot "use" extended versions with Perl < 5.6.2', 3; |
464 | } |
317f7c8a |
465 | eval "use lib '.'; use www 0.0.8;"; |
466 | like ($@, qr/^www version 0.000008 \(v0.0.8\) required/, |
467 | "Make sure very small versions don't freak"); |
468 | |
469 | eval "use lib '.'; use www 0.0.4;"; |
470 | unlike($@, qr/^www version 0.000004 \(v0.0.4\) required/, |
471 | 'Succeed - required == VERSION'); |
472 | cmp_ok ( "www"->VERSION, 'eq', '0.000004', 'No undef warnings' ); |
473 | |
474 | unlink 'www.pm'; |
475 | } |
476 | |
477 | open F, ">vvv.pm" or die "Cannot open vvv.pm: $!\n"; |
478 | print F <<"EOF"; |
92dcf8ce |
479 | package vvv; |
480 | use base qw(version); |
481 | 1; |
482 | EOF |
317f7c8a |
483 | close F; |
484 | # need to eliminate any other qv()'s |
485 | undef *main::qv; |
486 | ok(!defined(&{"main\::qv"}), "make sure we cleared qv() properly"); |
487 | eval "use lib '.'; use vvv;"; |
488 | ok(defined(&{"main\::qv"}), "make sure we exported qv() properly"); |
489 | isa_ok( qv(1.2), "vvv"); |
490 | unlink 'vvv.pm'; |
d69f6151 |
491 | |
492 | SKIP: { |
493 | # test locale handling |
494 | my $ver = 1.23; # has to be floating point number |
495 | my $loc; |
496 | while (<DATA>) { |
497 | chomp; |
498 | $loc = POSIX::setlocale( &POSIX::LC_ALL, $_); |
499 | last if POSIX::localeconv()->{decimal_point} eq ','; |
500 | } |
501 | skip 'Cannot test locale handling without a comma locale', 4 |
502 | unless ( $loc and ($ver eq '1,23') ); |
503 | |
504 | diag ("Testing locale handling with $loc") if $Verbose; |
505 | |
506 | my $v = $CLASS->new($ver); |
507 | unlike($warning,qr/Version string '1,23' contains invalid data/, |
508 | "Process locale-dependent floating point"); |
509 | is ($v, "1.230", "Locale doesn't apply to version objects"); |
510 | ok ($v == $ver, "Comparison to locale floating point"); |
511 | } |
137d6fc0 |
512 | } |
cb5772bb |
513 | |
514 | 1; |
d69f6151 |
515 | |
516 | __DATA__ |
517 | af_ZA |
518 | af_ZA.utf8 |
519 | an_ES |
520 | an_ES.utf8 |
521 | az_AZ.utf8 |
522 | be_BY |
523 | be_BY.utf8 |
524 | bg_BG |
525 | bg_BG.utf8 |
526 | br_FR |
527 | br_FR@euro |
528 | br_FR.utf8 |
529 | bs_BA |
530 | bs_BA.utf8 |
531 | ca_ES |
532 | ca_ES@euro |
533 | ca_ES.utf8 |
534 | cs_CZ |
535 | cs_CZ.utf8 |
536 | da_DK |
537 | da_DK.utf8 |
538 | de_AT |
539 | de_AT@euro |
540 | de_AT.utf8 |
541 | de_BE |
542 | de_BE@euro |
543 | de_BE.utf8 |
544 | de_DE |
545 | de_DE@euro |
546 | de_DE.utf8 |
547 | de_LU |
548 | de_LU@euro |
549 | de_LU.utf8 |
550 | el_GR |
551 | el_GR.utf8 |
552 | en_DK |
553 | en_DK.utf8 |
554 | es_AR |
555 | es_AR.utf8 |
556 | es_BO |
557 | es_BO.utf8 |
558 | es_CL |
559 | es_CL.utf8 |
560 | es_CO |
561 | es_CO.utf8 |
562 | es_EC |
563 | es_EC.utf8 |
564 | es_ES |
565 | es_ES@euro |
566 | es_ES.utf8 |
567 | es_PY |
568 | es_PY.utf8 |
569 | es_UY |
570 | es_UY.utf8 |
571 | es_VE |
572 | es_VE.utf8 |
573 | et_EE |
574 | et_EE.iso885915 |
575 | et_EE.utf8 |
576 | eu_ES |
577 | eu_ES@euro |
578 | eu_ES.utf8 |
579 | fi_FI |
580 | fi_FI@euro |
581 | fi_FI.utf8 |
582 | fo_FO |
583 | fo_FO.utf8 |
584 | fr_BE |
585 | fr_BE@euro |
586 | fr_BE.utf8 |
587 | fr_CA |
588 | fr_CA.utf8 |
589 | fr_CH |
590 | fr_CH.utf8 |
591 | fr_FR |
592 | fr_FR@euro |
593 | fr_FR.utf8 |
594 | fr_LU |
595 | fr_LU@euro |
596 | fr_LU.utf8 |
597 | gl_ES |
598 | gl_ES@euro |
599 | gl_ES.utf8 |
600 | hr_HR |
601 | hr_HR.utf8 |
602 | hu_HU |
603 | hu_HU.utf8 |
604 | id_ID |
605 | id_ID.utf8 |
606 | is_IS |
607 | is_IS.utf8 |
608 | it_CH |
609 | it_CH.utf8 |
610 | it_IT |
611 | it_IT@euro |
612 | it_IT.utf8 |
613 | ka_GE |
614 | ka_GE.utf8 |
615 | kk_KZ |
616 | kk_KZ.utf8 |
617 | kl_GL |
618 | kl_GL.utf8 |
619 | lt_LT |
620 | lt_LT.utf8 |
621 | lv_LV |
622 | lv_LV.utf8 |
623 | mk_MK |
624 | mk_MK.utf8 |
625 | mn_MN |
626 | mn_MN.utf8 |
627 | nb_NO |
628 | nb_NO.utf8 |
629 | nl_BE |
630 | nl_BE@euro |
631 | nl_BE.utf8 |
632 | nl_NL |
633 | nl_NL@euro |
634 | nl_NL.utf8 |
635 | nn_NO |
636 | nn_NO.utf8 |
637 | no_NO |
638 | no_NO.utf8 |
639 | oc_FR |
640 | oc_FR.utf8 |
641 | pl_PL |
642 | pl_PL.utf8 |
643 | pt_BR |
644 | pt_BR.utf8 |
645 | pt_PT |
646 | pt_PT@euro |
647 | pt_PT.utf8 |
648 | ro_RO |
649 | ro_RO.utf8 |
650 | ru_RU |
651 | ru_RU.koi8r |
652 | ru_RU.utf8 |
653 | ru_UA |
654 | ru_UA.utf8 |
655 | se_NO |
656 | se_NO.utf8 |
657 | sh_YU |
658 | sh_YU.utf8 |
659 | sk_SK |
660 | sk_SK.utf8 |
661 | sl_SI |
662 | sl_SI.utf8 |
663 | sq_AL |
664 | sq_AL.utf8 |
665 | sr_CS |
666 | sr_CS.utf8 |
667 | sv_FI |
668 | sv_FI@euro |
669 | sv_FI.utf8 |
670 | sv_SE |
671 | sv_SE.iso885915 |
672 | sv_SE.utf8 |
673 | tg_TJ |
674 | tg_TJ.utf8 |
675 | tr_TR |
676 | tr_TR.utf8 |
677 | tt_RU.utf8 |
678 | uk_UA |
679 | uk_UA.utf8 |
680 | vi_VN |
681 | vi_VN.tcvn |
682 | wa_BE |
683 | wa_BE@euro |
684 | wa_BE.utf8 |
685 | |