Skip Menu |

This queue is for tickets about the Test-Approx CPAN distribution.

Report information
The Basics
Id: 84499
Status: open
Priority: 0/
Queue: Test-Approx

People
Owner: Nobody in particular
Requestors: f.wesemann [...] fotofinder.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: use of POSIX::strtod forces locales
Date: Mon, 8 Apr 2013 15:29:12 +0200
To: bug-Test-Approx [...] rt.cpan.org
From: Frank Wesemann <f.wesemann [...] fotofinder.com>
Dear Steve, the usage of POSIX::strtod and strtol in the Test:.Approx Module forces the users locales to become "active". with locale enviroment set to "de_DE" assume this little script: #!/usr/bin/perl use strict; use warnings; use utf8; use Test::Approx(); my $dings = 3; my $dongs = $dings / 1000; print " dongs: ", $dongs, "\n"; #prints "0.003" Test::Approx::is_approx($dings, 3); my $ding_dong = $dings / 1000; print "ding_dong: ", $ding_dong, "\n"; #prints "0,003" (mind the changed decimal point!) additionally you can see that Test::Approx isn't doing the right thing at all: my $type = Test::Approx::check_type($dongs); print "type: ", $type, "\n"; #prints "str" In the "check-type" subroutine you assume the decimal_point to be "." which _may_ be correct. Workarounds? As setting the locale to your assumptions ( and resetting it to the users locale afterwards ) also changes the testing environment, in my opinion you should just mention in the docs, that the user should setlocales on his own in his test files. best frank -- -- mit freundlichem Gruß, Frank Wesemann Fotofinder GmbH USt-IdNr. DE812854514 Software Entwicklung Web: http://www.fotofinder.com/ Potsdamer Str. 96 Tel: +49 30 25 79 28 90 10785 Berlin Fax: +49 30 25 79 28 999 Sitz: Berlin Amtsgericht Berlin Charlottenburg (HRB 73099) Geschäftsführer: Ali Paczensky
On 2013-04-08 09:29:43, f.wesemann@fotofinder.com wrote: Show quoted text
> Dear Steve, > > the usage of POSIX::strtod and strtol in the Test:.Approx Module > forces the users locales to become "active". > > with locale enviroment set to "de_DE" assume this little script: > > #!/usr/bin/perl > use strict; > use warnings; > use utf8; > use Test::Approx(); > > my $dings = 3; > my $dongs = $dings / 1000; > > print " dongs: ", $dongs, "\n"; > #prints "0.003" > Test::Approx::is_approx($dings, 3); > my $ding_dong = $dings / 1000; > print "ding_dong: ", $ding_dong, "\n"; > #prints "0,003" (mind the changed decimal point!) > > additionally you can see that Test::Approx isn't doing the right thing > at all: > my $type = Test::Approx::check_type($dongs); > print "type: ", $type, "\n"; > > #prints "str" > > In the "check-type" subroutine you assume the decimal_point to be "." > which _may_ be correct. > > Workarounds? > As setting the locale to your assumptions ( and resetting it to the > users locale afterwards ) also changes the testing environment, in my > opinion you should just mention in the docs, that the user should > setlocales on his own in his test files. >
Another victim of this problem: https://github.com/yanick/Term-Caca/issues/4