3 # test calling conventions, and :constant overloading
11 # to locate the testing files
12 my $location = $0; $location =~ s/calling.t//i;
15 # testing with the core distribution
20 unshift @INC, '../lib';
26 unshift @INC, File::Spec->catdir(File::Spec->updir, $location);
30 unshift @INC, $location;
32 print "# INC = @INC\n";
37 for (1..$tests) { skip (1,'Not supported on older Perls'); }
42 package Math::BigInt::Test;
46 @ISA = qw/Math::BigInt/; # child of MBI
49 package Math::BigFloat::Test;
53 @ISA = qw/Math::BigFloat/; # child of MBI
62 my $version = '1.61'; # adjust manually to match latest release
64 ###############################################################################
65 # check whether op's accept normal strings, even when inherited by subclasses
67 # do one positive and one negative test to avoid false positives by "accident"
69 my ($func,@args,$ans,$rc,$class,$try);
73 next if /^#/; # skip comments
80 @args = split(/:/,$_,99);
83 Math::BigInt Math::BigFloat Math::BigInt::Test Math::BigFloat::Test/)
85 $try = "'$args[0]'"; # quote it
86 $try = $args[0] if $args[0] =~ /'/; # already quoted
87 $try = '' if $args[0] eq ''; # undef, no argument
88 $try = "$class\->$func($try);";
90 print "# Tried: '$try'\n" if !ok ($rc, $ans);
96 $class = 'Math::BigInt';
98 # XXX TODO this test does not work/fail.
99 # test whether use Math::BigInt qw/version/ works
100 #$try = "use $class ($version.'1');";
101 #$try .= ' $x = $class->new(123); $x = "$x";';
103 #ok_undef ( $x ); # should result in error!
105 # test whether fallback to calc works
106 $try = "use $class ($version,'lib','foo, bar , ');";
107 $try .= "$class\->config()->{lib};";
109 ok ( $ans, "Math::BigInt::Calc");
111 # test whether constant works or not, also test for qw($version)
112 # bgcd() is present in subclass, too
113 $try = "use Math::BigInt ($version,'bgcd',':constant');";
114 $try .= ' $x = 2**150; bgcd($x); $x = "$x";';
116 ok ( $ans, "1427247692705959881058285969449495136382746624");
118 # test wether Math::BigInt::Scalar via use works (w/ dff. spellings of calc)
119 $try = "use $class ($version,'lib','Scalar');";
120 $try .= ' $x = 2**10; $x = "$x";';
121 $ans = eval $try; ok ( $ans, "1024");
122 $try = "use $class ($version,'LiB','$class\::Scalar');";
123 $try .= ' $x = 2**10; $x = "$x";';
124 $ans = eval $try; ok ( $ans, "1024");
128 ###############################################################################
129 # Perl 5.005 does not like ok ($x,undef)
135 ok (1,1) and return if !defined $x;