File: ack-env.t

package info (click to toggle)
ack-grep 1.80-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 680 kB
  • ctags: 161
  • sloc: perl: 4,715; ansic: 21; fortran: 11; makefile: 9
file content (48 lines) | stat: -rw-r--r-- 1,480 bytes parent folder | download
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
#!perl

use warnings;
use strict;

use Test::More tests => 6;

use lib 't';
use Util;

prep_environment();

SINGLE_TEXT_MATCH_ENV: {
    my @expected = (
        'And I said: "My name is Sue! How do you do! Now you gonna die!"',
    );

    my @files = qw( t/text );
    local $ENV{ACK_OPTIONS} = '-1';         # set the parameter via the options
    my @args = qw( Sue! -h --text --env );  # and specifying --env does not change the result
    my @results = run_ack( @args, @files );

    sets_match( \@results, \@expected, 'Looking for first instance of Sue! with --env' );
}

SINGLE_TEXT_MATCH_NOENV: {
    my @expected = split( /\n/, <<'EOF' );
And I said: "My name is Sue! How do you do! Now you gonna die!"
Bill or George! Anything but Sue! I still hate that name!
EOF

    my @files = qw( t/text );
    local $ENV{ACK_OPTIONS} = '-1';          # set the parameter via the options
    my @args = qw( Sue! -h --text --noenv ); # but disable environment processing
    my @results = run_ack( @args, @files );

    sets_match( \@results, \@expected, 'Looking for Sue! with --noenv' );
}

SEARCH_FOR_DASH_DASH_NOENV: {
    my @expected = ' magic string --noenv';
    my @files = qw( t/text );
    local $ENV{ACK_OPTIONS} = '-h --cc';          # set the parameter via the options
    my @args = qw( -- --noenv t/swamp ); # but disable environment processing
    my @results = run_ack( @args, @files );

    sets_match( \@results, \@expected, 'Looking for Sue! with --noenv' );
}