1# -*- mode: perl; -*-
2
3use strict;
4use warnings;
5
6use Test::More;
7
8plan skip_all => 'Need at least Perl v5.10.1' if $] < "5.010001";
9
10plan tests => 96;
11
12note "\nbigint -> bignum -> bigrat\n\n";
13
14{
15    note "use bigint;";
16    use bigint;
17    is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
18    is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
19
20    {
21        note "use bignum;";
22        use bignum;
23        is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
24        is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
25
26        {
27            note "use bigrat;";
28            use bigrat;
29            is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
30            is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
31
32            note "no bigrat;";
33            no bigrat;
34            is(ref(hex("1")), "", 'ref(hex("1"))');
35            is(ref(oct("1")), "", 'ref(oct("1"))');
36        }
37
38        is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
39        is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
40
41        note "no bignum;";
42        no bignum;
43        is(ref(hex("1")), "", 'ref(hex("1"))');
44        is(ref(oct("1")), "", 'ref(oct("1"))');
45    }
46
47    is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
48    is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
49
50    note "no bigint;";
51    no bigint;
52    is(ref(hex("1")), "", 'ref(hex("1"))');
53    is(ref(oct("1")), "", 'ref(oct("1"))');
54}
55
56note "\nbigint -> bigrat -> bignum\n\n";
57
58{
59    note "use bigint;";
60    use bigint;
61    is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
62    is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
63
64    {
65        note "use bigrat;";
66        use bigrat;
67        is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
68        is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
69
70        {
71            note "use bignum;";
72            use bignum;
73            is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
74            is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
75
76            note "no bignum;";
77            no bignum;
78            is(ref(hex("1")), "", 'ref(hex("1"))');
79            is(ref(oct("1")), "", 'ref(oct("1"))');
80        }
81
82        is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
83        is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
84
85        note "no bigrat;";
86        no bigrat;
87        is(ref(hex("1")), "", 'ref(hex("1"))');
88        is(ref(oct("1")), "", 'ref(oct("1"))');
89    }
90
91    is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
92    is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
93
94    note "no bigint;";
95    no bigint;
96    is(ref(hex("1")), "", 'ref(hex("1"))');
97    is(ref(oct("1")), "", 'ref(oct("1"))');
98}
99
100note "\nbignum -> bigint -> bigrat\n\n";
101
102{
103    note "use bignum;";
104    use bignum;
105    is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
106    is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
107
108    {
109        note "use bigint;";
110        use bigint;
111        is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
112        is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
113
114        {
115            note "use bigrat;";
116            use bigrat;
117            is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
118            is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
119
120            note "no bigrat;";
121            no bigrat;
122            is(ref(hex("1")), "", 'ref(hex("1"))');
123            is(ref(oct("1")), "", 'ref(oct("1"))');
124        }
125
126        is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
127        is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
128
129        note "no bigint;";
130        no bigint;
131        is(ref(hex("1")), "", 'ref(hex("1"))');
132        is(ref(oct("1")), "", 'ref(oct("1"))');
133    }
134
135    is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
136    is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
137
138    note "no bignum;";
139    no bignum;
140    is(ref(hex("1")), "", 'ref(hex("1"))');
141    is(ref(oct("1")), "", 'ref(oct("1"))');
142}
143
144note "\nbignum -> bigrat -> bigint\n\n";
145
146{
147    note "use bignum;";
148    use bignum;
149    is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
150    is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
151
152    {
153        note "use bigrat;";
154        use bigrat;
155        is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
156        is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
157
158        {
159            note "use bigint;";
160            use bigint;
161            is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
162            is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
163
164            note "no bigint;";
165            no bigint;
166            is(ref(hex("1")), "", 'ref(hex("1"))');
167            is(ref(oct("1")), "", 'ref(oct("1"))');
168        }
169
170        is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
171        is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
172
173        note "no bigrat;";
174        no bigrat;
175        is(ref(hex("1")), "", 'ref(hex("1"))');
176        is(ref(oct("1")), "", 'ref(oct("1"))');
177    }
178
179    is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
180    is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
181
182    note "no bignum;";
183    no bignum;
184    is(ref(hex("1")), "", 'ref(hex("1"))');
185    is(ref(oct("1")), "", 'ref(oct("1"))');
186}
187
188note "\nbigrat -> bigint -> bignum\n\n";
189
190{
191    note "use bigrat;";
192    use bigrat;
193    is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
194    is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
195
196    {
197        note "use bigint;";
198        use bigint;
199        is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
200        is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
201
202        {
203            note "use bignum;";
204            use bignum;
205            is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
206            is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
207
208            note "no bignum;";
209            no bignum;
210            is(ref(hex("1")), "", 'ref(hex("1"))');
211            is(ref(oct("1")), "", 'ref(oct("1"))');
212        }
213
214        is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
215        is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
216
217        note "no bigint;";
218        no bigint;
219        is(ref(hex("1")), "", 'ref(hex("1"))');
220        is(ref(oct("1")), "", 'ref(oct("1"))');
221    }
222
223    is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
224    is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
225
226    note "no bigrat;";
227    no bigrat;
228    is(ref(hex("1")), "", 'ref(hex("1"))');
229    is(ref(oct("1")), "", 'ref(oct("1"))');
230}
231
232note "\nbigrat -> bignum -> bigint\n\n";
233
234{
235    note "use bigrat;";
236    use bigrat;
237    is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
238    is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
239
240    {
241        note "use bignum;";
242        use bignum;
243        is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
244        is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
245
246        {
247            note "use bigint;";
248            use bigint;
249            is(ref(hex("1")), "Math::BigInt", 'ref(hex("1"))');
250            is(ref(oct("1")), "Math::BigInt", 'ref(oct("1"))');
251
252            note "no bigint;";
253            no bigint;
254            is(ref(hex("1")), "", 'ref(hex("1"))');
255            is(ref(oct("1")), "", 'ref(oct("1"))');
256        }
257
258        is(ref(hex("1")), "Math::BigFloat", 'ref(hex("1"))');
259        is(ref(oct("1")), "Math::BigFloat", 'ref(oct("1"))');
260
261        note "no bignum;";
262        no bignum;
263        is(ref(hex("1")), "", 'ref(hex("1"))');
264        is(ref(oct("1")), "", 'ref(oct("1"))');
265    }
266
267    is(ref(hex("1")), "Math::BigRat", 'ref(hex("1"))');
268    is(ref(oct("1")), "Math::BigRat", 'ref(oct("1"))');
269
270    note "no bigrat;";
271    no bigrat;
272    is(ref(hex("1")), "", 'ref(hex("1"))');
273    is(ref(oct("1")), "", 'ref(oct("1"))');
274}
275