Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Created November 2, 2021 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/af79a02ec68dab2066ab58cb4d9c6711 to your computer and use it in GitHub Desktop.
Save dogbert17/af79a02ec68dab2066ab58cb4d9c6711 to your computer and use it in GitHub Desktop.
Pathetic golf attempt
use Test;
for ^1000 {
subtest 'Complex smartmatch against Range' => {
my @false = [i, 1..10], [i, -2e300.Int..2e300.Int], [i, -2e300.Int..2e300.Int],
[<0+0i>, 1..10], [i, 'a'..Inf], [i, 'a'..'z'];
# these cases are true because the imaginary part is small enough that
# we can convert these Complex into Real
my @true = [<0+0i>, -1..10], [<42+0i>, 10..50],
[<42+0.0000000000000001i>, 40..50], [<42+0i>, 10e0..50e0];
plan @false + @true;
for @false -> $t {
is-deeply ($t[0] ~~ $t[1]), False, "{$t[0].raku} ~~ {$t[1].raku}";
}
for @true -> $t {
is-deeply ($t[0] ~~ $t[1]), True, "{$t[0].raku} ~~ {$t[1].raku}";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment