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