Skip to content

Commit

Permalink
[coverage] Cover nummy trig: sinh and asinh
Browse files Browse the repository at this point in the history
Includes cover for asinh case of
rakudo/rakudo@a7e801f
and fudge for
RT#129919: https://rt.perl.org/Ticket/Display.html?id=129919
  • Loading branch information
zoffixznet committed Oct 19, 2016
1 parent ee12821 commit 6c31fe3
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion S02-types/num.t
Expand Up @@ -4,7 +4,7 @@ use Test;

#L<S02/The C<Num> and C<Rat> Types/Perl 6 intrinsically supports big integers>

plan 90;
plan 92;

isa-ok( EVAL(1.Num.perl), Num, 'EVAL 1.Num.perl is Num' );
is-approx( EVAL(1.Num.perl), 1, 'EVAL 1.Num.perl is 1' );
Expand Down Expand Up @@ -658,6 +658,43 @@ ok Num === Num, 'Num === Num should be truthy, and not die';
is-approx acotan(my num $ = -√(1-2/√5)), my num $ = -2*Ο€/5, '-√(1-2/√5)';
is-approx acotan(my num $ = -(2-√3)), my num $ = -5*Ο€/12, '-(2-√3)';
}

subtest 'sinh(num)' => {
my @test-values = 𝑒, 0e0, 1e0, Ο€, Ο„, 1e2;
plan 2*@test-values + 6;

cmp-ok sinh(my num $ ), '===', NaN, 'uninitialized';
cmp-ok sinh(my num $ = NaN), '===', NaN, 'NaN';

cmp-ok sinh(my num $ = ∞), '==', ∞, '∞';
cmp-ok sinh(my num $ = -∞), '==', -∞, '-∞';
cmp-ok sinh(my num $ = 1e20), '==', ∞, '1e20';
cmp-ok sinh(my num $ = -1e20), '==', -∞, '-1e20';

for @test-values.map({|($_, -$_)}) -> $x {
is-approx sinh(my num $ = $x), my num $ = (𝑒**$x - 𝑒**(-$x))/2, ~$x;
}
}

subtest 'asinh(num)' => {
my @test-values = 𝑒, 0e0, 1e0, Ο€, Ο„, 1e2;
plan 2*@test-values + 7;

cmp-ok asinh(my num $ ), '===', NaN, 'uninitialized';
cmp-ok asinh(my num $ = NaN), '===', NaN, 'NaN';

cmp-ok asinh(my num $ = ∞), '==', ∞, '∞';
cmp-ok asinh(my num $ = -∞), '==', -∞, '-∞';

cmp-ok asinh(my num $ = 1e200), '==', ∞, '1e200';
#?rakudo 2 todo 'RT 129919'
cmp-ok asinh(my num $ = -1e200), '==', -∞, '-1e200';
is asinh(my num $ = -0e0).Str, '-0', '-0e0 actually gives a minus 0';

for @test-values.map({|($_, -$_)}) -> $x {
is-approx asinh(my num $ = $x), my num $ = log($x+√($x²+1)), ~$x;
}
}
}

# vim: ft=perl6

0 comments on commit 6c31fe3

Please sign in to comment.