We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09250ba commit 6cdbe86Copy full SHA for 6cdbe86
doc/Language/testing.pod6
@@ -401,11 +401,20 @@ use v6.c;
401
use Test;
402
plan 1;
403
404
-sub count-chars(Str() $x) {
405
- $x.comb.Bag
+sub string-info(Str() $_) {
+ 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
+ ))
412
}
-my $expected = bag <f l e e e c>;
-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';
418
=end code
419
420
B<Note:> for L<historical
0 commit comments