Commit | Line | Data |
---|---|---|
fafebdf5 A |
1 | #!./perl -- -*- mode: cperl; cperl-indent-level: 4 -*- |
2 | ||
3 | BEGIN { | |
45369eab JH |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; | |
cc5fd094 | 6 | require Config; import Config; |
22ad4450 | 7 | unless ($Config{d_fork}) { |
45369eab | 8 | print "1..0 # no fork\n"; |
fafebdf5 A |
9 | exit 0; |
10 | } | |
fafebdf5 A |
11 | $ENV{PERL5LIB} = '../lib'; # so children will see it too |
12 | } | |
13 | ||
14 | use strict; | |
cc5fd094 A |
15 | use IPC::Open3 qw(open3); |
16 | use IO::Select; | |
fafebdf5 A |
17 | |
18 | $|=1; | |
7a2852ea JH |
19 | |
20 | my @prgs; | |
21 | ||
22 | { | |
23 | local $/; | |
24 | @prgs = split "########\n", <DATA>; | |
25 | close DATA; | |
26 | } | |
27 | ||
28 | use Test::More; | |
29 | ||
30 | plan tests => scalar @prgs; | |
31 | ||
fafebdf5 A |
32 | require "dumpvar.pl"; |
33 | ||
fafebdf5 | 34 | $ENV{PERLDB_OPTS} = "TTY=0"; |
cc5fd094 A |
35 | my($ornament1,$ornament2,$wtrfh,$rdrfh); |
36 | open3 $wtrfh, $rdrfh, 0, $^X, "-de0"; | |
37 | my $ios = IO::Select->new(); | |
38 | $ios->add($rdrfh); | |
fafebdf5 A |
39 | for (@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__ | |
60 | x "reserved example for calibrating the ornaments" | |
61 | EXPECT | |
62 | 0 'reserved example for calibrating the ornaments' | |
63 | ######## | |
64 | x "foo" | |
65 | EXPECT | |
66 | 0 'foo' | |
67 | ######## | |
7a2852ea JH |
68 | x "\x{100}" |
69 | EXPECT | |
70 | 0 '\\x\{0100\}' | |
71 | ######## | |
72 | x *a | |
73 | EXPECT | |
74 | 0 \*main::a | |
75 | ######## | |
fafebdf5 A |
76 | x 1..3 |
77 | EXPECT | |
78 | 0 1 | |
79 | 1 2 | |
80 | 2 3 | |
81 | ######## | |
82 | x +{1..4} | |
83 | EXPECT | |
7a2852ea | 84 | 0\s+HASH\(0x[0-9a-f]+\) |
fafebdf5 A |
85 | \s+1 => 2 |
86 | \s+3 => 4 | |
87 | ######## |