File: upgrade.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (40 lines) | stat: -rw-r--r-- 1,053 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- mode: perl; -*-

use strict;
use warnings;

use Test::More tests => 2136            # tests in require'd file
                         + 6;           # tests in this file

use Math::BigInt;
use Math::BigFloat;

my $x = Math::BigInt -> new(9);
my $y = Math::BigInt -> new(4);

# Without upgrading.

my $zi = $x / $y;
cmp_ok($zi, "==", 2, "9/4 = 2 without upgrading");
is(ref($zi), "Math::BigInt", "9/4 gives a Math::BigInt without upgrading");

# With upgrading.

Math::BigInt -> upgrade("Math::BigFloat");
my $zf = $x / $y;
cmp_ok($zf, "==", 2.25, "9/4 = 2.25 with upgrading");
is(ref($zf), "Math::BigFloat", "9/4 gives a Math::BigFloat with upgrading");

# Other tests.

our ($CLASS, $EXPECTED_CLASS, $LIB);
$CLASS          = "Math::BigInt";
$EXPECTED_CLASS = "Math::BigFloat";
$LIB            = "Math::BigInt::Calc";         # backend

is(Math::BigInt->upgrade(), "Math::BigFloat",
   "Math::BigInt->upgrade()");
is(Math::BigInt->downgrade(), undef,
   "Math::BigInt->downgrade()");

require './t/upgrade.inc';      # all tests here for sharing