From c1c954ee5d95900533d4ab0785198b373fdb7fb8 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sun, 26 Feb 2012 14:15:02 +0100 Subject: 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. --- t/run/switchn.t | 9 ++++++++- 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 -- cgit v1.2.1