Created
February 8, 2017 17:36
-
-
Save zoffixznet/37bad28674367e15b7e02ae872b6fc5e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
use Test; | |
subtest 'smartmatch against numeric range' => { | |
constant fr2 = FatRat.new: 2, 1; | |
constant fr3 = FatRat.new: 3, 1; | |
constant @true = 2..3, '2'..'3', 2/1..3/1, 2..3, 2.5..2.8, 1^..3, | |
'2'..^'3', '1'^..^3, -1/0..1/0, fr2..fr3, 2..fr3, 2e0..fr3; | |
constant @false = 1..3, '2'..'4', -2..5/1, -10..10, 2.5..6.5, 0^..3, | |
'2'..^'4', '1'^..^4, 0/0..0/0, fr3..10, -2e0..fr2, 3e0..fr3; | |
constant @variants = 2..3, 2..3e0, 2..3.0, 2..fr3, | |
2e0..3, 2e0..3e0, 2e0..3.0, 2e0..fr3, | |
2.0..3, 2.0..3e0, 2.0..3.0, 2.0..fr3, | |
fr2..3, fr2..fr3, fr2..fr3, fr2..fr3; | |
constant $plan = @variants * (@true + @false); | |
for @variants -> $r { | |
is-deeply $_ ~~ $r, True, "{.perl} ~~ {$r.perl}" for @true; | |
is-deeply $_ ~~ $r, False, "{.perl} ~~ {$r.perl}" for @false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment