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{LANG} = 'utf-8'; }
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_unicode.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' ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|