File: 03perl58.t

package info (click to toggle)
liblexical-underscore-perl 0.004-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 156 kB
  • sloc: perl: 19; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (7)
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
# There is no lexical underscore on Perl 5.8 but the module
# should fall back to the global underscore.
#

use Test::More;
BEGIN {
	plan tests => 6;
};

use lexical::underscore;

sub foo {
	$_ = 101;
	bar();
	is($_, 42);
}

sub bar {
	$_ = 102;
	baz();
}

sub baz {
	$_ = 103;
	quux();
}

sub quux {
	$_ = 104;
	
	is(${ lexical::underscore() }, 104);
	is(${ lexical::underscore(-1) }, 104);
	is(${ lexical::underscore(0) }, 104);
	is(${ lexical::underscore(1) }, 104);
	is(${ lexical::underscore(2) }, 104);
	
	${ lexical::underscore(2) } = 42;
}

foo();