File: fallback.t

package info (click to toggle)
libdata-show-perl 0.004002-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 212 kB
  • sloc: perl: 550; makefile: 2
file content (124 lines) | stat: -rw-r--r-- 1,612 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use 5.010;
use Test::More eval{require Data::Dumper} ? 'no_plan' : (skip_all => 'This test requires Data::Dumper');
use Data::Show with => 'NonexistentDumper', fallback => 'Data::Dumper';
my $STDERR;
close STDERR;
open *STDERR, '>', \$STDERR or die $!;

my %foo = (foo => 1, food => 2, fool => 3, foop => 4, foon => [5..10]);
my @bar = qw<b a r>;
my $baz = 'baz';
my $ref = \@bar;
sub sq;

show(%foo);
show $/;
show @bar;
show (
    @bar,
    $baz,
);
show $baz;
show $ref;
show @bar[do{1..2;}];
show 2*3;
show 'a+b';
show 100 * sq length $baz;
show $foo{q[;{{{]};
do {
    show 'foo' =~ m/;\{\/\{/
};
show $/{Answer};

my $str = 'foo';
$str =~ m/(?<bar>\w+)/;
show $+{bar};

my @expected = <DATA>;                    chomp @expected;
my @got      = split "[ \t]*\n", $STDERR;    chomp @got;

for my $n (0..$#expected) {
    is $got[$n], $expected[$n] => ": $expected[$n]";
}

sub sq {
    my ($n) = @_;
    return $n * $n;
}

__DATA__
t/fallback.t
14   show(%foo);
(
  'foo' => 1,
  'food' => 2,
  'fool' => 3,
  'foon' => [
              5,
              6,
              7,
              8,
              9,
              10
            ],
  'foop' => 4
)

15   show $/;
'
'

16   show @bar;
(
  'b',
  'a',
  'r'
)

17   show (
18       @bar,
19       $baz,
20   );
(
  'b',
  'a',
  'r',
  'baz'
)

21   show $baz;
'baz'

22   show $ref;
[
  'b',
  'a',
  'r'
]

23   show @bar[do{1..2;}];
(
  'a',
  'r'
)

24   show 2*3;
6

25   show 'a+b';
'a+b'

26   show 100 * sq length $baz;
900

27   show $foo{q[;{{{]};
undef

29   show 'foo' =~ m/;\{\/\{/
()

31   show $/{Answer};
undef

35   show $+{bar};
'foo'