Skip Menu |

This queue is for tickets about the Math-Currency CPAN distribution.

Report information
The Basics
Id: 65656
Status: resolved
Priority: 0/
Queue: Math-Currency

People
Owner: Nobody in particular
Requestors: johntrammell [...] gmail.com
Cc:
AdminCc:

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



Subject: test error (locale?), perl 10.0, MacOSX 10.6.6
failing test output and perl configuration attached.
Subject: testout.txt
/usr/bin/perl Build --makefile_env_macros 1 test t/001_load........ok t/002_basic....... # Failed test 'changes to object format' # at t/002_basic.t line 115. # got: '£98,994.95' # expected: '£98,994.95' # Failed test 'changes to object format' # at t/002_basic.t line 115. # got: '£98,994.95' # expected: '£98,994.95' # Looks like you failed 2 tests of 97. dubious Test returned status 2 (wstat 512, 0x200) DIED. FAILED tests 42, 90 Failed 2/97 tests, 97.94% okay t/003_subclass....ok t/004_localize.... # Failed test ' '£' = '£'' # at t/004_localize.t line 45. # Looks like you failed 1 test of 32. dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 19 Failed 1/32 tests, 96.88% okay t/005_rounding....ok t/006_defaults....ok Failed Test Stat Wstat Total Fail List of Failed ------------------------------------------------------------------------------- t/002_basic.t 2 512 97 2 42 90 t/004_localize.t 1 256 32 1 19 Failed 2/6 test scripts. 3/154 subtests failed. Files=6, Tests=154, 2 wallclock secs ( 0.78 cusr + 0.70 csys = 1.48 CPU) Failed 2/6 test programs. 3/154 subtests failed. make: *** [test] Error 255
Subject: perl-V.txt
Summary of my perl5 (revision 5 version 10 subversion 0) configuration: Platform: osname=darwin, osvers=10.0, archname=darwin-thread-multi-2level uname='darwin b79.apple.com 10.0 darwin kernel version 10.0.0d8: tue may 5 19:29:59 pdt 2009; root:xnu-1437.2~2release_i386 i386 ' config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=gcc-4.2' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc-4.2', ccflags ='-arch x86_64 -arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include', optimize='-Os', cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='4.2.1 (Apple Inc. build 5646)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc-4.2 -mmacosx-version-min=10.6', ldflags ='-arch x86_64 -arch i386 -arch ppc -L/usr/local/lib' libpth=/usr/local/lib /usr/lib libs=-ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-arch x86_64 -arch i386 -arch ppc -bundle -undefined dynamic_lookup -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Locally applied patches: /Library/Perl/Updates/<version> comes before system perl directories installprivlib and installarchlib points to the Updates directory Built under darwin Compiled at Jun 25 2009 21:54:25 @INC: /Library/Perl/Updates/5.10.0/darwin-thread-multi-2level /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .
Unfortunately, the Locale support in Mac OS/X is really messed up. In some respects, it claims to support UTF-8, but it actually provides only Latin-1 (ASCII). I haven't been doing much with Math::Currency recently, but I hope to eventually split out the L18n support into an independent test suite that has to be manually generated and executed. If the Currency math part of this module works for you, that is about all you can hope for on the Mac. You might be able to use the Locale support if you generate the Locale files yourself, but it isn't worth it to try and make it work in the test suite. Thanks for the complete but report, though. Sorry I couldn't be more helpful... John
Hi JPEACKOCK: I don't think we can lay this entirely at the feet of my OS. Once I "got to the bottom" of the failing tests, it looks to me like the problem rests deeply in how Math::Currency handles locales. One of the tests (t/002_basic.t) fails because the input ("GBP") does not specify an encoding, so Math::Currency then trolls the output of `locale -a` looking for a string match. Since `locale -a` can list the locales in any order, you're flipping a coin as to what encoding you'll get. I don't see any easy way out of this with the current M::C code, which AFAICT assumes Latin1 encoding throughout. The other failing test (t/004_localize.t) fails because the test localizes to "en_GB", not "en_GB.ISO8859-1". The attached patch addresses this on my platform. If you make the source code publicly available (on e.g. github) I will gladly supply more patches. Thanks, John
Subject: 0001-fixed-t-004_localize.t-for-MacOS.patch
From adbcba48ec50fd6a1dbee0396987e9ee0ebb1655 Mon Sep 17 00:00:00 2001 From: John Trammell <johntrammell@gmail.com> Date: Wed, 23 Feb 2011 15:16:27 -0600 Subject: [PATCH] fixed t/004_localize.t for MacOS --- t/004_localize.t | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/t/004_localize.t b/t/004_localize.t index 227d2b9..7c95529 100644 --- a/t/004_localize.t +++ b/t/004_localize.t @@ -4,7 +4,15 @@ use Math::Currency qw($LC_MONETARY); # monetary_locale testing use POSIX qw( locale_h ); -my $locale = setlocale( LC_ALL, "en_GB" ); + +my $locale; +if ($^O eq 'darwin') { # MacOS locale "en_GB" is UTF-8 + $locale = setlocale( LC_ALL, "en_GB.ISO8859-1" ); +} +else { + $locale = setlocale( LC_ALL, "en_GB" ); +} + my $format = {}; Math::Currency->localize( \$format ); -- 1.7.1
Here's a patch that works around the problem in t/002_basic.t.
Subject: 0002-fixed-t-002_basic.t-for-MacOS.patch
From 7ec3f9c4920a3d1b67d4a3662e674533a900a475 Mon Sep 17 00:00:00 2001 From: John Trammell <johntrammell@gmail.com> Date: Wed, 23 Feb 2011 16:04:59 -0600 Subject: [PATCH 2/2] fixed t/002_basic.t for MacOS --- t/002_basic.t | 41 ++++++++++++++++++++++++++++------------- 1 files changed, 28 insertions(+), 13 deletions(-) diff --git a/t/002_basic.t b/t/002_basic.t index 3bc4cf8..6c5519e 100644 --- a/t/002_basic.t +++ b/t/002_basic.t @@ -104,19 +104,34 @@ sub run_tests { my $locale; SKIP: { - $locale = setlocale(LC_ALL,"en_GB"); - skip ("No en_GB locale installed", 1) - unless setlocale(LC_ALL) eq "en_GB"; - skip ("No locale support", 3) unless $CLASS->localize(); - pass ( "Re-initialized locale with en_GB" ); - is ( $FORMAT->{INT_CURR_SYMBOL}, "GBP ", "POSIX format set properly"); - - $pounds = $CLASS->new( 98994.95, 'GBP'); - is ( $pounds, '£98,994.95', "changes to object format" ); - $newpounds = $pounds + 100000; - - is ( ref($newpounds), ref($pounds), "autoupgrade to object" ); - } + my $en_GB = ($^O =~ /darwin/) ? 'en_GB.ISO8859-1' : 'en_GB'; + + $locale = setlocale(LC_ALL,$en_GB); + skip ("No $en_GB locale installed", 1) + unless setlocale(LC_ALL) eq $en_GB; + skip ("No locale support", 3) unless $CLASS->localize(); + pass ( "Re-initialized locale with $en_GB" ); + is ( $FORMAT->{INT_CURR_SYMBOL}, "GBP ", "POSIX format set properly"); + + if ($^O eq 'darwin') { + # If we don't specify a precise locale, we are not guaranteed to + # get the encoding we want. This uses Math::Currency's en_GB.pm, + # which is encoded as Latin1. + $pounds = $CLASS->new(98994.95, 'en_GB'); + } + else { + $pounds = $CLASS->new(98994.95, 'GBP'); + } + my $correct = "\x{a3}98,994.95"; + is ($pounds, $correct, "changes to object format" ) or do { + diag("CLASS=$CLASS"); + diag("\$pounds='$pounds'"); + diag("\$correct='$correct'"); + }; + $newpounds = $pounds + 100000; + + is ( ref($newpounds), ref($pounds), "autoupgrade to object" ); + } SKIP: { $locale = setlocale(LC_ALL,"en_US"); -- 1.7.1
Hi. I have just uploaded Math::Currency v0.48 to CPAN which contains numerous fixes. It will probably take a few hours for it to mirror around CPAN. I am unable to reproduce this issue any longer. I notice this issue was reported on OS X 10.6, which is by now very old, and I do not have access to that. Can you test v0.48 and tell me if you are still experiencing problems? If not I think this ticket can finally be resolved.
Subject: Re: [rt.cpan.org #65656] test error (locale?), perl 10.0, MacOSX 10.6.6
Date: Thu, 16 Jun 2016 13:27:10 -0500
To: bug-Math-Currency [...] rt.cpan.org
From: John Trammell <johntrammell [...] gmail.com>
I no longer have access to that platform, so I can't say that the defect is resolved. But feel free to close the ticket if you like. On Thu, Jun 16, 2016 at 11:50 AM, MSCHOUT via RT < bug-Math-Currency@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=65656 > > > Hi. > > I have just uploaded Math::Currency v0.48 to CPAN which contains numerous > fixes. It will probably take a few hours for it to mirror around CPAN. > > I am unable to reproduce this issue any longer. I notice this issue was > reported on OS X 10.6, which is by now very old, and I do not have access > to that. > > Can you test v0.48 and tell me if you are still experiencing problems? > > If not I think this ticket can finally be resolved. >