File: no_show_lexical.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 (85 lines) | stat: -rw-r--r-- 1,360 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
use 5.010;
use Data::Show;
use Test::More eval{require Data::Pretty} ? 'no_plan' : (skip_all => 'This test requires Data::Pretty');
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;
{ no Data::Show; show $ref; }
show @bar[do{1..2;}];
show 2*3;
{ no Data::Show; show 'a+b'; }
show 100 * sq length $baz;
show $foo{q[;{{{]};
do { no Data::Show;
    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/no_show_lexical.t
14   show(%foo);
( foo => 1, food => 2, fool => 3, foon => [5 .. 10], foop => 4 )

15   show $/;
"\n"

16   show @bar;
(qw( b a r ))

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

21   show $baz;
"baz"

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

24   show 2*3;
6

26   show 100 * sq length $baz;
900

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

31   show $/{Answer};
undef

35   show $+{bar};
"foo"