Permalink
Browse files

[src/core/Range.pm] Range ~~ Range semantics

Now by spec. \o/
  • Loading branch information...
masak committed Apr 5, 2012
1 parent 2c35bdb commit cb61d593c721cf9e05634384a3e6ff94482a6d34
Showing with 11 additions and 0 deletions.
  1. +10 −0 src/core/Range.pm
  2. +1 −0 t/spectest.data
View
@@ -39,6 +39,16 @@ class Range is Iterable does Positional {
and ($topic cmp $!max) < +(!$!excludes_max)
}
+ multi method ACCEPTS(Range:D: Range \$topic) {
+ ($topic.min > $!min
+ || $topic.min == $!min
+ && !(!$topic.excludes_min && $!excludes_min))
+ &&
+ ($topic.max < $!max
+ || $topic.max == $!max
+ && !(!$topic.excludes_max && $!excludes_max))
+ }
+
method reify($n = 10) {
my $value = $!excludes_min ?? $!min.succ !! $!min;
# Iterating a Str range delegates to iterating a sequence.
View
@@ -193,6 +193,7 @@ S03-smartmatch/array-hash.t
# S03-smartmatch/capture-signature.t # all fail
S03-smartmatch/disorganized.t
S03-smartmatch/hash-hash.t
+S03-smartmatch/range-range.t
S03-smartmatch/regex-hash.t
S03-smartmatch/scalar-hash.t
S04-blocks-and-statements/pointy-rw.t

0 comments on commit cb61d59

Please sign in to comment.