File: upgrade.t

package info (click to toggle)
perl 5.36.0-7%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 120,064 kB
  • sloc: ansic: 650,199; perl: 478,052; sh: 70,710; pascal: 8,435; xml: 2,428; yacc: 1,230; makefile: 1,175; cpp: 208; lisp: 1
file content (40 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download
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 => 2134            # 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",
   qq/Math::BigInt->upgrade()/);
is(Math::BigInt->downgrade() || "", "",
   qq/Math::BigInt->downgrade() || ""/);

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