Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 32 lines (23 sloc) 0.976 kb
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
use v6;
use Test;

# L<S03/"Declarators">
# This section describes declarators like my, our, etc
# Note that the usage of declarators on the RHS is not spec'ed yet,
# but works like Perl 5. Also note that the list if declarators here
# does not match the list described in the referenced specs.

plan 5;

# sanity: declarations and very simple use (scoping tests come later)
# we take care to use different names to avoid other *kinds* of insanity.

is((try { my $a1 = my $b1 = 42; $b1++; "$a1, $b1" }), '42, 43', "chained my");
is((try { my $a2 = our $b2 = 42; $b2++; "$a2, $b2" }), '42, 43', "chained my, our");
is((try { my $a4 = constant $b4 = 42; "$a4, $b4" }), '42, 42', "chained my, constant");
is((try { my $a5 = state $b5 = 42; $b5++; "$a5, $b5" }), '42, 43', "chained my, state");

# scoping

eval_dies_ok '
{
our $sa2 = my $sb2 = 42;
}
($sa2, $sb2);
', "scoping our, my ('our' doesn't leak)";

# XXX: add more!

# vim: ft=perl6
Something went wrong with that request. Please try again.