Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Test sub MAIN can type-constrain using Enums
  • Loading branch information
zoffixznet committed Nov 18, 2016
1 parent a27c062 commit 8ff3ab7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion S06-other/main.t
Expand Up @@ -5,7 +5,7 @@ use lib 't/spec/packages';
use Test;
use Test::Util;

plan 7;
plan 8;

## If this test file is fudged, then MAIN never executes because
## the fudge script introduces an C<exit(1)> into the mainline.
Expand Down Expand Up @@ -36,4 +36,21 @@ is_run 'sub MAIN() { map { print "ha" }, ^3 }',
},
'MAIN return value is sunk';


# RT #130131
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[<--pos-hand=Scissors Rock>], { :out<pass>, :err('') }, 'positional + named works';
is_run $code, :args[<Hand> ], { :out{not .contains: 'pass'}, :err(/'=<Hand>'/) },
'name of enum itself is not valid and usage message prints the name of the enum';
}

# vim: ft=perl6

0 comments on commit 8ff3ab7

Please sign in to comment.