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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
# -*- mode: perl; -*-
use strict;
use warnings;
use Test::More tests => 22;
use Math::BigInt;
while (<DATA>) {
s/#.*$//; # remove comments
s/\s+$//; # remove trailing whitespace
next unless length; # skip empty lines
my ($in0, $out0, $out1, $out2, $out3) = split /:/;
my ($ss, $sa, $es, $ea);
my $test = q|($ss, $sa, $es, $ea) = |
. qq|Math::BigInt -> _dec_str_to_dec_str_parts("$in0")|;
eval $test;
die $@ if $@; # this should never happen
subtest $test => sub {
plan tests => 4;
is($ss, $out0, 'sign of the significand');
is($sa, $out1, 'absolute value of the significand');
is($es, $out2, 'sign of the exponent');
is($ea, $out3, 'absolute value of the exponent');
};
}
__DATA__
3:+:3:+:0
3e+0:+:3:+:0
3e-0:+:3:+:0
-3e+0:-:3:+:0
-3e-0:-:3:+:0
0:+:0:+:0
0e-0:+:0:+:0
0e+0:+:0:+:0
0e-7:+:0:+:0
0e+7:+:0:+:0
0.0120:+:.012:+:0
0120.0:+:120:+:0
0120.0340:+:120.034:+:0
1.e0:+:1:+:0
00.0012003400E0056007800:+:.00120034:+:56007800
+1__2__.__3__4__e+5__6__:+:12.34:+:56
+1__2__.__3__4__e-5__6__:+:12.34:-:56
-1__2__.__3__4__e+5__6__:-:12.34:+:56
-1__2__.__3__4__e-5__6__:-:12.34:-:56
1__2__.__3__4__e5__6__:+:12.34:+:56
1__2__.__3__4__e-5__6__:+:12.34:-:56
-1__2__.__3__4__e5__6__:-:12.34:+:56
|