diff options
author | Toby Inkster <mail@tobyinkster.co.uk> | 2022-09-12 09:58:30 +0100 |
---|---|---|
committer | Toby Inkster <mail@tobyinkster.co.uk> | 2022-09-12 09:58:30 +0100 |
commit | 140beeafd92a3342dea79f9272c7e014f57e7f8c (patch) | |
tree | d46e5183adc70bc5c55557461f58e6aaa60c033b | |
parent | 651e99a5268097619a8f276569211c1d7115bbb1 (diff) |
Ensure that ${^TYPE_PARAMS_MULTISIG} is set to undef before checking multisigs
-rw-r--r-- | lib/Type/Params/Alternatives.pm | 2 | ||||
-rw-r--r-- | t/20-modules/Type-Params/v2-multi.t | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/Type/Params/Alternatives.pm b/lib/Type/Params/Alternatives.pm index 6372748d..27f54f0b 100644 --- a/lib/Type/Params/Alternatives.pm +++ b/lib/Type/Params/Alternatives.pm @@ -98,6 +98,8 @@ sub _build_coderef { $self->_coderef_start( $coderef ); + $coderef->add_line( 'undef ${^TYPE_PARAMS_MULTISIG};' ); + $coderef->add_gap; $coderef->add_line( 'my $return;' ); $coderef->add_gap; diff --git a/t/20-modules/Type-Params/v2-multi.t b/t/20-modules/Type-Params/v2-multi.t index 0138fe0e..43d11db7 100644 --- a/t/20-modules/Type-Params/v2-multi.t +++ b/t/20-modules/Type-Params/v2-multi.t @@ -22,6 +22,7 @@ the same terms as the Perl 5 programming language system itself. use strict; use warnings; use Test::More; +use Test::Fatal; use Types::Common -sigs, -types; @@ -134,6 +135,11 @@ use Types::Common -sigs, -types; 'helloworld', 'final alternative', ); + + my $e = exception { array_lookup() }; + like $e, qr/Parameter validation failed/; + + is ${^TYPE_PARAMS_MULTISIG}, undef; }; } @@ -234,6 +240,11 @@ use Types::Common -sigs, -types; ); is ${^TYPE_PARAMS_MULTISIG}, 4; + + my $e = exception { array_lookup() }; + like $e, qr/Parameter validation failed/; + + is ${^TYPE_PARAMS_MULTISIG}, undef; }; } |