Skip Menu |
 

This queue is for tickets about the Number-Format CPAN distribution.

Report information
The Basics
Id: 97607
Status: open
Priority: 0/
Queue: Number-Format

People
Owner: Nobody in particular
Requestors: khw [...] cpan.org
Cc:
AdminCc:

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

Attachments


Subject: .t files do not set locale properly; fail on locales with comma radix
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
Message-ID: <rt-4.0.18-28131-1406664632-1557.0-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1406664632-28131-2"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
Content-Length: 244
Download (untitled) / with headers
text/plain 244b
The attached patch causes the Number::Format .t files to properly set the locale, and hence be immune from the caller's locale not conforming to what the tests expect. This is the root cause of https://rt.perl.org/Ticket/Display.html?id=122367
Subject: 0001-Fix-broken-.t-files.patch
MIME-Version: 1.0
Content-Type: text/x-patch; name="0001-Fix-broken-.t-files.patch"
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline; filename="0001-Fix-broken-.t-files.patch"
Content-Transfer-Encoding: binary
Content-Length: 3403
From 2d7932a1c8c7d3ebef7ba89229e06919132b6f7a Mon Sep 17 00:00:00 2001 From: Karl Williamson <khw@cpan.org> Date: Tue, 29 Jul 2014 13:15:08 -0600 Subject: [PATCH] Fix broken .t files All but one of these changed .t files set the locale to 'en_US' without checking the return value for success. Some platforms do not have this locale, and so the setlocale() fails, leaving the locale unchanged from the inherited value from the environment. If that locale has a comma for the radix character, for example, the tests fail. format_bytes.t is different; it doesn't even bother trying to change the locale, so will get whatever the inherited value is, and will succeed or fail like the other tests. This commit changes to use the C locale for the tests, as that should always be available everywhere --- t/format_bytes.t | 3 +++ t/format_negative.t | 2 +- t/format_number.t | 2 +- t/format_picture.t | 2 +- t/format_price.t | 2 +- t/object.t | 2 +- t/round.t | 2 +- t/unformat_number.t | 2 +- 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/t/format_bytes.t b/t/format_bytes.t index c608c80..d950bb9 100644 --- a/t/format_bytes.t +++ b/t/format_bytes.t @@ -4,6 +4,9 @@ use Test::More qw(no_plan); use strict; use warnings; +use POSIX; +setlocale(&LC_ALL, 'C'); + BEGIN { use_ok('Number::Format', ':subs') } is(format_bytes(123.51), '123.51', 'no change'); diff --git a/t/format_negative.t b/t/format_negative.t index b34a9d8..3091d22 100644 --- a/t/format_negative.t +++ b/t/format_negative.t @@ -5,7 +5,7 @@ use strict; use warnings; use POSIX; -setlocale(&LC_ALL, 'en_US'); +setlocale(&LC_ALL, 'C'); BEGIN { use_ok('Number::Format') } diff --git a/t/format_number.t b/t/format_number.t index 6f905ea..df6b229 100644 --- a/t/format_number.t +++ b/t/format_number.t @@ -5,7 +5,7 @@ use strict; use warnings; use POSIX; -setlocale(&LC_ALL, 'en_US'); +setlocale(&LC_ALL, 'C'); BEGIN { use_ok('Number::Format', ':subs') } diff --git a/t/format_picture.t b/t/format_picture.t index 782813d..4578279 100644 --- a/t/format_picture.t +++ b/t/format_picture.t @@ -5,7 +5,7 @@ use strict; use warnings; use POSIX; -setlocale(&LC_ALL, 'en_US'); +setlocale(&LC_ALL, 'C'); BEGIN { use_ok('Number::Format') } diff --git a/t/format_price.t b/t/format_price.t index 5bf1ce9..a4d21e3 100644 --- a/t/format_price.t +++ b/t/format_price.t @@ -5,7 +5,7 @@ use strict; use warnings; use POSIX; -setlocale(&LC_ALL, 'en_US'); +setlocale(&LC_ALL, 'C'); BEGIN { use_ok('Number::Format') } diff --git a/t/object.t b/t/object.t index ca485a3..420aa6b 100644 --- a/t/object.t +++ b/t/object.t @@ -5,7 +5,7 @@ use strict; use warnings; use POSIX; -setlocale(&LC_ALL, 'en_US'); +setlocale(&LC_ALL, 'C'); BEGIN { use_ok('Number::Format') } diff --git a/t/round.t b/t/round.t index 8b2310e..4bc2090 100755 --- a/t/round.t +++ b/t/round.t @@ -5,7 +5,7 @@ use strict; use warnings; use POSIX; -setlocale(&LC_ALL, 'en_US'); +setlocale(&LC_ALL, 'C'); BEGIN { use_ok('Number::Format', ':subs') } diff --git a/t/unformat_number.t b/t/unformat_number.t index 63bd44b..7799730 100644 --- a/t/unformat_number.t +++ b/t/unformat_number.t @@ -5,7 +5,7 @@ use strict; use warnings; use POSIX; -setlocale(&LC_ALL, 'en_US'); +setlocale(&LC_ALL, 'C'); BEGIN { use_ok('Number::Format', ':subs') } -- 1.9.1
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-28131-1406664632-1557.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-28131-1406664632-1557.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-18120-1426883573-247.97607-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 414
Download (untitled) / with headers
text/plain 414b
On 2014-07-29 16:10:33, khw wrote: Show quoted text
> The attached patch causes the Number::Format .t files to properly set > the locale, and hence be immune from the caller's locale not > conforming to what the tests expect. > > This is the root cause of > https://rt.perl.org/Ticket/Display.html?id=122367
The patch is still required for the newest development perl 5.21.10. Note that a stable perl will be out in a few months.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.