File: refelem.t

package info (click to toggle)
libarray-refelem-perl 1.00%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 76 kB
  • ctags: 2
  • sloc: perl: 10; makefile: 3
file content (41 lines) | stat: -rw-r--r-- 652 bytes parent folder | download | duplicates (3)
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
print "1..5\n";

use strict;
use Array::RefElem qw(av_store av_push hv_store);

my $a = "a";
my @a = (1, 2, 3, 4);

av_store(@a, 1, $a);
av_push(@a, $a);

print "not " unless "@a" eq "1 a 3 4 a";
print "ok 1\n";

$a = 2;
print "not " unless "@a" eq "1 2 3 4 2";
print "ok 2\n";

$a[1] = "z";
print "not " unless $a[4] eq "z";
print "ok 3\n";

my %h;
hv_store(%h, "foo", $a);

$h{foo} = "bar";
print "not " unless $a eq "bar";
print "ok 4\n";

$a[2] = [3];
av_store(@a, 2, $a[2][0]);
print "not " unless $a[2] == 3;
print "ok 5\n";

if (shift) {
   require Devel::Peek;
   Devel::Peek::Dump($a);
   Devel::Peek::Dump(\@a);
   Devel::Peek::Dump(\%h);
}