| 1 | 115 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 115 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 115 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package LINQ::Util::Internal; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 115 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||
| 8 | 115 | our $VERSION = '0.002'; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub create_linq { | ||||||||||||||||||||||||||||
| 11 | 101 | ▶ | require LINQ; | ||||||||||||||||||||||||||
|
Subroutine
create_linq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 12 | 101 | goto \&LINQ::LINQ; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub throw { | ||||||||||||||||||||||||||||
| 16 | 49 | ▶ | require LINQ::Exception; | ||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 49 | my $e = shift; | |||||||||||||||||||||||||||
| 18 | 49 | "LINQ::Exception::$e"->throw( @_ ); | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub assert_code { | ||||||||||||||||||||||||||||
| 22 | 988 | ▶ | my $code = shift; | ||||||||||||||||||||||||||
|
Subroutine
assert_code: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 988 | ▶ | if ( ref( $code ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 4 | @_ = @$code; | |||||||||||||||||||||||||||
| 26 | 4 | $code = shift; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 988 | ▶ | if ( ref( $code ) eq 'Regexp' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 11 | ▶ | throw( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | "CallerError", | ||||||||||||||||||||||||||||
| 32 | message => "Regexp cannot accept curried arguments" | ||||||||||||||||||||||||||||
| 33 | ) if @_; | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 11 | my $re = $code; | |||||||||||||||||||||||||||
| 36 | 11 | ▶ | return sub { m/$re/ }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 977 | ▶ | if ( ref( $code ) ne 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 35 | require Scalar::Util; | |||||||||||||||||||||||||||
| 41 | 35 | require overload; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 35 | ▶ | throw( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($code) and overload::Method($code, "&{}")
MC/DC0%0/2
builtin::blessed($code) and overload::Method($code, "&{}")
builtin::blessed($code)
overload::Method($code, "&{}")
Truth table33%1/3
A and B
A= builtin::blessed($code)B= overload::Method($code, "&{}")
| |||||||||||||||||||||||||||||
| 44 | "CallerError", | ||||||||||||||||||||||||||||
| 45 | message => "Expected coderef; got '$code'" | ||||||||||||||||||||||||||||
| 46 | ) unless Scalar::Util::blessed( $code ) && overload::Method( $code, '&{}' ); | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 977 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 40 | my @curry = @_; | |||||||||||||||||||||||||||
| 51 | 40 | ▶ | return sub { $code->( @curry, @_ ) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 937 | return $code; | |||||||||||||||||||||||||||
| 55 | } #/ sub assert_code | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 115 | 1; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =pod | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 NAME | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | LINQ::Util::Internal - common functions used internally by LINQ | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =over | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =item C<< create_linq( SOURCE ) >> | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =item C<< throw( EXCEPTION_TYPE, ARGS ) >> | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =item C<< assert_code( CALLABLE ) >> | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =back | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head1 BUGS | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Please report any bugs to | ||||||||||||||||||||||||||||
| 84 | L<http://rt.cpan.org/Dist/Display.html?Queue=LINQ>. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | L<LINQ>. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Toby Inkster E<lt>tobyink@cpan.orgE<gt>. | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head1 COPYRIGHT AND LICENCE | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | This software is copyright (c) 2021 by Toby Inkster. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 99 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head1 DISCLAIMER OF WARRANTIES | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||||||||||||||||||||
| 104 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||||||||||||||||||||||||||||
| 105 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||