diff options
author | Peter John Acklam <pjacklam@gmail.com> | 2024-01-05 19:05:32 +0100 |
---|---|---|
committer | Peter John Acklam <pjacklam@gmail.com> | 2024-01-05 19:05:32 +0100 |
commit | bf55af03c3bac5a8dc2fb545fa397f62f0ada0f6 (patch) | |
tree | ebe2df202abb357f92ff09cc2c5930f83bbd1485 | |
parent | 2072f85864289d103410209433078a9da07f2c81 (diff) |
Sync test files with the Math-BigInt distribution
-rw-r--r-- | xt/author/lib-arithmetic-unary-_clog10.t | 46 | ||||
-rw-r--r-- | xt/author/lib-arithmetic-unary-_clog2.t | 46 | ||||
-rw-r--r-- | xt/author/lib-arithmetic-unary-_ilog10.t | 46 | ||||
-rw-r--r-- | xt/author/lib-arithmetic-unary-_ilog2.t | 46 |
4 files changed, 180 insertions, 4 deletions
diff --git a/xt/author/lib-arithmetic-unary-_clog10.t b/xt/author/lib-arithmetic-unary-_clog10.t index 6ade891..bcb1657 100644 --- a/xt/author/lib-arithmetic-unary-_clog10.t +++ b/xt/author/lib-arithmetic-unary-_clog10.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 2285; +use Test::More tests => 4569; ############################################################################### # Read and load configuration file and backend library. @@ -85,6 +85,50 @@ for (my $y = 3 ; $y <= 50 ; $y++) { push @data, [ $LIB -> _str($x_up), $y + 1, 0 ]; # clog10(10**$y + 1) = $y + 1 } +# Scalar context. + +for (my $i = 0 ; $i <= $#data ; ++ $i) { + my ($in0, $out0) = @{ $data[$i] }; + + my ($x, $y, $got); + + my $test = qq|\$x = $LIB->_new("$in0"); | + . qq|\$got = $LIB->_clog10(\$x);|; + + diag("\n$test\n\n") if $ENV{AUTHOR_DEBUGGING}; + + eval $test; + is($@, "", "'$test' gives emtpy \$\@"); + + subtest "_clog10() in scalar context: $test", sub { + + unless (defined $out0) { + plan tests => 1; + + is($got, $out0, + "'$test' output arg has the right value"); + return; + } + + plan tests => 5; + + is(ref($got), $REF, + "'$test' output arg is a $REF"); + + is($LIB->_check($got), 0, + "'$test' output is valid"); + + is($LIB->_str($got), $out0, + "'$test' output arg has the right value"); + + is(ref($x), $REF, + "'$test' input arg is still a $REF"); + + ok($LIB->_str($x) eq $out0 || $LIB->_str($x) eq $in0, + "'$test' input arg has the correct value"); + }; +} + # List context. for (my $i = 0 ; $i <= $#data ; ++ $i) { diff --git a/xt/author/lib-arithmetic-unary-_clog2.t b/xt/author/lib-arithmetic-unary-_clog2.t index 9888389..73e78b1 100644 --- a/xt/author/lib-arithmetic-unary-_clog2.t +++ b/xt/author/lib-arithmetic-unary-_clog2.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 2591; +use Test::More tests => 5181; ############################################################################### # Read and load configuration file and backend library. @@ -85,6 +85,50 @@ for (my $y = 10 ; $y <= 100 ; $y++) { push @data, [ $LIB -> _str($x_up), $y + 1, 0 ]; # clog2(2**$y + 1) = $y + 1 } +# Scalar context. + +for (my $i = 0 ; $i <= $#data ; ++ $i) { + my ($in0, $out0) = @{ $data[$i] }; + + my ($x, $y, $got); + + my $test = qq|\$x = $LIB->_new("$in0"); | + . qq|\$got = $LIB->_clog2(\$x);|; + + diag("\n$test\n\n") if $ENV{AUTHOR_DEBUGGING}; + + eval $test; + is($@, "", "'$test' gives emtpy \$\@"); + + subtest "_clog2() in list context: $test", sub { + + unless (defined $out0) { + plan tests => 1; + + is($got, $out0, + "'$test' output arg has the right value"); + return; + } + + plan tests => 5; + + is(ref($got), $REF, + "'$test' output arg is a $REF"); + + is($LIB->_check($got), 0, + "'$test' output is valid"); + + is($LIB->_str($got), $out0, + "'$test' output arg has the right value"); + + is(ref($x), $REF, + "'$test' input arg is still a $REF"); + + ok($LIB->_str($x) eq $out0 || $LIB->_str($x) eq $in0, + "'$test' input arg has the correct value"); + }; +} + # List context. for (my $i = 0 ; $i <= $#data ; ++ $i) { diff --git a/xt/author/lib-arithmetic-unary-_ilog10.t b/xt/author/lib-arithmetic-unary-_ilog10.t index f9c049d..cacc2c7 100644 --- a/xt/author/lib-arithmetic-unary-_ilog10.t +++ b/xt/author/lib-arithmetic-unary-_ilog10.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 2285; +use Test::More tests => 4569; ############################################################################### # Read and load configuration file and backend library. @@ -85,6 +85,50 @@ for (my $y = 3 ; $y <= 50 ; $y++) { push @data, [ $LIB -> _str($x_up), $y, 0 ]; # ilog10(10**$y + 1) = $y } +# Scalar context. + +for (my $i = 0 ; $i <= $#data ; ++ $i) { + my ($in0, $out0) = @{ $data[$i] }; + + my ($x, $y, $got); + + my $test = qq|\$x = $LIB->_new("$in0"); | + . qq|\$got = $LIB->_ilog10(\$x);|; + + diag("\n$test\n\n") if $ENV{AUTHOR_DEBUGGING}; + + eval $test; + is($@, "", "'$test' gives emtpy \$\@"); + + subtest "_ilog10() in list context: $test", sub { + + unless (defined $out0) { + plan tests => 1; + + is($got, $out0, + "'$test' output arg has the right value"); + return; + } + + plan tests => 5; + + is(ref($got), $REF, + "'$test' output arg is a $REF"); + + is($LIB->_check($got), 0, + "'$test' output is valid"); + + is($LIB->_str($got), $out0, + "'$test' output arg has the right value"); + + is(ref($x), $REF, + "'$test' input arg is still a $REF"); + + ok($LIB->_str($x) eq $out0 || $LIB->_str($x) eq $in0, + "'$test' input arg has the correct value"); + }; +} + # List context. for (my $i = 0 ; $i <= $#data ; ++ $i) { diff --git a/xt/author/lib-arithmetic-unary-_ilog2.t b/xt/author/lib-arithmetic-unary-_ilog2.t index edb9644..56f30f3 100644 --- a/xt/author/lib-arithmetic-unary-_ilog2.t +++ b/xt/author/lib-arithmetic-unary-_ilog2.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 2591; +use Test::More tests => 5181; ############################################################################### # Read and load configuration file and backend library. @@ -85,6 +85,50 @@ for (my $y = 10 ; $y <= 100 ; $y++) { push @data, [ $LIB -> _str($x_up), $y, 0 ]; # ilog2(2**$y + 1) = $y } +# Scalar context. + +for (my $i = 0 ; $i <= $#data ; ++ $i) { + my ($in0, $out0) = @{ $data[$i] }; + + my ($x, $y, $got); + + my $test = qq|\$x = $LIB->_new("$in0"); | + . qq|\$got = $LIB->_ilog2(\$x);|; + + diag("\n$test\n\n") if $ENV{AUTHOR_DEBUGGING}; + + eval $test; + is($@, "", "'$test' gives emtpy \$\@"); + + subtest "_ilog2() in list context: $test", sub { + + unless (defined $out0) { + plan tests => 1; + + is($got, $out0, + "'$test' output arg has the right value"); + return; + } + + plan tests => 5; + + is(ref($got), $REF, + "'$test' output arg is a $REF"); + + is($LIB->_check($got), 0, + "'$test' output is valid"); + + is($LIB->_str($got), $out0, + "'$test' output arg has the right value"); + + is(ref($x), $REF, + "'$test' input arg is still a $REF"); + + ok($LIB->_str($x) eq $out0 || $LIB->_str($x) eq $in0, + "'$test' input arg has the correct value"); + }; +} + # List context. for (my $i = 0 ; $i <= $#data ; ++ $i) { |