Skip to content

Commit 6cdbe86

Browse files
authored
Use a more elaborate with different types
to showcase how is-deeply tests all of it
1 parent 09250ba commit 6cdbe86

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

doc/Language/testing.pod6

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,20 @@ use v6.c;
401401
use Test;
402402
plan 1;
403403
404-
sub count-chars(Str() $x) {
405-
$x.comb.Bag
404+
sub string-info(Str() $_) {
405+
Map.new: (
406+
length => .chars,
407+
char-counts => Bag.new-from-pairs: (
408+
letters => +.comb(/<[\w]-[_]>/),
409+
digits => +.comb(/\d/),
410+
other => +.comb(/<.-[\w\d]+[_]>/),
411+
))
406412
}
407-
my $expected = bag <f l e e e c>;
408-
is-deeply count-chars('fleece'), $expected, 'count-chars works on "fleece"';
413+
414+
is-deeply string-info('I ♥ Perl 6'), Map.new((
415+
:10length,
416+
char-counts => Bag.new-from-pairs: ( :6letters, :1digits, :4other, )
417+
)), 'string-info gives right info';
409418
=end code
410419
411420
B<Note:> for L<historical

0 commit comments

Comments
 (0)