Skip to content

Commit

Permalink
save work
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrowder committed Jan 19, 2024
1 parent f77acf2 commit 0835b36
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
49 changes: 42 additions & 7 deletions t/9-junction.t
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,50 @@ my $junction = abbrevs $target;
is $junction, "A|Ar|Arg|Args", "Single word => /regex junction/";

my @args = $junction.split("|");
is test-junction(:$target, :@args), 0;
my ($ntests, $nfails);
my $nargs = @args.elems;

$junction = "^(A|Ar|Arg|Args)";
is test-junction(:$junction, :$target, :@args), 0;
# subtest 1
subtest {
($ntests, $nfails) = test-junction(:$regex, :$target, :@args);
is $ntests, $nargs, "ntests $ntests";
is $nfails, 0, "expect 0 fails, got $nfails";
}, "subtest 1";

$target = "NArgs";
is test-junction(:$junction, :$target, :@args), 4;
# subtest 2
subtest {
$target = "Args";
$junction = /(A|Ar|Arg|Args)/;
($ntests, $nfails) = test-junction(:$regex, :$junction, :$target, :@args);
is $ntests, $nargs, "ntests $ntests";
is $nfails, 0, "expect 0 fails, got $nfails";
}, "subtest 2";

$junction = "A|Ar|Arg|Args";
is test-junction(:$junction, :$target, :@args), 0;
# subtest 3
subtest {
$target = "Args";
$junction = /^(A|Ar|Arg|Args)/;
($ntests, $nfails) = test-junction(:$regex, :$target, :@args);
is $ntests, $nargs, "ntests $ntests";
is $nfails, 0, "Expected 0 fails, got $nfails";
}, "subtest 3";

# subtest 4
subtest {
$target = "NArgs";
$junction = /^(A|Ar|Arg|Args)/;
($ntests, $nfails) = test-junction(:$regex, :$target, :@args);
is $ntests, $nargs, "ntests $ntests";
is $nfails, $nargs, "Expected $nargs fails, got $nfails";
}, "subtest 4";

# subtest 5
subtest {
$target = "NArgs";
$junction = /(A|Ar|Arg|Args)/;
($ntests, $nfails) = test-junction(:$regex, :$target, :@args);
is $ntests, $nargs, "ntests $ntests";
is $nfails, 0, "Expected 0 fails, got $nfails";
}, "subtest 5";

done-testing;
13 changes: 6 additions & 7 deletions t/Utils/Subs.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ use Abbreviations :ALL;
sub test-junction(
:$target!,
:@args!,
:$junction is copy,
:$regex!,
:$debug,
--> List
) is export {
unless $junction {
$junction = abbrev $target;
}

my $ntests = 0;
my $nfails = 0;
my $res;
for @args {
when /<$junction>/ {
++$ntests;
when $_ ~~ $regex {
$res = True
}
default {
$res = False;
++$nfails
}
}
$nfails
$ntests, $nfails
}

0 comments on commit 0835b36

Please sign in to comment.