File: grid_ascii.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 (167 lines) | stat: -rw-r--r-- 9,259 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
use 5.010;   BEGIN { @ENV{qw<LC_ALL LC_TYPE LANG>} = (); }
use Test::More eval{require Data::Dumper} ? 'no_plan' : (skip_all => 'This test requires Data::Dumper');
use Data::Show with => 'Data::Dumper', grid => 'on';
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/grid_ascii.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'                                                                      |
|____________________________________________________________________________|