Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add missing :Ds to EnumMap, start with EnumMap.ACCEPTS
  • Loading branch information
moritz committed Aug 8, 2011
1 parent 95e209b commit 3ea71cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/core/EnumMap.pm
Expand Up @@ -2,14 +2,22 @@ my class EnumMap does Associative {
# declared in BOOTSTRAP.pm:
# has $!storage; # Parrot Hash PMC of key->value mappings

method Bool() {
multi method Bool(EnumMap:D:) {
nqp::p6bool(pir::defined($!storage) ?? nqp::elems($!storage) !! 0)
}
method elems() {
method elems(EnumMap:D:) {
pir::defined($!storage) ?? nqp::p6box_i(nqp::elems($!storage)) !! 0
}

multi method ACCEPTS(EnumMap:D: Any $topic) {
so self.exists($topic.any);
}

multi method ACCEPTS(EnumMap:D: Cool:D $topic) {
so self.exists($topic);
}

method exists(Str \$key) {
method exists(EnumMap:D: Str \$key) {
nqp::p6bool(
pir::defined($!storage)
&& nqp::existskey($!storage, nqp::unbox_s($key))
Expand Down
4 changes: 2 additions & 2 deletions t/spectest.data
Expand Up @@ -174,7 +174,7 @@ S03-smartmatch/any-callable.t
S03-smartmatch/any-complex.t
S03-smartmatch/any-hash-pair.t
S03-smartmatch/any-hash-slice.t
# S03-smartmatch/any-method.t # err: No applicable candidates found to dispatch to for 'Numeric'
S03-smartmatch/any-method.t
S03-smartmatch/any-num.t
S03-smartmatch/any-pair.t
S03-smartmatch/any-str.t
Expand All @@ -186,7 +186,7 @@ S03-smartmatch/array-array.t
S03-smartmatch/disorganized.t
# S03-smartmatch/hash-hash.t # err: No applicable candidates found to dispatch to for 'ACCEPTS'.
# S03-smartmatch/regex-hash.t # err: No applicable candidates found to dispatch to for 'ACCEPTS'.
# S03-smartmatch/scalar-hash.t # err: No applicable candidates found to dispatch to for 'ACCEPTS'
S03-smartmatch/scalar-hash.t
# S04-blocks-and-statements/pointy-rw.t # err: Missing block
S04-blocks-and-statements/pointy.t
S04-phasers/end.t
Expand Down

0 comments on commit 3ea71cf

Please sign in to comment.