1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
#!/usr/bin/perl -w
use strict;
use lib './t';
$ENV{PERL_NO_VALIDATION} = 0;
require Params::Validate;
Params::Validate->import(':all');
use vars qw(@expect);
@expect = (
# mandatory/optional
0,
q|^Mandatory parameter 'bar' missing|,
q|^Mandatory parameters .* missing|,
q|^The following parameter .* baz|,
0,
0,
0,
0,
0,
# simple types
q|^The 'foo' parameter \("ARRAY\(0x[a-f0-9]+\)"\) to main::sub3 was an 'arrayref'.* types: scalar|,
q|^The 'brax' parameter \("ARRAY\(0x[a-f0-9]+\)"\) to main::sub3 was an 'arrayref'.* types: scalar hash|,
q|^The 'bar' parameter \("HASH\(0x[a-f0-9]+\)"\) to main::sub3 was a 'hashref'.* types: arrayref|,
0,
# funkier types
q|^The 'bar' parameter \("GLOB\(0x[a-f0-9]+\)"\) to main::sub4 was a 'globref'.* types: glob|,
q|^The 'baz' parameter \((?:"\*main::FH"\|GLOB)\) to main::sub4 was a 'glob'.* types: globref|,
q|^The 'foo' parameter \("foobar"\) to main::sub4 was a 'scalar'.* types: scalarref|,
q|^The 'quux' parameter \("GLOB\(0x[a-f0-9]+\)"\) to main::sub4 was a 'globref'.* types: coderef|,
0,
0,
q|^The 'foo' parameter \("ARRAY\(0x[a-f0-9]+\)"\) to main::sub4a was an 'arrayref'.* types: glob globref|,
0,
0,
# wasa
0,
0,
0,
q|^The 'foo' parameter \("Foo=SCALAR\(0x[a-f0-9]+\)"\) to main::sub6 was not a 'Bar'|,
0,
0,
q|^The 'foo' parameter \("Foo=SCALAR\(0x[a-f0-9]+\)"\) to main::sub7 was not a 'Baz'|,
q|^The 'foo' parameter \("Bar=SCALAR\(0x[a-f0-9]+\)"\) to main::sub7 was not a 'Baz'|,
0,
q|^The 'foo' parameter \("Foo=SCALAR\(0x[a-f0-9]+\)"\) to main::sub8 was not a 'Yadda'|,
0,
# can
0,
0,
q|^The 'foo' parameter \("Foo=SCALAR\(0x[a-f0-9]+\)"\) to main::sub9a does not have the method: 'barify'|,
0,
q|^The 'foo' parameter \("Baz=SCALAR\(0x[a-f0-9]+\)"\) to main::sub9b does not have the method: 'yaddaify'|,
q|^The 'foo' parameter \("Quux=SCALAR\(0x[a-f0-9]+\)"\) to main::sub9b does not have the method: 'barify'|,
q|^The 'foo' parameter \("Bar=SCALAR\(0x[a-f0-9]+\)"\) to main::sub9c does not have the method: 'yaddaify'|,
0,
# callbacks
0,
0,
q|^The 'foo' parameter \("20"\) to main::sub10 did not pass the 'less than 20' callback|,
0,
q|^The 'foo' parameter \("20"\) to main::sub11 did not pass the 'less than 20' callback|,
q|^The 'foo' parameter \("0"\) to main::sub11 did not pass the 'more than 0' callback|,
# mix n' match
q|^The 'foo' parameter \("1"\) to main::sub12 was a 'scalar'.* types: arrayref|,
q|^The 'foo' parameter \("ARRAY\(0x[a-f0-9]+\)"\) to main::sub12 did not pass the '5 elements' callback|,
0,
# positional - 1
q|^1 parameter was passed to .* but 2 were expected|,
q|^Parameter #2 \("ARRAY\(0x[a-f0-9]+\)"\) to .* did not pass the '5 elements' callback|,
# positional - 2
q|^Parameter #3 \("Foo=SCALAR\(0x[a-f0-9]+\)"\) to .* was not a 'Bar'|,
0,
# hashref named params
q|^The 'bar' parameter \("HASH\(0x[a-f0-9]+\)"\) to .* was a 'hashref'.* types: arrayref|,
q|^Mandatory parameter 'bar' missing|,
# positional - 3
q|^3 parameters were passed .* but 1 - 2 were expected|,
0,
0,
q|^0 parameters were passed .* but 1 - 2 were expected|,
# positional - 4
q|^3 parameters were passed .* but 1 - 2 were expected|,
0,
0,
q|^0 parameters were passed .* but 1 - 2 were expected|,
# positional - too few arguments supplied ##test 65 onward
q|^0 parameters were passed .* but 3 - 4 were expected|,
q|^2 parameters were passed .* but 3 - 4 were expected|,
q|^0 parameters were passed .* but 3 - 4 were expected|,
q|^2 parameters were passed .* but 3 - 4 were expected|,
# validation_options
0,
q|^The following parameter .* FOO|,
0,
q|^The following parameter .* -foo|,
0,
q|^The following parameter .* bar|,
'',
q|^2 parameters were passed .* but 1.*|,
q|^Mandatory parameter 'foo' missing|,
q|^ERROR WAS: The following parameter .* bar|,
q|^The following parameter .* bar|,
q|^The 'foo' parameter \(undef\) to .* was an 'undef'.*|,
0,
q|^The 'foo' parameter \("ARRAY\(0x[a-f0-9]+\)"\) to .* was an 'arrayref'.*|,
0,
0,
q|^The 'foo' parameter \("ARRAY\(0x[a-f0-9]+\)"\) to .* was an 'arrayref'.*|,
0,
0,
0,
q|^Parameter #1 \("1 element"\) to .* was a 'scalar'.*|,
0,
q|^Odd number|,
# optional glob
0,
);
# 5.6.0 core dumps all over during the tests
if ( $] == 5.006 )
{
warn <<'EOF';
Skipping tests for Perl 5.6.0. 5.6.0 core dumps all over during the
tests. This may just have to do with the test code rather than the
module itself. 5.6.1 works fine when I tested it. 5.6.0 is buggy.
You are encouraged to upgrade.
EOF
print "1..0";
exit;
}
require 'tests.pl';
run_tests();
|