1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
|
#! /usr/local/perl -w
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
#########################
use File::Basename;
use File::Temp qw/tempfile/;
use POSIX qw/locale_h/;
use Test::More tests => 8;
use Config;
BEGIN {
use_ok('version', 0.9933);
}
sub radix { # Returns the radix character for the current locale.
# Use localeconv() on earlier perls; if it is just a stub, assume a dot.
if (! $^V or $^V lt v5.37.4) {
return localeconv()->{decimal_point} || ".";
}
# localeconv() may be a stub on some platforms. But on later perls,
# langinfo() will always exist and returns the best available value.
use if $^V && $^V ge v5.37.4, 'I18N::Langinfo' => qw(langinfo RADIXCHAR);
return langinfo(RADIXCHAR);
}
SKIP: {
skip 'No locale testing for Perl < 5.6.0', 7 if $] < 5.006;
skip 'No locale testing without d_setlocale', 7
if(!$Config{d_setlocale});
eval "&POSIX::LC_NUMERIC";
skip 'No locale testing without LC_NUMERIC', 7
if $@ || $Config{ccflags} =~ /-DNO_LOCALE_NUMERIC\b/;
# test locale handling
my $warning = '';
local $SIG{__WARN__} = sub { $warning = $_[0] };
my $ver = 1.23; # has to be floating point number
my $loc;
my $orig_loc = setlocale(LC_NUMERIC);
ok ($ver eq "1.23", 'Not using locale yet'); # Don't use is(),
# because have to
# evaluate in current
# scope
use if $^O !~ /android/, 'locale';
while (<DATA>) {
chomp;
$loc = setlocale( LC_NUMERIC, $_);
last if $loc && radix() eq ',';
}
skip 'Cannot test locale handling without a comma locale', 6
unless $loc and radix() eq ',';
setlocale(LC_NUMERIC, $loc);
$ver = 1.23; # has to be floating point number
ok ($ver eq "1,23", "Using locale: $loc");
$v = 'version'->new($ver);
unlike($warning, qr/Version string '1,23' contains invalid data/,
"Process locale-dependent floating point");
ok ($v eq "1.23", "Locale doesn't apply to version objects");
ok ($v == $ver, "Comparison to locale floating point");
TODO: { # Resolve https://rt.cpan.org/Ticket/Display.html?id=102272
local $TODO = 'Fails for Perl 5.x.0 < 5.19.0' if $] < 5.019000;
$ver = 'version'->new($]);
is "$ver", "$]", 'Use PV for dualvars';
}
setlocale( LC_NUMERIC, $orig_loc); # reset this before possible skip
skip 'Cannot test RT#46921 with Perl < 5.008', 1
if ($] < 5.008);
my ($fh, $filename) = tempfile('tXXXXXXX', SUFFIX => '.pm', UNLINK => 1);
(my $package = basename($filename)) =~ s/\.pm$//;
print $fh <<"EOF";
package $package;
use locale;
use POSIX qw(locale_h);
\$^W = 1;
use version;
setlocale (LC_NUMERIC, '$loc');
use version ;
eval "use Socket 1.7";
setlocale( LC_NUMERIC, '$orig_loc');
1;
EOF
close $fh;
eval "use lib '.'; use $package;";
unlike($warning, qr"Version string '1,7' contains invalid data",
'Handle locale action-at-a-distance');
}
__DATA__
af_ZA
af_ZA.utf8
af_ZA.UTF-8
an_ES
an_ES.utf8
an_ES.UTF-8
az_AZ.utf8
az_AZ.UTF-8
be_BY
be_BY.utf8
be_BY.UTF-8
bg_BG
bg_BG.utf8
bg_BG.UTF-8
br_FR
br_FR@euro
br_FR.utf8
br_FR.UTF-8
bs_BA
bs_BA.utf8
bs_BA.UTF-8
ca_ES
ca_ES@euro
ca_ES.utf8
ca_ES.UTF-8
cs_CZ
cs_CZ.utf8
cs_CZ.UTF-8
da_DK
da_DK.utf8
da_DK.UTF-8
de_AT
de_AT@euro
de_AT.utf8
de_AT.UTF-8
de_BE
de_BE@euro
de_BE.utf8
de_BE.UTF-8
de_DE
de_DE@euro
de_DE.utf8
de_DE.UTF-8
de_DE.UTF-8
de_LU
de_LU@euro
de_LU.utf8
de_LU.UTF-8
el_GR
el_GR.utf8
el_GR.UTF-8
en_DK
en_DK.utf8
en_DK.UTF-8
es_AR
es_AR.utf8
es_AR.UTF-8
es_BO
es_BO.utf8
es_BO.UTF-8
es_CL
es_CL.utf8
es_CL.UTF-8
es_CO
es_CO.utf8
es_CO.UTF-8
es_EC
es_EC.utf8
es_EC.UTF-8
es_ES
es_ES@euro
es_ES.utf8
es_ES.UTF-8
es_PY
es_PY.utf8
es_PY.UTF-8
es_UY
es_UY.utf8
es_UY.UTF-8
es_VE
es_VE.utf8
es_VE.UTF-8
et_EE
et_EE.iso885915
et_EE.utf8
et_EE.UTF-8
eu_ES
eu_ES@euro
eu_ES.utf8
eu_ES.UTF-8
fi_FI
fi_FI@euro
fi_FI.utf8
fi_FI.UTF-8
fo_FO
fo_FO.utf8
fo_FO.UTF-8
fr_BE
fr_BE@euro
fr_BE.utf8
fr_BE.UTF-8
f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
sq_AL.UTF-8
sr_CS
sr_CS.utf8
sr_CS.UTF-8
sv_FI
sv_FI@euro
sv_FI.utf8
sv_FI.UTF-8
sv_SE
sv_SE.iso885915
sv_SE.utf8
sv_SE.UTF-8
tg_TJ
tg_TJ.utf8
tg_TJ.UTF-8
tr_TR
tr_TR.utf8
tr_TR.UTF-8
tt_RU.utf8
tt_RU.UTF-8
uk_UA
uk_UA.utf8
uk_UA.UTF-8
vi_VN
vi_VN.tcvn
wa_BE
wa_BE@euro
wa_BE.utf8
wa_BE.UTF-8
Afrikaans
Albanian
Arabic
Basque
Breton
Brezhoneg
Bulgarian
Bulgarski
Chinese
Croatian
Cymraeg
Czech
Danish
Dansk
Deutsch
Dutch
Eesti
Ellada
Esperanto
Estonian
Euskaraz
Finnish
Flamish
Frysk
Gaeilge
Galego
Galician
German
Greek
Greenlandic
Hebrew
Hrvatski
Hungarian
Indonesian
Irish
Italian
Italiano
Japanese
Korean
Latin
Latine
Latvian
Lithuanian
Macedonian
Maltese
Moldovan
Nederlands
Nihongo
Norsk
Norwegian
Occitan
Polish
Polski
Rumanian
Russian
Russki
Serbian
Serbski
Slovak
Slovene
Slovenian
Sqhip
Suomi
Svenska
Swedish
Thai
Turkish
Welsh
Yiddish
|