Skip to content

Commit

Permalink
#34 extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 4, 2023
1 parent 12eb896 commit cd6f121
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions perl-tests/fixing-in-place.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,36 @@ package bibcop;
print $out '@article{knuth, author = {Knuth, Donald E}} @book{lamport, title={LaTeX}}';
close($out);

my $stdout = `perl ./bibcop.pl --in-place --fix '$temp' 2>&1`;
if (not $stdout eq '') {
print $stdout;
my $stdout1 = `perl ./bibcop.pl --in-place --fix '$temp' 2>&1`;
if (not $stdout1 eq '') {
print $stdout1;
print "This output was not expected!\n";
exit 1;
}

open(my $in, '<', $temp);
my $after; { local $/; $after = <$in>; }
open(my $in1, '<', $temp);
my $after1; { local $/; $after1 = <$in1>; }
close($in1);

if (index($after, 'Knuth, Donald E.') == 1) {
if (index($after1, 'Knuth, Donald E.') == 1) {
print "Didn't fix in place\n";
exit 1;
}

my $stdout2 = `perl ./bibcop.pl --in-place --fix '$temp' 2>&1`;
if (not $stdout2 eq '') {
print $stdout2;
print "This output was not expected!\n";
exit 1;
}

open(my $in2, '<', $temp);
my $after2; { local $/; $after2 = <$in2>; }
close($in2);

if (not $after2 eq $after1) {
print "Fixing again, why?\n";
exit 1;
}

1;

0 comments on commit cd6f121

Please sign in to comment.