-
Notifications
You must be signed in to change notification settings - Fork 135
/
closure.t
50 lines (39 loc) · 981 Bytes
/
closure.t
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
46
47
48
49
50
use v6;
use Test;
plan 8;
diag "Testing for calling block bindings...";
is eval(q[
my &foo := { "foo" };
foo;
]), 'foo', "Calling block binding without argument. (Runtime)";
{
is eval(q[
my &foo ::= { "foo" };
foo;
]), 'foo', "Calling block binding without argument. (read-only bind)";
}
is eval(q[
my &foo := { $^a };
foo(1);
]), 1, "Calling block binding with argument. (Runtime, with parens)";
is eval(q[
my &foo := { $^a };
foo 1;
]), 1, "Calling block binding with argument. (Runtime, no parens)";
{
is eval(q[
my &foo ::= { $^a };
foo(1);
]), 1, "Calling block binding with argument. (read-only bind, with parens)";
is eval(q[
my &foo ::= { $^a };
foo 1;
]), 1, "Calling block binding with argument. (read-only bind, no parens)";
}
my &foo_r := { $^a + 5 };
is foo_r(1), 6, "Testing the value for placeholder(Runtime binding)";
{
my &foo_c ::= { $^a + 5 };
is foo_c(1), 6, "Testing the value for placeholder(read-only binding)";
}
# vim: ft=perl6