This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In Win32 IPC::Open3 + IO::Select does not work that well
[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';
3379a47e
JH
6 $ENV{PERL5LIB} = '../lib'; # so children will see it too
7 if ($^O eq 'VMS') {
8 print "1..0 # skip on $^O, no piped open\n";
fafebdf5
A
9 exit 0;
10 }
fafebdf5
A
11}
12
13use strict;
14
3379a47e 15$| = 1;
7a2852ea
JH
16
17my @prgs;
18
19{
20 local $/;
21 @prgs = split "########\n", <DATA>;
22 close DATA;
23}
24
25use Test::More;
26
27plan tests => scalar @prgs;
28
fafebdf5
A
29require "dumpvar.pl";
30
3379a47e
JH
31use File::Temp qw/tempfile/;
32
33our ($tmpfh, $tmpfile) = tempfile();
34
fafebdf5 35$ENV{PERLDB_OPTS} = "TTY=0";
3379a47e 36my($ornament1,$ornament2);
fafebdf5 37for (@prgs){
3379a47e
JH
38 my($prog, $expected) = split(/\nEXPECT\n?/, $_);
39 open my $select, "| $^X -de0 2> $tmpfile" or die $!;
40 print $select $prog;
41 close $select;
42 my $got = do { open my($fh), $tmpfile or die; local $/; <$fh>; };
fafebdf5
A
43 $got =~ s/^\s*Loading.*\nEditor.*\n\nEnter.*\n\nmain::\(-e:1\):\s0\n//;
44 unless (defined $ornament1) {
3379a47e
JH
45 ($ornament1, $ornament2) = $got =~
46 /(.*?)0\s+'reserved example for calibrating the ornaments'\n(.*)/
fafebdf5
A
47 }
48 $got =~ s/^\Q$ornament1\E//;
49 $got =~ s/\Q$ornament2\E\z//;
7a2852ea 50 like($got, qr:$expected:i, $prog);
fafebdf5
A
51}
52
53__END__
54x "reserved example for calibrating the ornaments"
55EXPECT
560 'reserved example for calibrating the ornaments'
57########
58x "foo"
59EXPECT
600 'foo'
61########
7a2852ea
JH
62x "\x{100}"
63EXPECT
640 '\\x\{0100\}'
65########
66x *a
67EXPECT
680 \*main::a
69########
fafebdf5
A
70x 1..3
71EXPECT
720 1
731 2
742 3
75########
76x +{1..4}
77EXPECT
7a2852ea 780\s+HASH\(0x[0-9a-f]+\)
fafebdf5
A
79\s+1 => 2
80\s+3 => 4
81########