VMS: adds capability to control more configuration stuff with
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / calling.t
CommitLineData
ee15d750 1#!/usr/bin/perl -w
2
3# test calling conventions
4
5use strict;
6use Test;
7
8BEGIN
9 {
10 $| = 1;
11 # chdir 't' if -d 't';
12 unshift @INC, '../lib'; # for running manually
13 plan tests => 100;
14 }
15
16package Math::BigInt::Test;
17
18use Math::BigInt;
19use vars qw/@ISA/;
20@ISA = qw/Math::BigInt/; # child of MBI
21use overload;
22
23package Math::BigFloat::Test;
24
25use Math::BigFloat;
26use vars qw/@ISA/;
27@ISA = qw/Math::BigFloat/; # child of MBI
28use overload;
29
30package main;
31
32use Math::BigInt;
33use Math::BigFloat;
34
35my ($x,$y,$z,$u);
36
37###############################################################################
38# check whether op's accept normal strings, even when inherited by subclasses
39
40# do one positive and one negative test to avoid false positives by "accident"
41
42my ($func,@args,$ans,$rc,$class,$try);
43while (<DATA>)
44 {
45 chop;
46 next if /^#/; # skip comments
47 if (s/^&//)
48 {
49 $func = $_;
50 }
51 else
52 {
53 @args = split(/:/,$_,99);
54 $ans = pop @args;
55 foreach $class (qw/
56 Math::BigInt Math::BigFloat Math::BigInt::Test Math::BigFloat::Test/)
57 {
58 $try = "$class\->$func('$args[0]');";
59 $rc = eval $try;
60 print "# Tried: '$try'\n" if !ok ($rc, $ans);
61 }
62 }
63
64 }
65
66# all done
67
68###############################################################################
69# Perl 5.005 does not like ok ($x,undef)
70
71sub ok_undef
72 {
73 my $x = shift;
74
75 ok (1,1) and return if !defined $x;
76 ok ($x,'undef');
77 }
78
79__END__
80&is_zero
811:0
820:1
83&is_one
841:1
850:0
86&is_positive
871:1
88-1:0
89&is_negative
901:0
91-1:1
92&is_nan
93abc:1
941:0
95&is_inf
96inf:1
970:0
98&bstr
995:5
10010:10
101abc:NaN
102+inf:inf
103-inf:-inf
104&bsstr
1051:1e+0
1060:0e+1
1072:2e+0
108200:2e+2
109&babs
110-1:1
1111:1
112&bnot
113-2:1
1141:-2