@@ -120,19 +120,21 @@ sub showkv($x) {
120
120
}
121
121
122
122
{
123
- my $ b = KeyBag. new (set < foo bar foo bar baz foo > );
123
+ my $ b = KeyBag. new ({ foo => 10 , bar => 1 , baz => 2 } );
124
124
125
+ # .list is just the keys, as per TimToady:
126
+ # http://irclog.perlgeek.de/perl6/2012-02-07#i_5112706
125
127
isa_ok $ b . list. elems , 3 , " .list returns 3 things" ;
126
- is $ b . list. grep (Pair ). elems , 3 , " ... all of which are Pairs" ;
127
- is $ b . list. grep ({ . key ~~ Str }). elems , 3 , " ... the keys of which are Strs" ;
128
+ is $ b . list. grep (Str ). elems , 3 , " ... all of which are Str" ;
128
129
129
130
isa_ok $ b . pairs . elems , 3 , " .pairs returns 3 things" ;
130
131
is $ b . pairs . grep (Pair ). elems , 3 , " ... all of which are Pairs" ;
131
132
is $ b . pairs . grep ({ . key ~~ Str }). elems , 3 , " ... the keys of which are Strs" ;
133
+ is $ b . pairs . grep ({ . value ~~ Int }). elems , 3 , " ... and the values of which are Ints" ;
132
134
133
- is $ b . grep (Pair ). elems , 3 , " .iterator yields three Pairs" ;
134
- is $ b . grep ({ . key ~~ Str }). elems , 3 , " ... the keys of which are Strs" ;
135
- is $ b . grep ({True }). elems , 3 , " ... and nothing else" ;
135
+ is $ b . iterator . grep (Pair ). elems , 3 , " .iterator yields three Pairs" ;
136
+ is $ b . iterator . grep ({ . key ~~ Str }). elems , 3 , " ... the keys of which are Strs" ;
137
+ is $ b . iterator . grep ({True }). elems , 3 , " ... and nothing else" ;
136
138
}
137
139
138
140
{
0 commit comments