diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-02-26 14:15:02 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2012-02-27 11:17:21 +0100 |
commit | c1c954ee5d95900533d4ab0785198b373fdb7fb8 (patch) | |
tree | acc59f6b775bacbe86209e1929023d39150a2f4b /t/run | |
parent | 901455ecceca122044b675aeea6938e5a510ebb4 (diff) | |
download | perl-c1c954ee5d95900533d4ab0785198b373fdb7fb8.tar.gz |
Improve the tests for the -n and -p switches.
Verify that -p actually runs the code in the program body.
Verify that -n doesn't implicitly print out the contents of $_.
For both, verify that an END block runs after the implicit loop.
Diffstat (limited to 't/run')
-rw-r--r-- | t/run/switchn.t | 9 | ||||
-rw-r--r-- | t/run/switchp.t | 12 |
2 files changed, 17 insertions, 4 deletions
diff --git a/t/run/switchn.t b/t/run/switchn.t index 12d3898a8e..bca9a66e76 100644 --- a/t/run/switchn.t +++ b/t/run/switchn.t @@ -1,11 +1,18 @@ #!./perl -n BEGIN { - print "1..2\n"; + print "1..3\n"; *ARGV = *DATA; } + +END { + print "ok 3\n"; +} + print; +s/^/not /; + __DATA__ ok 1 ok 2 diff --git a/t/run/switchp.t b/t/run/switchp.t index 19947356d9..1d1fe1485f 100644 --- a/t/run/switchp.t +++ b/t/run/switchp.t @@ -1,10 +1,16 @@ #!./perl -p BEGIN { - print "1..2\n"; + print "1..3\n"; *ARGV = *DATA; } +END { + print "ok 3\n"; +} + +s/^not //; + __DATA__ -ok 1 -ok 2 +not ok 1 +not ok 2 |