[perl #123836] basic tests for dump, catches the issue as a TODO
authorTony Cook <tony@develop-help.com>
Mon, 16 Feb 2015 00:54:25 +0000 (11:54 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 16 Feb 2015 22:39:41 +0000 (09:39 +1100)
MANIFEST
t/op/dump.t [new file with mode: 0644]

index 0427a9f..7a6ab41 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5280,6 +5280,7 @@ t/op/die.t                        See if die works
 t/op/die_unwind.t              Check die/eval early-$@ backcompat hack
 t/op/dor.t                     See if defined-or (//) works
 t/op/do.t                      See if subroutines work
+t/op/dump.t                    See if dump works.
 t/op/each_array.t              See if array iterators work
 t/op/each.t                    See if hash iterators work
 t/op/evalbytes.t               See if evalbytes operator works
diff --git a/t/op/dump.t b/t/op/dump.t
new file mode 100644 (file)
index 0000000..27b95bf
--- /dev/null
@@ -0,0 +1,59 @@
+#!./perl
+
+# Minimally test if dump() behaves as expected
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = qw(. ../lib);
+    require './test.pl';
+
+    skip_all_if_miniperl();
+}
+
+use Config;
+use File::Temp qw(tempdir);
+use Cwd qw(getcwd);
+
+skip_all("only tested on devel builds")
+  unless $Config{usedevel};
+
+# there may be other operating systems where it makes sense, but
+# there are some where it isn't, so limit the platforms we test
+# this on
+skip_all("no point in dumping on $^O")
+  unless $^O =~ /^(linux|.*bsd|solaris)$/;
+
+# execute in a work directory so File::Temp can clean up core dumps
+my $tmp = tempdir(CLEANUP => 1);
+
+my $start = getcwd;
+
+chdir $tmp
+  or skip_all("Cannot chdir to work directory");
+
+plan(2);
+
+# depending on how perl is built there may be extra output after
+# the A such as "Aborted".
+
+fresh_perl_like(<<'PROG', qr/\AA(?!B\z)/, {}, "plain dump quits");
+++$|;
+print qq(A);
+dump;
+print qq(B);
+PROG
+
+{
+local $TODO = "[perl #123836]";
+fresh_perl_like(<<'PROG', qr/A(?!B\z)/, {}, "dump with label quits");
+++$|;
+print qq(A);
+dump foo;
+foo:
+print qq(B);
+PROG
+}
+
+END {
+  chdir $start;
+}