Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[src/core/Range.pm] Range ~~ Range semantics
Now by spec. \o/
  • Loading branch information
Carl Masak committed Apr 5, 2012
1 parent 2c35bdb commit cb61d59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/Range.pm
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions t/spectest.data
Expand Up @@ -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
Expand Down

0 comments on commit cb61d59

Please sign in to comment.