sub _blam {
my ($self, $error) = @_;
- my $hat = (' ' x pos).'^';
+ my $hat = (' ' x (pos||0)).'^';
die "Error parsing dispatch specification: ${error}\n
${_}
${hat} here\n";
or $self->_blam('No valid combinator - expected + or |');
} until (pos == length) }; # accept trailing whitespace
if ($nested and pos == length) {
- pos = $nested;
+ pos = $nested - 1;
$self->_blam("No closing ) found for opening (");
}
return $match[0] if (@match == 1);
[],
'(GET+/foo)|POST does not match PUT /foo'
);
+
+{
+ local $@;
+ ok(
+ !eval { $dp->parse_dispatch_specification('/foo+(GET'); 1 },
+ 'Death with missing closing )'
+ );
+ my $err = q{
+ /foo+(GET
+ ^
+ };
+ (s/^\n//s,s/\n $//s,s/^ //mg) for $err;
+ like(
+ $@,
+ qr{\Q$err\E},
+ "Error $@ matches\n${err}\n"
+ );
+}