summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-09-15 17:42:59 +0000
committerNicholas Clark <nick@ccl4.org>2021-09-16 13:54:40 +0000
commit1a40fa6ddbc0f611355e78ab3e623e38d54977c6 (patch)
treee7e67d1e714671dabe52e8c670bbd8b371ab213d /t
parent9038fafc024d2d25fc1aa7f9c38d1e2ede35ce5c (diff)
downloadperl-1a40fa6ddbc0f611355e78ab3e623e38d54977c6.tar.gz
Add strict and warnings to t/op/for.t
strict subs and refs, but not strict vars, because it's obvious that some tests are explicitly about package variables, but it's not obvious whether what they are testing is sensitive to rewriting the variables with full package names. Also convert it to done_testing(), and add a call to set_up_inc().
Diffstat (limited to 't')
-rw-r--r--t/op/for.t14
1 files changed, 11 insertions, 3 deletions
diff --git a/t/op/for.t b/t/op/for.t
index f34fbd8b56..d199cc8a82 100644
--- a/t/op/for.t
+++ b/t/op/for.t
@@ -3,9 +3,11 @@
BEGIN {
chdir 't' if -d 't';
require "./test.pl";
+ set_up_inc('../lib');
}
-plan(126);
+use strict qw(subs refs);
+use warnings;
# A lot of tests to check that reversed for works.
@@ -548,12 +550,16 @@ for my $i (reverse (map {$_} @array, 1)) {
}
is ($r, '1CBA', 'Reverse for array and value via map with var');
-is do {17; foreach (1, 2) { 1; } }, '', "RT #1085: what should be output of perl -we 'print do { foreach (1, 2) { 1; } }'";
+{
+ no warnings 'void';
+ is (do {17; foreach (1, 2) { 1; } }, "",
+ "RT #1085: what should be output of perl -we 'print do { foreach (1, 2) { 1; } }'");
+}
TODO: {
local $TODO = "RT #2166: foreach spuriously autovivifies";
my %h;
- foreach (@h{a, b}) {}
+ foreach (@h{'a', 'b'}) {}
is keys(%h), 0, 'RT #2166: foreach spuriously autovivifies';
}
@@ -678,3 +684,5 @@ is(fscope(), 1, 'return via loop in sub');
push @b, $_ for (reverse 'bar');
is "@b", "bar", " RT #133558 reverse list";
}
+
+done_testing();