From 2d7932a1c8c7d3ebef7ba89229e06919132b6f7a Mon Sep 17 00:00:00 2001 From: Karl Williamson 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