-
Notifications
You must be signed in to change notification settings - Fork 135
/
ro.t
51 lines (43 loc) · 1.2 KB
/
ro.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
51
use v6;
use Test;
plan 11;
# L<S03/Item assignment precedence/bind and make readonly>
{
my $x = 5;
my $y = 3;
$x ::= $y;
is $x, 3, '::= on scalars took the value from the RHS';
#?rakudo todo 'nom regression'
dies_ok { $x = 5 }; '... and made the LHS RO';
#?rakudo todo 'nom regression'
is $x, 3, 'variable is still 3';
}
{
my Int $a = 4;
my Str $b;
dies_ok { $b ::= $a },
'Cannot ro-bind variables with incompatible type constraints';
}
{
my @x = <a b c>;
my @y = <d e>;
@x ::= @y;
is @x.join('|'), 'd|e', '::= on arrays';
#?rakudo 4 todo '::= on arrays'
#?niecza todo
dies_ok { @x := <3 4 foo> }, '... make RO';
#?niecza todo
is @x.join('|'), 'd|e', 'value unchanged';
#?niecza todo
lives_ok { @x[2] = 'k' }, 'can still assign to items of RO array';
#?niecza todo
is @x.join(''), 'd|e|k', 'assignment relly worked';
}
# RT #65900
{
throws_like q[my $a is readonly = 5;], X::Comp::Trait::Unknown,
'variable trait "is readonly" is no longer valid (1)';
throws_like q[(my $a is readonly) = 5;], X::Comp::Trait::Unknown,
'variable trait "is readonly" is no longer valid (2)';
}
# vim: ft=perl6