remove hardcoded cmd shell in testsuite
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / bigintc.t
CommitLineData
0716bf9b 1#!/usr/bin/perl -w
2
3use strict;
4use Test;
5
6BEGIN
7 {
8 $| = 1;
9 # chdir 't' if -d 't';
10 unshift @INC, '../lib'; # for running manually
11 plan tests => 29;
12 }
13
14# testing of Math::BigInt::Calc, primarily for interface/api and not for the
15# math functionality
16
17use Math::BigInt::Calc;
18
19my $s123 = \'123'; my $s321 = \'321';
20# _new and _str
21my $x = _new($s123); my $u = _str($x);
22ok ($$u,123); ok ($x->[0],123); ok (@$x,1);
23my $y = _new($s321);
24
25# _add, _sub, _mul, _div
26
27ok (${_str(_add($x,$y))},444);
28ok (${_str(_sub($x,$y))},123);
29ok (${_str(_mul($x,$y))},39483);
30ok (${_str(_div($x,$y))},123);
31
32# division with reminder
33my $z = _new(\"111");
34 _mul($x,$y);
35ok (${_str($x)},39483);
36_add($x,$z);
37ok (${_str($x)},39594);
38my ($re,$rr) = _div($x,$y);
39
40ok (${_str($re)},123); ok (${_str($rr)},111);
41
42# _copy
43$x = _new(\"12356");
44ok (${_str(_copy($x))},12356);
45
46# digit
47$x = _new(\"123456789");
48ok (_digit($x,0),9);
49ok (_digit($x,1),8);
50ok (_digit($x,2),7);
51ok (_digit($x,-1),1);
52ok (_digit($x,-2),2);
53ok (_digit($x,-3),3);
54
55# is_zero, _is_one, _one, _zero
56$x = _new(\"12356");
57ok (_is_zero($x),0);
58ok (_is_one($x),0);
59
60# _zeros
61$x = _new(\"1256000000"); ok (_zeros($x),6);
62$x = _new(\"152"); ok (_zeros($x),0);
63$x = _new(\"123000"); ok (_zeros($x),3);
64
65ok (_is_one(_one()),1); ok (_is_one(_zero()),0);
66ok (_is_zero(_zero()),1); ok (_is_zero(_one()),0);
67
68ok (_check($x),0);
69ok (_check(123),'123 is not a reference');
70
71# done
72
731;