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