Commit | Line | Data |
---|---|---|
1ddff52a JH |
1 | #!/usr/bin/perl -w |
2 | ||
1ddff52a | 3 | use strict; |
3167abe5 | 4 | use Test::More tests => 6; |
1ddff52a JH |
5 | |
6 | ############################################################################### | |
7 | package Math::BigFloat::Test; | |
8 | ||
9 | use Math::BigFloat; | |
10 | require Exporter; | |
11 | use vars qw/@ISA/; | |
12 | @ISA = qw/Exporter Math::BigFloat/; | |
13 | ||
14 | use overload; | |
15 | ||
16 | sub isa | |
17 | { | |
18 | my ($self,$class) = @_; | |
19 | return if $class =~ /^Math::Big(Int|Float)/; # we aren't one of these | |
20 | UNIVERSAL::isa($self,$class); | |
21 | } | |
22 | ||
23 | sub bmul | |
24 | { | |
25 | return __PACKAGE__->new(123); | |
26 | } | |
27 | ||
28 | sub badd | |
29 | { | |
30 | return __PACKAGE__->new(321); | |
31 | } | |
32 | ||
33 | ############################################################################### | |
34 | package main; | |
35 | ||
36 | # use Math::BigInt upgrade => 'Math::BigFloat'; | |
37 | use Math::BigFloat upgrade => 'Math::BigFloat::Test'; | |
38 | ||
39 | use vars qw ($scale $class $try $x $y $z $f @args $ans $ans1 $ans1_str $setup | |
40 | $ECL $CL); | |
41 | $class = "Math::BigFloat"; | |
42 | $CL = "Math::BigInt::Calc"; | |
43 | $ECL = "Math::BigFloat::Test"; | |
44 | ||
3167abe5 NC |
45 | is (Math::BigFloat->upgrade(),$ECL); |
46 | is (Math::BigFloat->downgrade()||'',''); | |
1ddff52a JH |
47 | |
48 | $x = $class->new(123); $y = $ECL->new(123); $z = $x->bmul($y); | |
3167abe5 | 49 | is (ref($z),$ECL); is ($z,123); |
1ddff52a JH |
50 | |
51 | $x = $class->new(123); $y = $ECL->new(123); $z = $x->badd($y); | |
3167abe5 | 52 | is (ref($z),$ECL); is ($z,321); |
1ddff52a JH |
53 | |
54 | ||
55 | ||
56 | # not yet: | |
57 | # require 'upgrade.inc'; # all tests here for sharing |