This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Let's require fork for this test.
[perl5.git] / lib / perl5db / de0.t
CommitLineData
fafebdf5
A
1#!./perl -- -*- mode: cperl; cperl-indent-level: 4 -*-
2
3BEGIN {
cc5fd094 4 require Config; import Config;
22ad4450 5 unless ($Config{d_fork}) {
cc5fd094 6 print "1..0\n";
fafebdf5
A
7 exit 0;
8 }
9 chdir 't' if -d 't';
10 @INC = '../lib';
11 $ENV{PERL5LIB} = '../lib'; # so children will see it too
12}
13
14use strict;
cc5fd094
A
15use IPC::Open3 qw(open3);
16use IO::Select;
fafebdf5
A
17
18$|=1;
7a2852ea
JH
19
20my @prgs;
21
22{
23 local $/;
24 @prgs = split "########\n", <DATA>;
25 close DATA;
26}
27
28use Test::More;
29
30plan tests => scalar @prgs;
31
fafebdf5
A
32require "dumpvar.pl";
33
fafebdf5 34$ENV{PERLDB_OPTS} = "TTY=0";
cc5fd094
A
35my($ornament1,$ornament2,$wtrfh,$rdrfh);
36open3 $wtrfh, $rdrfh, 0, $^X, "-de0";
37my $ios = IO::Select->new();
38$ios->add($rdrfh);
fafebdf5
A
39for (@prgs){
40 my($prog,$expected) = split(/\nEXPECT\n?/, $_);
cc5fd094
A
41 print $wtrfh $prog, "\n";
42 my $got;
43 while (not defined $got) {
44 while ($ios->can_read(0.25)) {
45 sysread $rdrfh, $got, 1024, length($got);
46 }
47 }
fafebdf5
A
48 $got =~ s/^\s*Loading.*\nEditor.*\n\nEnter.*\n\nmain::\(-e:1\):\s0\n//;
49 unless (defined $ornament1) {
cc5fd094
A
50 $got =~ s/^\s*Loading.*\nEditor.*\n\nEnter.*\n\nmain::\(-e:1\):\s0\n//;
51 ($ornament1,$ornament2) = $got =~
52 /(.*?)0\s+'reserved example for calibrating the ornaments'\n(.*)/
fafebdf5
A
53 }
54 $got =~ s/^\Q$ornament1\E//;
55 $got =~ s/\Q$ornament2\E\z//;
7a2852ea 56 like($got, qr:$expected:i, $prog);
fafebdf5
A
57}
58
59__END__
60x "reserved example for calibrating the ornaments"
61EXPECT
620 'reserved example for calibrating the ornaments'
63########
64x "foo"
65EXPECT
660 'foo'
67########
7a2852ea
JH
68x "\x{100}"
69EXPECT
700 '\\x\{0100\}'
71########
72x *a
73EXPECT
740 \*main::a
75########
fafebdf5
A
76x 1..3
77EXPECT
780 1
791 2
802 3
81########
82x +{1..4}
83EXPECT
7a2852ea 840\s+HASH\(0x[0-9a-f]+\)
fafebdf5
A
85\s+1 => 2
86\s+3 => 4
87########