Permalink
Browse files

Fix tests & code for --column + -C.

The tests and the code for the --column and -C context case from the
previous commits were broken. This commit fixes both the code (to not
emit the warnings) and the tests (so the right behaviour will be
exhibited).

See:

petdance#240 .
  • Loading branch information...
1 parent 639bd6a commit 155ec30d7c48941589069e1e7be2859c82d5aaf7 @shlomif committed Dec 12, 2012
Showing with 7 additions and 5 deletions.
  1. +1 −1 Ack.pm
  2. +6 −4 t/context.t
View
2 Ack.pm
@@ -1260,7 +1260,7 @@ sub print_match_or_context {
# remove any kind of newline at the end of the line
s/[\r\n]*\z//;
}
- if ( $show_column ) {
+ if ( $show_column && $is_match ) {
App::Ack::print_column_no( $match_start+1, $sep );
}
App::Ack::print($_ . "\n");
View
@@ -3,7 +3,7 @@
use warnings;
use strict;
-use Test::More tests => 22;
+use Test::More tests => 24;
use File::Next 0.34; # for reslash function
use lib 't';
@@ -242,11 +242,13 @@ WITH_COLUMNS_AND_CONTEXT: {
25-
26- -- "The Science Of Myth", Screeching Weasel
HERE
- my $weasel = File::Next::reslash( 't/text/science-of-myth.txt' );
+ my $weasel = File::Next::reslash( 't/text/science-of-myth.txt' );
my @files = ( $weasel );
- @expected = map { "${weasel}:$_" } @expected;
+ @expected = map {
+ $_ eq '--' ? $_ : ($weasel . (/\A\d+-/ ? '-' : ':') . $_)
+ } @expected;
- my @args = qw( somehow -w -i --noenv --type=text --column -C2 );
+ my @args = qw( somehow -H -w -i --noenv --type=text --column -C2 );
my @results = run_ack( @args, @files );
lists_match( \@results, \@expected, 'Checking context with column numbers' );

0 comments on commit 155ec30

Please sign in to comment.