### ----------------------------------------------------
### -- shorten-sub-commands
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;

plan 12;

my $raku        := $*EXECUTABLE.absolute;
my $frobnicate  := $*PROGRAM.sibling("frobnicate").absolute;
my $regurgitate := $*PROGRAM.sibling("regurgitate").absolute;
my $numicate    := $*PROGRAM.sibling("numicate").absolute;

my sub test($script, $command, $expected) {
    is (run $raku, '-I.', $script, $command, :merge).out.slurp(:close).chomp,
      $expected,
      "does $command give $expected?";
}

test $frobnicate, "foo", "foozle";
test $frobnicate, "bar", "barabas";
test $frobnicate, "baz", "bazzie";
test $frobnicate, "fnok", "'fnok' is not recognized as sub-command:\nKnown sub-commands: barabas bazzie foozle";
test $frobnicate, "ba", "'ba' is ambiguous, matches: barabas bazzie";

test $regurgitate, "s", "'s' recurses into 'search'";
test $regurgitate, "search", "'search' recurses";

test $numicate, "f", "foo";
test $numicate, "foo", "foo";
test $numicate, 4, 42;
test $numicate, 42, 42;
test $numicate, 423, "'423' is not recognized as sub-command:
Known sub-commands: 42 foo";

# vim: expandtab shiftwidth=4


