File: ppi_token_regexp.t

package info (click to toggle)
libppi-perl 1.236-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,056 kB
  • ctags: 922
  • sloc: perl: 15,002; makefile: 8
file content (34 lines) | stat: -rwxr-xr-x 860 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use strict;
use File::Spec::Functions ':ALL';

use lib 't/lib';
use PPI::Test::pragmas;
use PPI;

# Execute the tests
use Test::More tests => 7 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

use lib 't/lib';
use Helper 'check_with';

run();

sub run {
	check_with "m{a}i", sub {
		my $qr = $_->find_first( 'Token::Regexp' );
		ok $qr, 'found qr token';
		is $qr->get_match_string,      "a",   "sucessfully retrieved match string";
		is $qr->get_substitute_string, undef, "substitute string method exists but returns undef";
		ok $qr->get_modifiers->{i}, "regex modifiers can be queried";
		is( ( $qr->get_delimiters )[0], "{}", "delimiters can be retrieved" );
	};
	check_with "s{a}{b}i", sub {
		my $qr = $_->find_first( 'Token::Regexp' );
		ok $qr, 'found qr token';
		is $qr->get_substitute_string, "b", "substitute string can be extracted";
	};
}

1;