1#!/usr/bin/perl -w 2 3# Math::BigFloat->new had a bug where it would assume any object is a 4# BigInt which broke overloaded non-BigInts. 5 6use Test::More tests => 4; 7 8 9package Overloaded::Num; 10 11use overload '0+' => sub { ${$_[0]} }, 12 fallback => 1; 13sub new { 14 my($class, $num) = @_; 15 return bless \$num, $class; 16} 17 18 19package main; 20 21use Math::BigFloat; 22 23my $overloaded_num = Overloaded::Num->new(2.23); 24is $overloaded_num, 2.23; 25 26my $bigfloat = Math::BigFloat->new($overloaded_num); 27is $bigfloat, 2.23, 'BigFloat->new accepts overloaded numbers'; 28 29my $bigint = Math::BigInt->new(Overloaded::Num->new(3)); 30is $bigint, 3, 'BigInt->new accepts overloaded numbers'; 31 32is( Math::BigFloat->new($bigint), 3, 'BigFloat from BigInt' ); 33