File: ack-group.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 (119 lines) | stat: -rw-r--r-- 3,327 bytes parent folder | download | duplicates (3)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 12;
use File::Next ();

use lib 't';
use Util;

prep_environment();

my $freedom = File::Next::reslash( 't/text/freedom-of-choice.txt' );
my $bobbie  = File::Next::reslash( 't/text/me-and-bobbie-mcgee.txt' );

NO_GROUPING: {
    my @expected = split( /\n/, <<"EOF" );
$freedom:2:Nobody ever said life was free
$freedom:4:But use your freedom of choice
$freedom:6:I'll say it again in the land of the free
$freedom:7:Use your freedom of choice
$freedom:8:Your freedom of choice
$freedom:28:I'll say it again in the land of the free
$freedom:29:Use your freedom of choice
$bobbie:12:    Nothin' don't mean nothin' if it ain't free
$bobbie:27:    Nothin' don't mean nothin' if it ain't free
EOF

    my @files = sort glob( 't/text/*.txt' );

    my @arg_sets = (
        [qw( -a --nogroup --nocolor free )],
        [qw( -a --nobreak --noheading --nocolor free )],
    );
    for my $set ( @arg_sets ) {
        my @results = run_ack( @{$set}, @files );
        lists_match( \@results, \@expected, 'No grouping' );
    }
}


STANDARD_GROUPING: {
    my @expected = split( /\n/, <<"EOF" );
$freedom
2:Nobody ever said life was free
4:But use your freedom of choice
6:I'll say it again in the land of the free
7:Use your freedom of choice
8:Your freedom of choice
28:I'll say it again in the land of the free
29:Use your freedom of choice

$bobbie
12:    Nothin' don't mean nothin' if it ain't free
27:    Nothin' don't mean nothin' if it ain't free
EOF

    my @files = sort glob( 't/text/*.txt' );
    my @arg_sets = (
        [qw( -a --group --nocolor free )],
        [qw( -a --heading --break --nocolor free )],
    );
    for my $set ( @arg_sets ) {
        my @results = run_ack( @{$set}, @files );
        lists_match( \@results, \@expected, 'Standard grouping' );
    }
}

HEADING_NO_BREAK: {
    my @expected = split( /\n/, <<"EOF" );
$freedom
2:Nobody ever said life was free
4:But use your freedom of choice
6:I'll say it again in the land of the free
7:Use your freedom of choice
8:Your freedom of choice
28:I'll say it again in the land of the free
29:Use your freedom of choice
$bobbie
12:    Nothin' don't mean nothin' if it ain't free
27:    Nothin' don't mean nothin' if it ain't free
EOF

    my @files = sort glob( 't/text/*.txt' );
    my @arg_sets = (
        [qw( -a --heading --nobreak --nocolor free )],
    );
    for my $set ( @arg_sets ) {
        my @results = run_ack( @{$set}, @files );
        lists_match( \@results, \@expected, 'Standard grouping' );
    }
}

BREAK_NO_HEADING: {
    my @expected = split( /\n/, <<"EOF" );
$freedom:2:Nobody ever said life was free
$freedom:4:But use your freedom of choice
$freedom:6:I'll say it again in the land of the free
$freedom:7:Use your freedom of choice
$freedom:8:Your freedom of choice
$freedom:28:I'll say it again in the land of the free
$freedom:29:Use your freedom of choice

$bobbie:12:    Nothin' don't mean nothin' if it ain't free
$bobbie:27:    Nothin' don't mean nothin' if it ain't free
EOF

    my @files = sort glob( 't/text/*.txt' );

    my @arg_sets = (
        [qw( -a --break --noheading --nocolor free )],
    );
    for my $set ( @arg_sets ) {
        my @results = run_ack( @{$set}, @files );
        lists_match( \@results, \@expected, 'No grouping' );
    }
}