File: display_precision.t

package info (click to toggle)
libmath-matrixreal-perl 2.13-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,120 kB
  • sloc: perl: 2,837; makefile: 8
file content (34 lines) | stat: -rw-r--r-- 1,232 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use Test::More tests => 3;
use File::Spec;
use lib File::Spec->catfile("..","lib");
use Math::MatrixReal;
do 'funcs.pl';

my $matrix  = Math::MatrixReal->new_diag([1,2,3,4]);
$matrix->display_precision(5);

my $correct =  Math::MatrixReal->new_from_string(<<END);
[  1.00000             0.00000             0.00000             0.00000            ]
[  0.00000             2.00000             0.00000             0.00000            ]
[  0.00000             0.00000             3.00000             0.00000            ]
[  0.00000             0.00000             0.00000             4.00000            ]
END
$correct->display_precision(5);

ok( "$matrix" eq "$correct", 'display_precision(n)' );

$matrix->display_precision(0);
$correct = Math::MatrixReal->new_from_string(<<END);
[  1           0           0           0          ]
[  0           2           0           0          ]
[  0           0           3           0          ]
[  0           0           0           4          ]
END
$correct->display_precision(0);
ok( "$matrix" eq "$correct", 'display_precision(0)' );

{
    assert_dies ( sub { Math::MatrixReal->new(5,5)->display_precision(-42) },
                'display_precision dies on negative arg, matey!' 
    );
}