Permalink
Browse files

add missing :Ds to EnumMap, start with EnumMap.ACCEPTS

  • Loading branch information...
1 parent 95e209b commit 3ea71cf82fe9efc07119e8388bda9244ce739f0e @moritz moritz committed Aug 8, 2011
Showing with 13 additions and 5 deletions.
  1. +11 −3 src/core/EnumMap.pm
  2. +2 −2 t/spectest.data
View
@@ -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))
View
@@ -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
@@ -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

0 comments on commit 3ea71cf

Please sign in to comment.