This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Cleanup PerlIO::scalar documentation a bit.
[perl5.git] / lib / perl5db / dumpvar.t
CommitLineData
fafebdf5
A
1#!./perl -- -*- mode: cperl; cperl-indent-level: 4 -*-
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
e8c07a23
JH
6 unless (find PerlIO::Layer 'perlio') { # PerlIO::scalar
7 print "1..0 # Skip: not perlio\n";
8 exit 0;
9 }
fafebdf5
A
10}
11
12use strict;
13
14$|=1;
15undef $/;
16my @prgs = split "########\n", <DATA>;
17close DATA;
18print "1..", scalar @prgs, "\n";
19require "dumpvar.pl";
20
21my $i = 0;
22for (@prgs){
23 my($prog,$expected) = split(/\nEXPECT\n?/, $_);
24 open my $select, ">", \my $got or die;
25 select $select;
26 eval $prog;
27 my $not = "";
28 my $why = "";
29 if ($@) {
30 $not = "not ";
31 $why = " # prog[$prog]\$\@[$@]";
32 } elsif ($got ne $expected) {
33 $not = "not ";
34 $why = " # prog[$prog]got[$got]expected[$expected]";
35 }
36 close $select;
37 select STDOUT;
38 print $not, "ok ", ++$i, $why, "\n";
39}
40
41__END__
42"";
43EXPECT
44########
45dumpValue(1);
46EXPECT
471
48########
49dumpValue("1\n2\n3");
50EXPECT
51'1
522
533'
54########
55dumpValue([1..3],1);
56EXPECT
570 1
581 2
592 3
60########
61dumpValue({1..4},1);
62EXPECT
631 => 2
643 => 4
65########