xref: /openbsd-src/gnu/usr.bin/perl/cpan/Test-Harness/t/glob-to-regexp.t (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1#!/usr/bin/perl -w
2
3use strict;
4
5use Test::More;
6
7require TAP::Parser::Scheduler;
8
9my @tests;
10while (<DATA>) {
11    my ( $glob, $pattern, $name ) = /^(\S+)\t+(\S+)(?:\t+(.*))?$/;
12    die "'$_'" unless $pattern;
13    push @tests, [ $glob, $pattern, $name ];
14}
15
16plan tests => scalar @tests;
17
18for (@tests) {
19    my ( $glob, $pattern, $name ) = @$_;
20    is( TAP::Parser::Scheduler->_glob_to_regexp($glob), $pattern,
21        defined $name ? "$glob  -- $name" : $glob
22    );
23}
24__DATA__
25Pie			Pie
26*.t			[^/]*\.t
27**.t			.*?\.t
28A?B			A[^/]B
29*/*.t			[^/]*\/[^/]*\.t
30A,B			A\,B				, outside {} not special
31{A,B}			(?:A|B)
32A{B}C			A(?:B)C
33A{B,C}D			A(?:B|C)D
34A{B,C,D}E{F,G,H}I,J	A(?:B|C|D)E(?:F|G|H)I\,J
35{Perl,Rules}		(?:Perl|Rules)
36A}B			A\}B				Bare } corner case
37A{B,C}D}E		A(?:B|C)D\}E
38},A{B,C}D},E		\}\,A(?:B|C)D\}\,E
39{A{1,2},D{3,4}}		(?:A(?:1|2)|D(?:3|4))
40{A,{B,C},D}		(?:A|(?:B|C)|D)
41A{B,C\}D,E\,F}G		A(?:B|C\}D|E\,F)G
42A\\B			A\\B
43A(B)C			A\(B\)C
441{A(B)C,D|E}2		1(?:A\(B\)C|D\|E)2
45