Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 72858259

Von Sven Schöling vor etwa 12 Jahren hinzugefügt

  • ID 72858259ef9bad485f7b37ee97f6bc799d433dfd
  • Vorgänger dc03543f
  • Nachfolger 8790e337

t/form/format_amount: boilerplate entfernt, und use once warnung unterdrückt

Unterschiede anzeigen:

t/form/format_amount.t
2 2
use Test::More;
3 3

  
4 4
use lib 't';
5
use Support::TestSetup;
5 6

  
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

  
7
Support::TestSetup::login();
21 8

  
22 9
my $config = {};
23 10

  
24

  
25 11
$config->{numberformat} = '1.000,00';
26 12

  
27
is($form->format_amount($config, '1e1', 2), '10,00', 'format 1e1 (numberformat: 1.000,00)');
28
is($form->format_amount($config, 1000, 2), '1.000,00', 'format 1000 (numberformat: 1.000,00)');
29
is($form->format_amount($config, 1000.1234, 2), '1.000,12', 'format 1000.1234 (numberformat: 1.000,00)');
30
is($form->format_amount($config, 1000000000.1234, 2), '1.000.000.000,12', 'format 1000000000.1234 (numberformat: 1.000,00)');
31
is($form->format_amount($config, -1000000000.1234, 2), '-1.000.000.000,12', 'format -1000000000.1234 (numberformat: 1.000,00)');
13
is($::form->format_amount($config, '1e1', 2), '10,00', 'format 1e1 (numberformat: 1.000,00)');
14
is($::form->format_amount($config, 1000, 2), '1.000,00', 'format 1000 (numberformat: 1.000,00)');
15
is($::form->format_amount($config, 1000.1234, 2), '1.000,12', 'format 1000.1234 (numberformat: 1.000,00)');
16
is($::form->format_amount($config, 1000000000.1234, 2), '1.000.000.000,12', 'format 1000000000.1234 (numberformat: 1.000,00)');
17
is($::form->format_amount($config, -1000000000.1234, 2), '-1.000.000.000,12', 'format -1000000000.1234 (numberformat: 1.000,00)');
32 18

  
33 19

  
34 20
$config->{numberformat} = '1,000.00';
35 21

  
36
is($form->format_amount($config, '1e1', 2), '10.00', 'format 1e1 (numberformat: 1,000.00)');
37
is($form->format_amount($config, 1000, 2), '1,000.00', 'format 1000 (numberformat: 1,000.00)');
38
is($form->format_amount($config, 1000.1234, 2), '1,000.12', 'format 1000.1234 (numberformat: 1,000.00)');
39
is($form->format_amount($config, 1000000000.1234, 2), '1,000,000,000.12', 'format 1000000000.1234 (numberformat: 1,000.00)');
40
is($form->format_amount($config, -1000000000.1234, 2), '-1,000,000,000.12', 'format -1000000000.1234 (numberformat: 1,000.00)');
22
is($::form->format_amount($config, '1e1', 2), '10.00', 'format 1e1 (numberformat: 1,000.00)');
23
is($::form->format_amount($config, 1000, 2), '1,000.00', 'format 1000 (numberformat: 1,000.00)');
24
is($::form->format_amount($config, 1000.1234, 2), '1,000.12', 'format 1000.1234 (numberformat: 1,000.00)');
25
is($::form->format_amount($config, 1000000000.1234, 2), '1,000,000,000.12', 'format 1000000000.1234 (numberformat: 1,000.00)');
26
is($::form->format_amount($config, -1000000000.1234, 2), '-1,000,000,000.12', 'format -1000000000.1234 (numberformat: 1,000.00)');
41 27

  
42 28
done_testing;
43 29

  

Auch abrufbar als: Unified diff