Created
November 18, 2016 22:54
-
-
Save zoffixznet/42ed3b55b8df6e0bc340a7a434212acd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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