File: quote.t

package info (click to toggle)
libpkgconfig-perl 0.23026-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,912 kB
  • sloc: ansic: 6,120; perl: 1,968; makefile: 4
file content (49 lines) | stat: -rw-r--r-- 1,443 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;
use PkgConfig;
use FindBin ();
use File::Spec;
use Test::More tests => 6;

my $path = File::Spec->catfile($FindBin::Bin, 'data', 'quote');

foreach my $type (qw( doublequote singlequote backslash quotevar ))
{
  subtest $type => sub {
  
    my $pkg = PkgConfig->find($type,
      search_path => [File::Spec->catfile($FindBin::Bin, 'data', 'quote')],
    );
    
    isa_ok $pkg, 'PkgConfig';
    is $pkg->errmsg, undef, 'no error';

    is_deeply [$pkg->get_cflags], ['-I/foo/include', '-DFOO=bar baz'], 'list context';
    is scalar $pkg->get_cflags, '-I/foo/include -DFOO=bar\\ baz', 'scalar context';
    #note $_ for $pkg->get_cflags;
  };
}

subtest 'noquote' => sub {
  my $pkg = PkgConfig->find('noquote',
    search_path => [File::Spec->catfile($FindBin::Bin, 'data', 'quote')],
  );
  
  isa_ok $pkg, 'PkgConfig';
  is $pkg->errmsg, undef, 'no error';
  
  is_deeply [$pkg->get_cflags], ['-I/foo/include', '-DFOO=bar'], 'list context';
  is scalar $pkg->get_cflags, '-I/foo/include -DFOO=bar', 'scalar context';
};

subtest 'escape' => sub {
  my $pkg = PkgConfig->find('escape',
    search_path => [File::Spec->catfile($FindBin::Bin, 'data', 'quote')],
  );
  
  isa_ok $pkg, 'PkgConfig';
  is $pkg->errmsg, undef, 'no error';
  
  is_deeply [$pkg->get_cflags], ['-I/foo/include', '-DFOO="bar_baz"'], 'list context';
  is scalar $pkg->get_cflags, '-I/foo/include -DFOO=\\"bar_baz\\"', 'scalar context';
};