3 # Math::BigFloat->new had a bug where it would assume any object is a
4 # BigInt which broke overloaded non-BigInts.
6 use Test::More tests => 4;
9 package Overloaded::Num;
11 use overload '0+' => sub { ${$_[0]} },
14 my($class, $num) = @_;
15 return bless \$num, $class;
23 my $overloaded_num = Overloaded::Num->new(2.23);
24 is $overloaded_num, 2.23;
26 my $bigfloat = Math::BigFloat->new($overloaded_num);
27 is $bigfloat, 2.23, 'BigFloat->new accepts overloaded numbers';
29 my $bigint = Math::BigInt->new(Overloaded::Num->new(3));
30 is $bigint, 3, 'BigInt->new accepts overloaded numbers';
32 is( Math::BigFloat->new($bigint), 3, 'BigFloat from BigInt' );