Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created November 18, 2016 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/42ed3b55b8df6e0bc340a7a434212acd to your computer and use it in GitHub Desktop.
Save zoffixznet/42ed3b55b8df6e0bc340a7a434212acd to your computer and use it in GitHub Desktop.
subtest 'MAIN can take type-constrain using Enums' => {
plan 3;
my $code = Q:to/END/;
enum Hand <Rock Paper Scissors>;
sub MAIN (Hand $hand, Hand :$pos-hand) {
print "pass";
}
END
is_run $code, :args[<Rock>], { :out<pass>, :err('') }, 'positional works';
is_run $code, :args[<Rock --pos-hand=Scissors>], { :out<pass>, :err('') }, 'named works';
is_run $code, :args[<Hand>], { :out{not 'pass'}, :err(/'=<Hand>'/) },
'name of enum itself is not valid and usage message prints the name of the enum';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment