File: 02-infinite-loop.t

package info (click to toggle)
libgetopt-declare-perl 1.14-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 328 kB
  • sloc: perl: 1,386; makefile: 8
file content (30 lines) | stat: -rw-r--r-- 574 bytes parent folder | download | duplicates (3)
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
#!perl

use lib 'lib';
use strict;
use warnings;
use Test::More tests => 4;

BEGIN { use_ok( 'Getopt::Declare' ); }

# The two '?' confused extract_codeblock and led to an infinite loop in the
# usage_string() function. Bug fixed by using extract_bracketed() instead.

my $spec = <<'EOCMDS';
[pvtype: who /x?/]
<error>	 Error
{ print "Error?\n" }
EOCMDS

ok my $args = Getopt::Declare->new($spec);

ok my $got_usage = $args->usage_string, 'don\'t get stuck in a loop';

my $expected_usage = quotemeta( q{
Options:

<error>  Error
} );

ok $got_usage =~ m/$expected_usage/;