Skip to content

Commit

Permalink
Add tests for rakudo/rakudo#1745 plus some more for 2-argument versio…
Browse files Browse the repository at this point in the history
…n of &round.
  • Loading branch information
jkramer committed Jul 4, 2018
1 parent 32157bd commit 955b0e0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion S32-num/rounders.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 134;
plan 142;

# L<S32::Numeric/Real/"=item round">
# L<S32::Numeric/Real/"=item floor">
Expand Down Expand Up @@ -75,6 +75,27 @@ for @testkeys -> $type {
}
}

# Tests for 2-argument version of &round
# (https://github.com/rakudo/rakudo/issues/1745).
{
my @tests = (
[ 1.23456, 0.00001, 1.23456 ],
[ 1.23456, 0.0001, 1.2346 ],
[ 1.23456, 0.001, 1.235 ],
[ 1.23456, 0.01, 1.23 ],
[ 1.23456, 0.1, 1.2 ],

# Make sure first argument is coerced to Numeric.
[ "123.12", 0.01, 123.12 ],
[ [<foo bar baz>], 1, 3 ],
[ { :1foo, :2bar, :3baz }, 1, 3 ],
);

for @tests {
is(round(.[0], .[1]), .[2], "round({.[0].perl}, {.[1].perl}) == {.[2].perl}");
}
}

for @testkeys -> $type {
my @subtests = @(%tests{$type}); # XXX .[] doesn't work yet!
for @subtests -> $test {
Expand Down

0 comments on commit 955b0e0

Please sign in to comment.