forked from ingydotnet/lexicals-pm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ce0dc6
commit 10fd38e
Showing
4 changed files
with
99 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use Test::More tests => 7; | ||
use lexicals; | ||
|
||
sub foo { | ||
my %h = ( a => 1, b => 2); | ||
my @a = ( 'x', 'y', 3); | ||
my $s = 42; | ||
my $r = \$s; | ||
my $r2 = \\$s; | ||
my $l = lexicals; | ||
my $x = 7; | ||
my @x = (3, 4); | ||
my %x = (1, 3, 2, 1); | ||
|
||
my $l = lexicals; | ||
is $l->{x}, 7, 'Scalar wins on match'; | ||
is ref($l->{h}), 'HASH', 'lexical hashes are ok'; | ||
is ref($l->{a}), 'ARRAY', 'lexical arrays are ok'; | ||
is ref($l->{r}), 'SCALAR', 'lexical refs are ok'; | ||
is ref($l->{r2}), 'REF', 'lexical refs are ok'; | ||
is ref($l->{s}), '', 'lexical scalars are ok'; | ||
is ${$l->{r2}}, $l->{r}, 'references are correct'; | ||
} | ||
|
||
foo(); |