This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade bignum from version 0.40 to 0.41
[perl5.git] / cpan / bignum / t / auth-bigint-hex.t
CommitLineData
c6824fe7
SH
1#!perl
2
3BEGIN {
4 unless ($ENV{AUTHOR_TESTING}) {
5 require Test::More;
6 Test::More::plan(skip_all => 'these tests are for release candidate testing');
7 }
8}
9
10use strict;
11use warnings;
12
13use Test::More tests => 507068;
14
15use Algorithm::Combinatorics qw< variations >;
16
17use bigint;
18
19use Test::More;
20
21my $elements = ['0', 'b', 'x', '1', '1', '_', '_', '9', 'z'];
22
23for my $k (0 .. @$elements) {
24 my $seen = {};
25 for my $variation (variations($elements, $k)) {
26 my $str = join "", @$variation;
27 next if $seen -> {$str}++;
28 print qq|#\n# hex("$str")\n#\n|;
29
30 my $i;
31 my @warnings;
32 local $SIG{__WARN__} = sub {
33 my $warning = shift;
34 $warning =~ s/ at .*\z//s;
35 $warnings[$i] = $warning;
36 };
37
38 $i = 0;
39 my $want_val = CORE::hex("$str");
40 my $want_warn = $warnings[$i];
41
42 $i = 1;
43 my $got_val = bigint::hex("$str");
44 my $got_warn = $warnings[$i];
45
46 is($got_val, $want_val, qq|hex("$str") (output)|);
47 is($got_warn, $want_warn, qq|hex("$str") (warning)|);
48 }
49}