summaryrefslogtreecommitdiff
path: root/lib/Math
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-03-04 16:46:49 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-04 16:46:49 +0000
commitda687c2af97fa1d5b33113fe1498d87de2b43b2a (patch)
treef08462d6e856c212928ef76bb7bf03efa890c98d /lib/Math
parent161720b2bf5213fa196f98898fc983804d595589 (diff)
downloadperl-da687c2af97fa1d5b33113fe1498d87de2b43b2a.tar.gz
A new M::BI test.
p4raw-id: //depot/perl@15006
Diffstat (limited to 'lib/Math')
-rw-r--r--lib/Math/BigInt/t/isa.t59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/Math/BigInt/t/isa.t b/lib/Math/BigInt/t/isa.t
new file mode 100644
index 0000000000..adb80f9331
--- /dev/null
+++ b/lib/Math/BigInt/t/isa.t
@@ -0,0 +1,59 @@
+#!/usr/bin/perl -w
+
+use Test;
+use strict;
+
+BEGIN
+ {
+ $| = 1;
+ # to locate the testing files
+ my $location = $0; $location =~ s/isa.t//i;
+ if ($ENV{PERL_CORE})
+ {
+ # testing with the core distribution
+ @INC = qw(../t/lib);
+ }
+ unshift @INC, qw(../lib);
+ if (-d 't')
+ {
+ chdir 't';
+ require File::Spec;
+ unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
+ }
+ else
+ {
+ unshift @INC, $location;
+ }
+ print "# INC = @INC\n";
+
+ plan tests => 7;
+ }
+
+use Math::BigInt::Subclass;
+use Math::BigFloat::Subclass;
+use Math::BigInt;
+use Math::BigFloat;
+
+use vars qw ($class $try $x $y $f @args $ans $ans1 $ans1_str $setup $CL);
+$class = "Math::BigInt::Subclass";
+$CL = "Math::BigInt::Calc";
+
+# Check that a subclass is still considered a BigInt
+ok ($class->new(123)->isa('Math::BigInt'),1);
+
+# ditto for plain Math::BigInt
+ok (Math::BigInt->new(123)->isa('Math::BigInt'),1);
+
+# But Math::BigFloats aren't
+ok (Math::BigFloat->new(123)->isa('Math::BigInt') || 0,0);
+
+# see what happens if we feed a Math::BigFloat into new()
+$x = Math::BigInt->new(Math::BigFloat->new(123));
+ok (ref($x),'Math::BigInt');
+ok ($x->isa('Math::BigInt'),1);
+
+# ditto for subclass
+$x = Math::BigInt->new(Math::BigFloat->new(123));
+ok (ref($x),'Math::BigInt');
+ok ($x->isa('Math::BigInt'),1);
+