summaryrefslogtreecommitdiff
path: root/xt/author/lib_load-mbf-mbi.t
blob: e18476ed49a2627b21be1cbde7f8a2d8d5a4f06d (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- mode: perl; -*-

use strict;
use warnings;

use Test::More tests => 10;

use lib "t";

# First load Math::BigFloat with Math::BigInt::Calc.

use Math::BigFloat lib => "Calc";

is(Math::BigFloat -> config("lib"), "Math::BigInt::Calc",
   'Math::BigFloat -> config("lib")');

is(ref Math::BigFloat -> bzero() -> {_m}, "Math::BigInt::Calc",
   'ref Math::BigFloat -> bzero() -> {_m}');

# Math::BigInt will know that we loaded Math::BigInt::Calc.

require Math::BigInt;

is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
   'Math::BigInt -> config("lib")');

is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
   "ref Math::BigInt -> bzero() -> {value}");

# Now load Math::BigFloat again with a different lib.

Math::BigFloat -> import(lib => "BareCalc");

is(Math::BigFloat -> config("lib"), "Math::BigInt::Calc",
   'Math::BigFloat -> config("lib")');

is(ref Math::BigFloat -> bzero() -> {_m}, "Math::BigInt::Calc",
   'ref Math::BigFloat -> bzero() -> {_m}');

# See if Math::BigInt knows about Math::BigInt::BareCalc.

is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
   "Math::BigInt is using library Math::BigInt::Calc");

is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
   "ref Math::BigInt -> bzero() -> {value}");

# See that Math::BigInt supports "only".

eval { Math::BigInt -> import("only" => "Calc") };
subtest 'Math::BigInt -> import("only" => "Calc")' => sub {
    plan tests => 3;

    is($@, "", '$@ is empty');
    is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
       'Math::BigInt -> config("lib")');
    is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
       "ref Math::BigInt -> bzero() -> {value}");
};

# See that Math::BigInt supports "try".

eval { Math::BigInt -> import("try" => "BareCalc") };
subtest 'Math::BigInt -> import("try" => "BareCalc")' => sub {
    plan tests => 3;

    is($@, "", '$@ is empty');
    is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
       'Math::BigInt -> config("lib")');
    is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
       "ref Math::BigInt -> bzero() -> {value}");
}