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
CommitLineData
1ddff52a
JH
1#!/usr/bin/perl -w
2
1ddff52a 3use strict;
3167abe5 4use Test::More tests => 6;
1ddff52a
JH
5
6###############################################################################
7package Math::BigFloat::Test;
8
9use Math::BigFloat;
10require Exporter;
11use vars qw/@ISA/;
12@ISA = qw/Exporter Math::BigFloat/;
13
14use overload;
15
16sub 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
23sub bmul
24 {
25 return __PACKAGE__->new(123);
26 }
27
28sub badd
29 {
30 return __PACKAGE__->new(321);
31 }
32
33###############################################################################
34package main;
35
36# use Math::BigInt upgrade => 'Math::BigFloat';
37use Math::BigFloat upgrade => 'Math::BigFloat::Test';
38
39use 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
45is (Math::BigFloat->upgrade(),$ECL);
46is (Math::BigFloat->downgrade()||'','');
1ddff52a
JH
47
48$x = $class->new(123); $y = $ECL->new(123); $z = $x->bmul($y);
3167abe5 49is (ref($z),$ECL); is ($z,123);
1ddff52a
JH
50
51$x = $class->new(123); $y = $ECL->new(123); $z = $x->badd($y);
3167abe5 52is (ref($z),$ECL); is ($z,321);
1ddff52a
JH
53
54
55
56# not yet:
57# require 'upgrade.inc'; # all tests here for sharing