1# -*- mode: perl; -*-
2
3use strict;
4use warnings;
5
6use Test::More tests => 10;
7
8use lib "t";
9
10# First load Math::BigFloat with Math::BigInt::Calc.
11
12use Math::BigFloat lib => "Calc";
13
14is(Math::BigFloat -> config("lib"), "Math::BigInt::Calc",
15   'Math::BigFloat -> config("lib")');
16
17is(ref Math::BigFloat -> bzero() -> {_m}, "Math::BigInt::Calc",
18   'ref Math::BigFloat -> bzero() -> {_m}');
19
20# Math::BigInt will know that we loaded Math::BigInt::Calc.
21
22require Math::BigInt;
23
24is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
25   'Math::BigInt -> config("lib")');
26
27is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
28   "ref Math::BigInt -> bzero() -> {value}");
29
30# Now load Math::BigFloat again with a different lib.
31
32Math::BigFloat -> import(lib => "BareCalc");
33
34is(Math::BigFloat -> config("lib"), "Math::BigInt::Calc",
35   'Math::BigFloat -> config("lib")');
36
37is(ref Math::BigFloat -> bzero() -> {_m}, "Math::BigInt::Calc",
38   'ref Math::BigFloat -> bzero() -> {_m}');
39
40# See if Math::BigInt knows about Math::BigInt::BareCalc.
41
42is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
43   "Math::BigInt is using library Math::BigInt::Calc");
44
45is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
46   "ref Math::BigInt -> bzero() -> {value}");
47
48# See that Math::BigInt supports "only".
49
50eval { Math::BigInt -> import("only" => "Calc") };
51subtest 'Math::BigInt -> import("only" => "Calc")' => sub {
52    plan tests => 3;
53
54    is($@, "", '$@ is empty');
55    is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
56       'Math::BigInt -> config("lib")');
57    is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
58       "ref Math::BigInt -> bzero() -> {value}");
59};
60
61# See that Math::BigInt supports "try".
62
63eval { Math::BigInt -> import("try" => "BareCalc") };
64subtest 'Math::BigInt -> import("try" => "BareCalc")' => sub {
65    plan tests => 3;
66
67    is($@, "", '$@ is empty');
68    is(Math::BigInt -> config("lib"), "Math::BigInt::Calc",
69       'Math::BigInt -> config("lib")');
70    is(ref Math::BigInt -> bzero() -> {value}, "Math::BigInt::Calc",
71       "ref Math::BigInt -> bzero() -> {value}");
72}
73