summaryrefslogtreecommitdiff
path: root/cpan/bignum/t/bigint.t
diff options
context:
space:
mode:
Diffstat (limited to 'cpan/bignum/t/bigint.t')
-rw-r--r--cpan/bignum/t/bigint.t71
1 files changed, 51 insertions, 20 deletions
diff --git a/cpan/bignum/t/bigint.t b/cpan/bignum/t/bigint.t
index 4af592f5c1..5a5c00b72c 100644
--- a/cpan/bignum/t/bigint.t
+++ b/cpan/bignum/t/bigint.t
@@ -5,7 +5,7 @@
use strict;
use warnings;
-use Test::More tests => 51;
+use Test::More tests => 66;
use bigint qw/hex oct/;
@@ -87,22 +87,53 @@ is(bigint->round_mode(), 'odd', 'get round mode again');
my $class = 'Math::BigInt';
-is(ref(hex(1)), $class, qq|ref(hex(1)) = $class|);
-is(ref(hex(0x1)), $class, qq|ref(hex(0x1)) = $class|);
-is(ref(hex("af")), $class, qq|ref(hex("af")) = $class|);
-is(ref(hex("0x1")), $class, qq|ref(hex("0x1")) = $class|);
-
-is(hex("af"), Math::BigInt->new(0xaf),
- qq|hex("af") = Math::BigInt->new(0xaf)|);
-
-is(ref(oct("0x1")), $class, qq|ref(oct("0x1")) = $class|);
-is(ref(oct("01")), $class, qq|ref(oct("01")) = $class|);
-is(ref(oct("0b01")), $class, qq|ref(oct("0b01")) = $class|);
-is(ref(oct("1")), $class, qq|ref(oct("1")) = $class|);
-is(ref(oct(" 1")), $class, qq|ref(oct(" 1")) = $class|);
-is(ref(oct(" 0x1")), $class, qq|ref(oct(" 0x1")) = $class|);
-
-is(ref(oct(0x1)), $class, qq|ref(oct(0x1)) = $class|);
-is(ref(oct(01)), $class, qq|ref(oct(01)) = $class|);
-is(ref(oct(0b01)), $class, qq|ref(oct(0b01)) = $class|);
-is(ref(oct(1)), $class, qq|ref(oct(1)) = $class|);
+my @table =
+ (
+
+ [ 'hex(1)', 1 ],
+ [ 'hex(01)', 1 ],
+ [ 'hex(0x1)', 1 ],
+ [ 'hex("01")', 1 ],
+ [ 'hex("0x1")', 1 ],
+ [ 'hex("0X1")', 1 ],
+ [ 'hex("x1")', 1 ],
+ [ 'hex("X1")', 1 ],
+ [ 'hex("af")', 175 ],
+
+ [ 'oct(1)', 1 ],
+ [ 'oct(01)', 1 ],
+ [ 'oct(" 1")', 1 ],
+
+ [ 'oct(0x1)', 1 ],
+ [ 'oct("0x1")', 1 ],
+ [ 'oct("0X1")', 1 ],
+ [ 'oct("x1")', 1 ],
+ [ 'oct("X1")', 1 ],
+ [ 'oct(" 0x1")', 1 ],
+
+ [ 'oct(0b1)', 1 ],
+ [ 'oct("0b1")', 1 ],
+ [ 'oct("0B1")', 1 ],
+ [ 'oct("b1")', 1 ],
+ [ 'oct("B1")', 1 ],
+ [ 'oct(" 0b1")', 1 ],
+
+ #[ 'oct(0o1)', 1 ], # requires Perl 5.33.8
+ [ 'oct("01")', 1 ],
+ [ 'oct("0o1")', 1 ],
+ [ 'oct("0O1")', 1 ],
+ [ 'oct("o1")', 1 ],
+ [ 'oct("O1")', 1 ],
+ [ 'oct(" 0o1")', 1 ],
+
+ );
+
+for my $entry (@table) {
+ my ($test, $want) = @$entry;
+ subtest $test, sub {
+ plan tests => 2;
+ my $got = eval $test;
+ cmp_ok($got, '==', $want, 'the output value is correct');
+ is(ref($x), $class, 'the reference type is correct');
+ };
+}