8
unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
9
plan skip_all => 'Needs DISPLAY';
19
my ( $start, $end, @matches ) = Padre::Util::get_matches( "abc", qr/x/, 0, 0 );
20
is_deeply( \@matches, [], 'no match' );
24
my (@matches) = Padre::Util::get_matches( "abc", qr/(b)/, 0, 0 );
25
is_deeply( \@matches, [ 1, 2, [ 1, 2 ] ], 'one match' );
29
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b)/, 0, 0 );
30
is_deeply( \@matches, [ 1, 2, [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], 'three matches' );
34
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b)/, 1, 2 );
35
is_deeply( \@matches, [ 3, 4, [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], 'three matches' );
39
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b)/, 3, 4 );
40
is_deeply( \@matches, [ 5, 6, [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], 'three matches' );
44
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b)/, 5, 6 );
45
is_deeply( \@matches, [ 1, 2, [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], 'three matches, wrapping' );
49
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b)/, 5, 6, 1 );
50
is_deeply( \@matches, [ 3, 4, [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], 'three matches backwards' );
54
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b)/, 1, 2, 1 );
55
is_deeply( \@matches, [ 5, 6, [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ], 'three matches backwards wrapping' );
59
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b(.))/, 1, 2 );
60
is_deeply( \@matches, [ 3, 5, [ 1, 3 ], [ 3, 5 ] ], '2 matches' );
64
my (@matches) = Padre::Util::get_matches( "abcbxb", qr/(b(.?))/, 1, 2, 1 );
65
is_deeply( \@matches, [ 5, 6, [ 1, 3 ], [ 3, 5 ], [ 5, 6 ] ], 'three matches bw, wrap' );
69
my $str = qq( perl ("שלום"); perl );
70
my (@matches) = Padre::Util::get_matches( $str, qr/(perl)/, 0, 0 );
72
# TODO are these really correct numbers?
73
is_deeply( \@matches, [ 1, 5, [ 1, 5 ], [ 28, 32 ] ], 'two matches with unicode' );
74
is( substr( $str, 1, 4 ), 'perl' );
79
my (@matches) = Padre::Util::get_matches( $str, qr/(üss)/, 0, 0 );
80
is_deeply( \@matches, [ 1, 7, [ 1, 7 ] ], 'one match with unicode regex' );
81
is( substr( $str, 1, 4 ), 'üss' );