Skip to content

Commit

Permalink
- tests for format_number also use round_option constants
Browse files Browse the repository at this point in the history
- see Perl#9
  • Loading branch information
Sadrak committed Mar 7, 2017
1 parent 520d308 commit febbbbf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions t/format_number.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use warnings;
use POSIX;
setlocale(&LC_ALL, 'C');

BEGIN { use_ok('Number::Format', ':subs') }
BEGIN { use_ok('Number::Format', ':subs', ':constants') }

is(format_number(123456.51), '123,456.51', 'thousands');
is(format_number(1234567.509, 2), '1,234,567.51', 'rounding');
Expand All @@ -17,16 +17,16 @@ is(format_number(1.23456789, 6), '1.234568', 'six digit rounding');
is(format_number('1.2300', 7, 1), '1.2300000', 'extra zeroes');
is(format_number(.23, 7, 1), '0.2300000', 'leading zero');
is(format_number(-100, 7, 1), '-100.0000000', 'negative with zeros');
is(format_number(1.1, 0, undef, undef, -2), '1', 'abs floor');
is(format_number(1.1, 0, undef, undef, -1), '1', 'floor');
is(format_number(1.1, 0, undef, undef, 0), '1', 'round');
is(format_number(1.1, 0, undef, undef, +1), '2', 'ceil');
is(format_number(1.1, 0, undef, undef, +2), '2', 'abs ceil');
is(format_number(-1.6, 0, undef, undef, -2), '-1', 'abs floor');
is(format_number(-1.6, 0, undef, undef, -1), '-2', 'floor');
is(format_number(-1.6, 0, undef, undef, 0), '-2', 'round');
is(format_number(-1.6, 0, undef, undef, +1), '-1', 'ceil');
is(format_number(-1.6, 0, undef, undef, +2), '-2', 'abs ceil');
is(format_number(1.1, 0, undef, undef, ROUND_ABS_FLOOR), '1', 'abs floor');
is(format_number(1.1, 0, undef, undef, ROUND_FLOOR), '1', 'floor');
is(format_number(1.1, 0, undef, undef, ROUND_NORMAL), '1', 'round');
is(format_number(1.1, 0, undef, undef, ROUND_CEIL), '2', 'ceil');
is(format_number(1.1, 0, undef, undef, ROUND_ABS_CEIL), '2', 'abs ceil');
is(format_number(-1.6, 0, undef, undef, ROUND_ABS_FLOOR), '-1', 'abs floor');
is(format_number(-1.6, 0, undef, undef, ROUND_FLOOR), '-2', 'floor');
is(format_number(-1.6, 0, undef, undef, ROUND_NORMAL), '-2', 'round');
is(format_number(-1.6, 0, undef, undef, ROUND_CEIL), '-1', 'ceil');
is(format_number(-1.6, 0, undef, undef, ROUND_ABS_CEIL), '-2', 'abs ceil');

is(format_number("0.000020000E+00", 7), '2e-05', 'scientific notation not processed');

Expand Down

0 comments on commit febbbbf

Please sign in to comment.