This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document string- and number-specific bitops in perlop
[perl5.git] / dist / Math-BigInt / t / upgradef.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More tests => 6;
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
45 is (Math::BigFloat->upgrade(),$ECL);
46 is (Math::BigFloat->downgrade()||'','');
47
48 $x = $class->new(123); $y = $ECL->new(123); $z = $x->bmul($y);
49 is (ref($z),$ECL); is ($z,123);
50
51 $x = $class->new(123); $y = $ECL->new(123); $z = $x->badd($y);
52 is (ref($z),$ECL); is ($z,321);
53
54
55
56 # not yet:
57 # require 'upgrade.inc';        # all tests here for sharing