Permalink
Browse files

Extract a closure.

  • Loading branch information...
1 parent a3fef16 commit 3dc282caf9b74347dc090e67a2bef4efc52ae205 @shlomif committed Oct 30, 2011
Showing with 13 additions and 3 deletions.
  1. +13 −3 t/Helper.pm
View
@@ -39,11 +39,21 @@ sub run_debugger($$;$$)
my $run_opts = $opts->{run_opts} || "--basename --nx --no-highlight";
my $full_cmdfile = File::Spec->catfile(dirname(__FILE__), 'data', $cmdfile);
+ my $ext_file = sub {
+ my ($ext) = @_;
+
+ my $new_fn = $full_cmdfile;
+
+ $new_fn =~ s/\.cmd\z/.$ext/;
+
+ return $new_fn;
+ };
+
$run_opts .= " --command $full_cmdfile" unless ($opts->{no_cmdfile});
if (!defined($rightfile))
{
- ($rightfile = $full_cmdfile) =~ s/\.cmd\z/.right/;
+ $rightfile = $ext_file->('right');
}
my $cmd = "$EXECUTABLE_NAME $trepanpl $run_opts $test_invoke";
@@ -62,8 +72,8 @@ sub run_debugger($$;$$)
($output, $right_string) = $opts->{filter}->($output, $right_string);
}
- my $gotfile;
- ($gotfile = $full_cmdfile) =~ s/\.cmd/.got/;
+ my $gotfile = $ext_file->('got');
+
if ($right_string eq $output) {
Test::More::ok(1);
unlink $gotfile;

1 comment on commit 3dc282c

rocky commented on 3dc282c Nov 4, 2011

Applied.

Please sign in to comment.