Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Unfudge passing test
  • Loading branch information
lizmat committed Aug 11, 2013
1 parent 2aae384 commit 50a3a42
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions S02-names/caller.t
Expand Up @@ -12,7 +12,7 @@ plan 15;
my $a is dynamic = 3;
is $sub(), 3, 'basic $CALLER:: works';
}
}
} #1

{
my $a is dynamic = 9;
Expand All @@ -26,7 +26,7 @@ plan 15;
my $a is dynamic = 11;
is $sub1(), 10, '$CALLER:: with nested subs works';
}
}
} #1

{
my $get_caller = sub { return sub { $CALLER::CALLER::a } };
Expand All @@ -46,7 +46,7 @@ plan 15;
# calculation.
ok !(try { $result_of_sub1() }), '$CALLER::CALLER:: is recalculated on each access (1)';
ok !(try { $result_of_sub2() }), '$CALLER::CALLER:: is recalculated on each access (2)';
}
} #2

# L<S02/Names/The CALLER package refers to the lexical scope>
{
Expand All @@ -59,7 +59,7 @@ plan 15;

$_ = 23;
is bar(), 42, '$_ is implicitly declared "is dynamic" (1)';
}
} #1

{
# $_ is always implicitly declared "is dynamic".
Expand All @@ -72,7 +72,7 @@ plan 15;

$_ = 23;
is bar(), 42, '$_ is implicitly declared "is dynamic" (2)';
}
} #1

#?pugs skip 'Cannot cast from VStr "success" to VCode (VCode)'
{
Expand All @@ -86,54 +86,53 @@ plan 15;

my $abs = 23;
#?niecza todo 'strictness'
#?rakudo todo 'strictness'
nok (try bar()) eq 'success',
'vars not declared "is dynamic" are not accessible via $CALLER::';
}
} #1

# Vars declared with "is dynamic" default to being rw in the creating scope and
# readonly when accessed with $CALLER::.
{
my $foo is dynamic = 42;
$foo++;
is $foo, 43, '"is dynamic" vars are rw in the creating scope (1)';
}
} #1

{
my $foo is dynamic = 42;
{ $foo++ }
is $foo, 43, '"is dynamic" vars are rw in the creating scope (2)';
}
} #1

#?pugs skip "Can't modify constant item: VInt 42"
{
my sub modify { $CALLER::foo++; 'success' }
my $foo is dynamic ::= 42;
nok (try modify()) eq 'success', '"::=" vars are ro when accessed with $CALLER::';
}
} #1

{
my sub modify { $CALLER::_++ }
$_ = 42;
modify();
is $_, 43, '$_ is implicitly rw (2)';
}
} #1

{
my sub modify { $CALLER::foo++ }
my $foo is dynamic = 42;
modify();
is $foo, 43,
'"is dynamic" vars declared "is rw" are rw when accessed with $CALLER:: (2)';
}
} #1

{
my sub get_foo { try { $DYNAMIC::foo } }
my $foo is dynamic = 42;

#?pugs todo
is get_foo(), 42, '$DYNAMIC:: searches call stack';
}
} #1

# Rebinding caller's variables -- legal?
{
Expand All @@ -145,7 +144,7 @@ plan 15;
is $foo, 23, 'rebinding $CALLER:: variables works (2)';
$other_var++;
is $foo, 24, 'rebinding $CALLER:: variables works (3)';
}
} #2

=begin pod
Expand Down

0 comments on commit 50a3a42

Please sign in to comment.