-
-
Save jkramer/072d3b3ffbb7346e9ce4741d2ebb6920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/S32-num/rounders.t b/S32-num/rounders.t | |
index 2b703b5a3..5b3d7212e 100644 | |
--- a/S32-num/rounders.t | |
+++ b/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"> | |
@@ -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 { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment