File: scalar_ident.t

package info (click to toggle)
liblexical-var-perl 0.010-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 464 kB
  • sloc: perl: 76; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 1,014 bytes parent folder | download | duplicates (4)
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
use warnings;
use strict;

use Test::More tests => 5*6;

BEGIN { $^H |= 0x20000 if "$]" < 5.008; }

$SIG{__WARN__} = sub { die "WARNING: $_[0]" };

# The \5 test fails unfairly under MAD+threads due to [perl #109746].
my $bug109746 = do { my $a = \123; my $b = \$$a; $a != $b };

our $x = undef;
our $y = 1;
our($oref, $aref, $bref, $cref, $dref);
foreach(
	\$x,
	\$y,
	do { my $x = 6; \$x },
	sub { my $x = 7; \$x }->(),
	$bug109746 ? "skip" : \5,
	\undef,
) { SKIP: {
	skip "[perl #109746]", 5 if ref($_) eq "" && $_ eq "skip";
	$oref = $_;
	$aref = $bref = $cref = $dref = undef;
	eval q{
		use Lexical::Var '$foo' => $oref;
		$aref = \$foo;
		$bref = \$foo;
		# A srefgen op applied to a const op will undergo
		# constant folding.  This screws up some test cases.
		# So we also test with list-type refgen, which won't
		# be constant-folded.
		($cref, undef) = \($foo, 1);
		($dref, undef) = \($foo, 2);
	};
	is $@, "";
	ok $aref == $oref;
	ok $bref == $oref;
	ok $cref == $oref;
	ok $dref == $oref;
} }

1;