Codebase list libparams-validate-perl / b9ac6bd
Add some code so we can figure out which implementation of PV was loaded Add release tests that both are loadable. Dave Rolsky 12 years ago
5 changed file(s) with 37 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
77 BEGIN {
88 use Exporter;
99
10 use vars qw( $NO_VALIDATION %OPTIONS $options );
10 use vars qw( $NO_VALIDATION %OPTIONS $options $IMPLEMENTATION );
1111
1212 our @ISA = 'Exporter';
1313
4040 if ( $e || $ENV{PV_TEST_PERL} ) {
4141 require Params::ValidatePP;
4242 }
43 }
44
45 sub _implementation {
46 return $IMPLEMENTATION;
4347 }
4448
4549 1;
2323 sub HANDLE () { 16 | 32 }
2424 sub BOOLEAN () { 1 | 256 }
2525 }
26
27 $IMPLEMENTATION = 'PP';
2628
2729 # Various internals notes (for me and any future readers of this
2830 # monstrosity):
66 require Carp;
77 Carp::confess( $_[0] );
88 };
9
10 $IMPLEMENTATION = 'XS';
911
1012 {
1113 my %defaults = (
0 use strict;
1 use warnings;
2
3 use Test::More;
4
5 BEGIN { $ENV{PV_TEST_PERL} = 1 }
6
7 use Params::Validate;
8
9 is(
10 Params::Validate::_implementation(), 'PP',
11 'PP implementation is loaded when env var is set'
12 );
13
14 done_testing();
0 use strict;
1 use warnings;
2
3 use Test::More;
4
5 use Params::Validate;
6
7 is(
8 Params::Validate::_implementation(), 'XS',
9 'XS implementation is loaded by default'
10 );
11
12 done_testing();