File: as_number-mbi.t

package info (click to toggle)
libmath-bigint-perl 1.999838-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,424 kB
  • sloc: perl: 10,236; pascal: 5,387; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 812 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
# -*- mode: perl; -*-

use strict;
use warnings;

use Test::More tests => 2;
use Scalar::Util qw< refaddr >;

use Math::BigInt;

my ($x, $y);

note("as_number() as a class method");

$x = Math::BigInt -> as_number("2");
subtest '$x = Math::BigInt -> as_number("2");' => sub {
    plan tests => 2;
    is(ref($x), 'Math::BigInt', '$x is a Math::BigInt');
    cmp_ok($x, "==", 2, '$x == 2');
};

note("as_number() as an instance method");

$x = Math::BigInt -> new("2"); $y = $x -> as_number();
subtest '$x = Math::BigInt -> new("2"); $y = $x -> as_number();' => sub {
    plan tests => 4;
    is(ref($x), 'Math::BigInt', '$x is a Math::BigInt');
    is(ref($y), 'Math::BigInt', '$y is a Math::BigInt');
    cmp_ok($y, "==", 2, '$y == 2');
    isnt(refaddr($x), refaddr($y), '$x and $y are different objects');
};