diff --git a/Changes b/Changes index 7cd3ce7..bffd020 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ - Make the default output for a single word be a suitable word for an arg regex selection, e.g., abbrev "Args" => "A|Ar|Arg|Args" + + Add info in the README - Separate tests into one for each arg 2.1.0 2023-06-14T16:05:14-05:00 diff --git a/README.md b/README.md index c1a89e2..d2389ed 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,23 @@ DESCRIPTION **Abbreviations** is a module with one automatically exported subroutine, `abbreviations`, which takes as input a set of words and returns the original set with added unique abbreviations for the set. (Note the input words are also abbreviations in the context of this module.) +A natural consequence of generating all the abbreviations for a set of one word is this: the ouput provides the parts of a junction which matches any partial length of the target word. For example, given a target word 'Args': + + use Abbreviations; + use Test; + my $target = "Args"; + my $junction = abbrev $target; # OUTPUT: "A|Ar|Arg|Args"; + my $res = False; + for @w { + when /$junction/ { + $res = True + } + default { + $res = False + } + } + is $res, True; # OUTPUT: ok 1 + Its signature: sub abbreviations($word-set, #= Str, List, or Hash (Set) diff --git a/docs/README.rakudoc b/docs/README.rakudoc index 3c73934..d5233d0 100644 --- a/docs/README.rakudoc +++ b/docs/README.rakudoc @@ -23,6 +23,29 @@ returns the original set with added unique abbreviations for the set. (Note the input words are also abbreviations in the context of this module.) +A natural consequence of generating all the abbreviations for a +set of one word is this: the ouput +provides the parts of a junction which matches any +partial length of the target word. For example, given a target +word 'Args': + +=begin code +use Abbreviations; +use Test; +my $target = "Args"; +my $junction = abbrev $target; # OUTPUT: "A|Ar|Arg|Args"; +my $res = False; +for @w { + when /$junction/ { + $res = True + } + default { + $res = False + } +} +is $res, True; # OUTPUT: ok 1 +=end code + Its signature: =begin code diff --git a/t/03-unusual-inputs.t b/t/03-unusual-inputs.t index 4bbf08a..ca9b1a3 100644 --- a/t/03-unusual-inputs.t +++ b/t/03-unusual-inputs.t @@ -4,7 +4,7 @@ use Abbreviations :ALL; my $debug = 0; -plan 19; +plan 20; # good input test data my @in = ; # arbitrary input order @@ -107,3 +107,14 @@ for @w { } is $res, False; +subtest { + # example in README + my $target = "Args"; + my $junction = abbrev $target; # OUTPUT: "A|Ar|Arg|Args"; + my $res = False; + for @w { + when /$junction/ { $res = True } + default { $res = False } + } + is $res, True, "README example"; # OUTPUT: ok 1 +}