1# -*- mode: perl; -*- 2 3use strict; 4use warnings; 5 6use Test::More tests => 220; 7 8use Math::BigInt; 9 10while (<DATA>) { 11 s/#.*$//; # remove comments 12 s/\s+$//; # remove trailing whitespace 13 next unless length; # skip empty lines 14 15 my ($x_str, $expected) = split /:/; 16 my ($x, $str); 17 18 my $test = qq|\$x = Math::BigInt -> new("$x_str");| 19 . qq| \$str = \$x -> bdstr();|; 20 21 note "\n$test\n\n"; 22 eval $test; 23 24 is($str, $expected, qq|input value is "$x_str"|); 25 is($x, $x_str, "input object is unmodified"); 26} 27 28__DATA__ 29 30NaN:NaN 31 32inf:inf 33-inf:-inf 34 350:0 36 37# positive numbers 38 391:1 4010:10 41100:100 421000:1000 4310000:10000 44100000:100000 451000000:1000000 4610000000:10000000 47100000000:100000000 481000000000:1000000000 4910000000000:10000000000 50100000000000:100000000000 511000000000000:1000000000000 52 5312:12 54120:120 551200:1200 5612000:12000 57120000:120000 581200000:1200000 5912000000:12000000 60120000000:120000000 611200000000:1200000000 6212000000000:12000000000 63120000000000:120000000000 641200000000000:1200000000000 65 66123:123 671230:1230 6812300:12300 69123000:123000 701230000:1230000 7112300000:12300000 72123000000:123000000 731230000000:1230000000 7412300000000:12300000000 75123000000000:123000000000 761230000000000:1230000000000 77 781234:1234 7912340:12340 80123400:123400 811234000:1234000 8212340000:12340000 83123400000:123400000 841234000000:1234000000 8512340000000:12340000000 86123400000000:123400000000 871234000000000:1234000000000 88 893:3 9031:31 91314:314 923141:3141 9331415:31415 94314159:314159 953141592:3141592 96 97# negative numbers 98 99-1:-1 100-10:-10 101-100:-100 102-1000:-1000 103-10000:-10000 104-100000:-100000 105-1000000:-1000000 106-10000000:-10000000 107-100000000:-100000000 108-1000000000:-1000000000 109-10000000000:-10000000000 110-100000000000:-100000000000 111-1000000000000:-1000000000000 112 113-12:-12 114-120:-120 115-1200:-1200 116-12000:-12000 117-120000:-120000 118-1200000:-1200000 119-12000000:-12000000 120-120000000:-120000000 121-1200000000:-1200000000 122-12000000000:-12000000000 123-120000000000:-120000000000 124-1200000000000:-1200000000000 125 126-123:-123 127-1230:-1230 128-12300:-12300 129-123000:-123000 130-1230000:-1230000 131-12300000:-12300000 132-123000000:-123000000 133-1230000000:-1230000000 134-12300000000:-12300000000 135-123000000000:-123000000000 136-1230000000000:-1230000000000 137 138-1234:-1234 139-12340:-12340 140-123400:-123400 141-1234000:-1234000 142-12340000:-12340000 143-123400000:-123400000 144-1234000000:-1234000000 145-12340000000:-12340000000 146-123400000000:-123400000000 147-1234000000000:-1234000000000 148 149-3:-3 150-31:-31 151-314:-314 152-3141:-3141 153-31415:-31415 154-314159:-314159 155-3141592:-3141592 156