Skip to content

Commit

Permalink
fixed failing test on columns
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Apr 23, 2009
1 parent 02a2b65 commit 64166a4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Ack.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1100,10 +1100,10 @@ sub print_match_or_context {
my $is_match = shift; # is there a match on the line?
my $line_no = shift;

my $color = $opt->{color};
my $heading = $opt->{heading};
my $color = $opt->{color};
my $heading = $opt->{heading};
my $show_filename = $opt->{show_filename};
my $show_column = $opt->{with_column};
my $show_column = $opt->{column};

if ( $show_filename ) {
if ( not defined $display_filename ) {
Expand Down Expand Up @@ -1485,7 +1485,7 @@ Returns true if ack's input is coming from a pipe.
=cut

sub input_from_pipe() {
sub input_from_pipe {
return $input_from_pipe;
}

Expand All @@ -1496,7 +1496,7 @@ Returns true if ack's input is coming from a pipe.
=cut

sub output_to_pipe() {
sub output_to_pipe {
return $output_to_pipe;
}

Expand Down
10 changes: 5 additions & 5 deletions ack
Original file line number Diff line number Diff line change
Expand Up @@ -1982,10 +1982,10 @@ sub print_match_or_context {
my $is_match = shift; # is there a match on the line?
my $line_no = shift;

my $color = $opt->{color};
my $heading = $opt->{heading};
my $color = $opt->{color};
my $heading = $opt->{heading};
my $show_filename = $opt->{show_filename};
my $show_column = $opt->{with_column};
my $show_column = $opt->{column};

if ( $show_filename ) {
if ( not defined $display_filename ) {
Expand Down Expand Up @@ -2312,13 +2312,13 @@ sub set_up_pager {
}


sub input_from_pipe() {
sub input_from_pipe {
return $input_from_pipe;
}



sub output_to_pipe() {
sub output_to_pipe {
return $output_to_pipe;
}

Expand Down
15 changes: 7 additions & 8 deletions t/ack-column.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ use Util;
prep_environment();

my $weasel = File::Next::reslash( 't/text/science-of-myth.txt' );
my @base_args = qw( the -w -i --with-filename --noenv );

WITH_COLUMNS: {
my @expected = split( /\n/, <<'HERE' );
3:4:In the case of Christianity and Judaism there exists the belief
6:1:The Buddhists believe that the functional aspects override the myth
7:8:While other religions use the literal core to build foundations with
7:27:While other religions use the literal core to build foundations with
8:11:See, half the world sees the myth as fact, and it's seen as a lie by the other half
9:5:And the simple truth is that it's none of that 'cause
10:24:Somehow no matter what the world keeps turning
14:43:In fact, for better understanding we take the facts of science and apply them
15:35:And if both factors keep evolving then we continue getting information
16:17:But closing off the possibilities makes it hard to see the bigger picture
18:10:Consider the case of the woman whose faith helped her make it through
22:18:And if it works, then it gets the job done
22:31:And if it works, then it gets the job done
23:24:Somehow no matter what the world keeps turning
26:9: -- "The Science Of Myth", Screeching Weasel
HERE
@expected = map { "${weasel}:$_" } @expected;

my @files = ( $weasel );
my @args = qw( the -w --with-filename --column );
my @args = ( @base_args, '--column' );
my @results = run_ack( @args, @files );

sets_match( \@results, \@expected, 'Checking column numbers' );
lists_match( \@results, \@expected, 'Checking column numbers' );
}


Expand All @@ -49,7 +49,6 @@ WITHOUT_COLUMNS: {
9:And the simple truth is that it's none of that 'cause
10:Somehow no matter what the world keeps turning
14:In fact, for better understanding we take the facts of science and apply them
15:And if both factors keep evolving then we continue getting information
16:But closing off the possibilities makes it hard to see the bigger picture
18:Consider the case of the woman whose faith helped her make it through
22:And if it works, then it gets the job done
Expand All @@ -59,9 +58,9 @@ HERE
@expected = map { "${weasel}:$_" } @expected;

my @files = ( $weasel );
my @args = qw( the -w --with-filename --no-column );
my @args = ( @base_args, '--no-column' );
my @results = run_ack( @args, @files );

sets_match( \@results, \@expected, 'Checking without column numbers' );
lists_match( \@results, \@expected, 'Checking without column numbers' );
}

3 changes: 3 additions & 0 deletions tags
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ UNRESTRICTED_AND_DASH_G_INTERACTION t/ack-g.t /^UNRESTRICTED_AND_DASH_G_INTERACT
Usage Ack.pm /^Usage: ack [OPTION]... PATTERN [FILES]$/;" l
Usage Ack.pm /^Usage: ack [OPTION]... PATTERN [FILE]$/;" l
VERSION t/module.t /^VERSION: {$/;" l
WITHOUT_COLUMNS t/ack-column.t /^WITHOUT_COLUMNS: {$/;" l
WITH_COLUMNS t/ack-column.t /^WITH_COLUMNS: {$/;" l
WITH_O t/ack-o.t /^WITH_O: {$/;" l
WITH_O t/context.t /^WITH_O: {$/;" l
WITH_OUTPUT t/ack-o.t /^WITH_OUTPUT: {$/;" l
Expand Down Expand Up @@ -235,6 +237,7 @@ pipe_into_ack t/Util.pm /^sub pipe_into_ack {$/;" s
prep_environment t/Util.pm /^sub prep_environment {$/;" s
print Ack.pm /^sub print { print {$fh} @_ }$/;" s
print_blank_line Ack.pm /^sub print_blank_line { App::Ack::print( "\\n" ) }$/;" s
print_column_no Ack.pm /^sub print_column_no { App::Ack::print( $_[0], $_[1] ) }$/;" s
print_count Ack.pm /^sub print_count {$/;" s
print_count0 Ack.pm /^sub print_count0 {$/;" s
print_filename Ack.pm /^sub print_filename { App::Ack::print( $_[0], $_[1] ) }$/;" s
Expand Down

0 comments on commit 64166a4

Please sign in to comment.