/
assign-is-not-binding.t
49 lines (38 loc) 路 1.11 KB
/
assign-is-not-binding.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
use v6;
use Test;
plan 8;
# +---- UTF8 non-breaking space here!
# |
# V
# L<S03/Changes to Perl聽5 operators/list assignment operator now parses on the right>
# very simple assignment
{
my $foo = 'FOO';
is $foo, 'FOO', 'Can assign string to scalar 1';
my $bar = 'BAR';
is $foo, 'FOO', 'Can assign string to scalar 2';
$foo = $bar;
is $foo, 'BAR', 'Can assign scalar to scalar';
$foo = 'FOO';
is $bar, 'BAR', "Assignment didn't create a binding";
}
# test that assignment from arrays to scalars doesn't create a binding:
{
my @array = 23, 42;
is @array[0], 23, 'Could assign first element';
is @array[1], 42, 'Could assign second element';
my $temp = @array[0];
is $temp, 23, 'Could retrieve first element to a scalar';
#rakudo skip 'Broken in ng1'
# {
# @array[0] = @array[1];
# is $temp, 23, "Assignment to scalar didn't create a binding"
# }
}
{
my $a = 42;
my @list = ($a);
$a = 24;
is @list[0], 42, "Assignment to scalar didn't create a binding";
}
# vim: ft=perl6