This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Win32 is playing to hard to get but I do not have
[perl5.git] / lib / perl5db / de0.t
CommitLineData
fafebdf5
A
1#!./perl -- -*- mode: cperl; cperl-indent-level: 4 -*-
2
3BEGIN {
45369eab
JH
4 chdir 't' if -d 't';
5 @INC = '../lib';
cb08c255 6 require Config; import Config;
3379a47e
JH
7 if ($^O eq 'VMS') {
8 print "1..0 # skip on $^O, no piped open\n";
cb08c255 9 exit 0;
fafebdf5 10 }
cb08c255 11 $ENV{PERL5LIB} = '../lib'; # so children will see it too
fafebdf5
A
12}
13
14use strict;
cb08c255
JH
15use IPC::Open3 qw(open3);
16use IO::Select;
fafebdf5 17
cb08c255 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";
cb08c255
JH
35my($ornament1,$ornament2,$wtrfh,$rdrfh);
36open3 $wtrfh, $rdrfh, 0, $^X, "-de0";
37my $ios = IO::Select->new();
38$ios->add($rdrfh);
fafebdf5 39for (@prgs){
cb08c255
JH
40 my($prog,$expected) = split(/\nEXPECT\n?/, $_);
41 print $wtrfh $prog, "\n";
42 my $got;
43 while ($ios->can_read(0.25)) {
44 last unless sysread $rdrfh, $got, 1024, length($got);
45 }
46 SKIP: {
47 skip("failed to read debugger", 1) unless defined $got;
48 $got =~ s/^\s*Loading.*\r?\n?Editor.*\r?\n?\r?\n?Enter.*\r?\n?\r?\n?main::\(-e:1\):\s+0\r?\n?//;
49 unless (defined $ornament1) {
50 $got =~ s/^\s*Loading.*\r?\n?Editor.*\r?\n?\r?\n?Enter.*\r?\n?\r?\n?main::\(-e:1\):\s+0\r?\n?//;
51 ($ornament1,$ornament2) = $got =~
52 /(.*?)0\s+'reserved example for calibrating the ornaments'\r?\n?(.*)/
53 }
54 $got =~ s/^\Q$ornament1\E//;
55 $got =~ s/\Q$ornament2\E\z//;
56 like($got, qr:$expected:i, $prog);
fafebdf5 57 }
fafebdf5
A
58}
59
60__END__
61x "reserved example for calibrating the ornaments"
62EXPECT
630 'reserved example for calibrating the ornaments'
64########
65x "foo"
66EXPECT
670 'foo'
68########
7a2852ea
JH
69x "\x{100}"
70EXPECT
710 '\\x\{0100\}'
72########
73x *a
74EXPECT
750 \*main::a
76########
fafebdf5
A
77x 1..3
78EXPECT
790 1
801 2
812 3
82########
83x +{1..4}
84EXPECT
7a2852ea 850\s+HASH\(0x[0-9a-f]+\)
fafebdf5
A
86\s+1 => 2
87\s+3 => 4
88########