|
1 |
use strict;
|
|
2 |
use Test::More;
|
|
3 |
|
|
4 |
use lib 't';
|
|
5 |
|
|
6 |
use_ok('SL::Form');
|
|
7 |
require_ok('SL::Form');
|
|
8 |
|
|
9 |
|
|
10 |
package LxDebugMock;
|
|
11 |
sub enter_sub {};
|
|
12 |
sub leave_sub {};
|
|
13 |
|
|
14 |
$main::lxdebug = bless({}, 'LxDebugMock');
|
|
15 |
|
|
16 |
package main;
|
|
17 |
|
|
18 |
|
|
19 |
my $form = Form->new();
|
|
20 |
|
|
21 |
|
|
22 |
my $config = {};
|
|
23 |
|
|
24 |
|
|
25 |
$config->{numberformat} = '1.000,00';
|
|
26 |
|
|
27 |
is($form->format_amount($config, '1e1', 2), '10,00', 'blaa');
|
|
28 |
is($form->format_amount($config, 1000, 2), '1.000,00', 'blaa');
|
|
29 |
is($form->format_amount($config, 1000.1234, 2), '1.000,12', 'blaa');
|
|
30 |
is($form->format_amount($config, 1000000000.1234, 2), '1.000.000.000,12', 'blaa');
|
|
31 |
is($form->format_amount($config, -1000000000.1234, 2), '-1.000.000.000,12', 'blaa');
|
|
32 |
|
|
33 |
|
|
34 |
$config->{numberformat} = '1,000.00';
|
|
35 |
|
|
36 |
is($form->format_amount($config, '1e1', 2), '10.00', 'blaa');
|
|
37 |
is($form->format_amount($config, 1000, 2), '1,000.00', 'blaa');
|
|
38 |
is($form->format_amount($config, 1000.1234, 2), '1,000.12', 'blaa');
|
|
39 |
is($form->format_amount($config, 1000000000.1234, 2), '1,000,000,000.12', 'blaa');
|
|
40 |
is($form->format_amount($config, -1000000000.1234, 2), '-1,000,000,000.12', 'blaa');
|
|
41 |
|
|
42 |
done_testing;
|
|
43 |
|
|
44 |
1;
|
SL::Form::format_amount formatiert Zahlen auch aus der Exponentialschreibweise.
+Tests für SL::Form::format_amount
fixt #1904