File: 03_gen.t

package info (click to toggle)
libdata-util-perl 0.67-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 556 kB
  • sloc: perl: 2,958; ansic: 416; makefile: 8
file content (25 lines) | stat: -rw-r--r-- 503 bytes parent folder | download | duplicates (5)
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
#!perl -w

use strict;
use Test::More tests =>7;

use Data::Util qw(anon_scalar);

my $sref = \do{ my $anon };

is_deeply anon_scalar(), $sref, 'anon_scalar';
is_deeply anon_scalar(undef), $sref, 'anon_scalar';

is_deeply anon_scalar(10), \10;
is_deeply anon_scalar('foo'), \'foo';

ok !Internals::SvREADONLY(${ anon_scalar(10) }), 'not readonly';

my $foo;

# equivalent to "$foo = \do{ my $tmp = $foo }"
$foo = anon_scalar $foo;

is_deeply $foo, $sref;

ok eval{ ${anon_scalar()} = 10; }, 'writable';