1# -*- mode: perl; -*- 2 3use strict; 4use warnings; 5 6use Test::More tests => 1401; 7 8my $class; 9 10BEGIN { $class = 'Math::BigFloat'; } 11BEGIN { use_ok($class, '1.999710'); } 12 13my @data; 14my $space = "\t\r\n "; 15 16while (<DATA>) { 17 s/#.*$//; # remove comments 18 s/\s+$//; # remove trailing whitespace 19 next unless length; # skip empty lines 20 21 my ($in0, $out0) = split /:/; 22 23 push @data, [ $in0, $out0 ], 24 [ $in0 . $space, $out0 ], 25 [ $space . $in0, $out0 ], 26 [ $space . $in0 . $space, $out0 ]; 27} 28 29for my $entry (@data) { 30 my ($in0, $out0) = @$entry; 31 32 # As class method. 33 34 { 35 my $x; 36 my $test = qq|\$x = $class -> from_oct("$in0");|; 37 38 eval $test; 39 die $@ if $@; # this should never happen 40 41 subtest $test, sub { 42 plan tests => 2, 43 44 is(ref($x), $class, "output arg is a $class"); 45 is($x, $out0, 'output arg has the right value'); 46 }; 47 } 48 49 # As instance method. 50 51 { 52 for my $str ("-1", "0", "1", "-inf", "+inf", "NaN") { 53 my $x; 54 my $test = qq|\$x = $class -> new("$str");| 55 . qq| \$x -> from_oct("$in0");|; 56 57 eval $test; 58 die $@ if $@; # this should never happen 59 60 subtest $test, sub { 61 plan tests => 2, 62 63 is(ref($x), $class, "output arg is a $class"); 64 is($x, $out0, 'output arg has the right value'); 65 }; 66 } 67 } 68} 69 70__END__ 71 72# Without "0o" prefix. 73 7401p+0:1 750.4p+1:1 760.2p+2:1 770.1p+3:1 780.04p+4:1 7902p-1:1 8004p-2:1 81010p-3:1 82 83-1p+0:-1 84 850p+0:0 860p+7:0 870p-7:0 880.p+0:0 89.0p+0:0 900.0p+0:0 91 92145376:51966 930145376:51966 9400145376:51966 95 963.1p+2:12.5 9722.15p-1:9.1015625 98-0.361152746757p+32:-2023406814.9375 9944.3212636115p+30:39093746765 100 101.p+0:NaN 102 103# With "0o" prefix. 104 1050o01p+0:1 1060o0.4p+1:1 1070o0.2p+2:1 1080o0.1p+3:1 1090o0.04p+4:1 1100o02p-1:1 1110o04p-2:1 1120o010p-3:1 113 114-0o1p+0:-1 115 1160o0p+0:0 1170o0p+7:0 1180o0p-7:0 1190o0.p+0:0 1200o.0p+0:0 1210o0.0p+0:0 122 1230o145376:51966 1240O145376:51966 125o145376:51966 126O145376:51966 127 1280o3.1p+2:12.5 1290o22.15p-1:9.1015625 130-0o0.361152746757p+32:-2023406814.9375 1310o44.3212636115p+30:39093746765 132 1330o.p+0:NaN 134 135NaN:NaN 136+inf:NaN 137-inf:NaN 138