summaryrefslogtreecommitdiff
path: root/scripts/t/850_Dpkg_Compression.t
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2012-12-31 21:43:39 +0100
committerGuillem Jover <guillem@debian.org>2013-05-04 19:03:13 +0200
commit6a73e3078b01a71d4a6ea90c85da16523ed56f1d (patch)
tree4cc7a210e7e851395f7ba4989e3aac4aa9d32710 /scripts/t/850_Dpkg_Compression.t
parent62bc788a45e4a641c28ca9c8c5b9bb08f29faed8 (diff)
downloaddpkg-6a73e3078b01a71d4a6ea90c85da16523ed56f1d.tar.gz
Do not use double-quotes on strings that do not need interpolation
Using double-quotes imposes a small performance penalty as the perl parser needs to check if any interpolation is needed. Use double-quotes only when the string contains single-quotes. Ideally we'd use double-quotes too for escaped meta-characters that might otherwise be confusing to immediately see if they need interpolation or not, but the policy does not (currently) allow to ignore these. Fixes ValuesAndExpressions::ProhibitInterpolationOfLiterals. Warned-by: perlcritic
Diffstat (limited to 'scripts/t/850_Dpkg_Compression.t')
-rw-r--r--scripts/t/850_Dpkg_Compression.t40
1 files changed, 20 insertions, 20 deletions
diff --git a/scripts/t/850_Dpkg_Compression.t b/scripts/t/850_Dpkg_Compression.t
index a4f99f0eb..4bac076f6 100644
--- a/scripts/t/850_Dpkg_Compression.t
+++ b/scripts/t/850_Dpkg_Compression.t
@@ -21,7 +21,7 @@ use warnings;
use_ok('Dpkg::Compression');
use_ok('Dpkg::Compression::FileHandle');
-my $tmpdir = "t.tmp/850_Dpkg_Compression";
+my $tmpdir = 't.tmp/850_Dpkg_Compression';
mkdir $tmpdir;
my @lines = ("One\n", "Two\n", "Three\n");
my $fh;
@@ -30,39 +30,39 @@ sub test_write {
my ($filename, $check_result) = @_;
$fh = Dpkg::Compression::FileHandle->new();
- open $fh, ">", $filename or die "open failed";
+ open $fh, '>', $filename or die 'open failed';
print $fh $lines[0];
syswrite($fh, $lines[1]);
- printf $fh "%s", $lines[2];
- close $fh or die "close failed";
+ printf $fh '%s', $lines[2];
+ close $fh or die 'close failed';
- &$check_result($filename, "std functions");
+ &$check_result($filename, 'std functions');
unlink $filename or die "cannot unlink $filename";
$fh = Dpkg::Compression::FileHandle->new();
- $fh->open($filename, "w");
+ $fh->open($filename, 'w');
$fh->print($lines[0]);
$fh->write($lines[1], length($lines[1]));
- $fh->printf("%s", $lines[2]);
- $fh->close() or die "close failed";
+ $fh->printf('%s', $lines[2]);
+ $fh->close() or die 'close failed';
- &$check_result($filename, "IO::Handle methods");
+ &$check_result($filename, 'IO::Handle methods');
}
sub check_uncompressed {
my ($filename, $method) = @_;
- open(my $read_fh, "<", $filename) or die "cannot read $filename";
+ open(my $read_fh, '<', $filename) or die "cannot read $filename";
my @read = <$read_fh>;
- close $read_fh or die "cannot close";
+ close $read_fh or die 'cannot close';
is_deeply(\@lines, \@read, "$filename correctly written ($method)");
}
sub check_compressed {
my ($filename, $method) = @_;
- open(my $read_fh, "-|", "zcat $tmpdir/myfile.gz") or die "cannot fork zcat";
+ open(my $read_fh, '-|', "zcat $tmpdir/myfile.gz") or die 'cannot fork zcat';
my @read = <$read_fh>;
- close $read_fh or die "cannot close";
+ close $read_fh or die 'cannot close';
is_deeply(\@lines, \@read, "$filename correctly written ($method)");
}
@@ -70,17 +70,17 @@ sub test_read {
my ($filename) = @_;
$fh = Dpkg::Compression::FileHandle->new();
- open($fh, "<", $filename) or die "open failed";
+ open($fh, '<', $filename) or die 'open failed';
my @read = <$fh>;
- close $fh or die "close failed";
+ close $fh or die 'close failed';
is_deeply(\@lines, \@read, "$filename correctly read (std functions)");
@read = ();
$fh = Dpkg::Compression::FileHandle->new();
- $fh->open($filename, "r") or die "open failed";
+ $fh->open($filename, 'r') or die 'open failed';
@read = $fh->getlines();
- $fh->close() or die "close failed";
+ $fh->close() or die 'close failed';
is_deeply(\@lines, \@read, "$filename correctly read (IO::Handle methods)");
}
@@ -88,11 +88,11 @@ sub test_read {
# Test changing the default compression levels
my $old_level = compression_get_default_level();
compression_set_default_level(1);
-is(compression_get_default_level(), 1, "change default compression level");
+is(compression_get_default_level(), 1, 'change default compression level');
compression_set_default_level(5);
-is(compression_get_default_level(), 5, "change default compression level");
+is(compression_get_default_level(), 5, 'change default compression level');
compression_set_default_level(undef);
-is(compression_get_default_level(), $old_level, "reset default compression level");
+is(compression_get_default_level(), $old_level, 'reset default compression level');
# Test write on uncompressed file
test_write("$tmpdir/myfile", \&check_uncompressed);