Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 135 lines (109 sloc) 2.151 kb
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
1 use Test;
d28cbc3 [t] merge smartmatch_autovivifies.t into autovivification.t
moritz authored
2 plan 22;
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
3
49d08c1 [t] smartlink unbreakage
lwall authored
4 # L<S03/Assignment operators/>
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
5
6 {
7 my $x;
8 $x++;
9 ok $x == 1, 'my $x; $x++ works'
10 }
11
12 {
13 my Int $x;
14 $x++;
15 ok $x == 1, 'my Int $x; $x++ works'
16 }
17
18 {
19 my $x;
20 $x += 1;
21 ok $x == 1, 'my $x; $x += 1 works'
22 }
23
24 {
25 my Int $x;
26 $x += 1;
27 ok $x == 1, 'my Int $x; $x += 1 works'
28 }
29
30 {
31 my $x;
32 $x -= 1;
33 ok $x == -1, 'my $x; $x -= 1 works'
34 }
35
36 {
37 my Int $x;
38 $x -= 1;
39 ok $x == -1, 'my Int $x; $x -= 1 works'
40 }
41
42 {
43 my $s;
44 $s ~= 'ab';
45 is $s, 'ab', 'my $s; $s ~= "ab" works'
46 }
47
48 {
49 my Str $s;
50 $s ~= 'ab';
51 is $s, 'ab', 'my Str $s; $s ~= "ab" works'
52 }
53
54 {
55 my $x;
56 $x *= 2;
6852496 [t/spec] correct and fudge autovivification.t
moritz authored
57 ok $x == 2, 'my $x; $x *= 2 works'
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
58 }
59
60 {
61 my $x;
62 $x **= 2;
6852496 [t/spec] correct and fudge autovivification.t
moritz authored
63 ok $x == 1, 'my $x; $x **= 2 works'
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
64 }
65
66 {
67 my Int $x;
68 $x *= 2;
30469fa [spec]: More unfudging and test correction in autovivification.t
pmichaud authored
69 ok $x == 2, 'my Int $x; $x *= 2 works'
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
70 }
71
72 {
73 my Int $x;
74 $x **= 2;
30469fa [spec]: More unfudging and test correction in autovivification.t
pmichaud authored
75 ok $x == 1, 'my Int $x; $x **= 2 works'
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
76 }
77
f7064c6 [t/spec] test for RT #59982 (my $x; $x = $x + 1i fails in rakudo)
moritz authored
78 {
79 my $x;
80 $x = $x + 1i;
81 ok $x == 0 + 1i, 'my $x; $x = $x + 1i; works';
82 }
83
84 {
85 my $x;
86 $x += 1i;
87 ok $x == 0 + 1i, 'my $x; $x += 1i; works';
88 }
89
90 {
91 my $x;
92 $x *= 1i;
93 ok $x == 1i, 'my $x; $x *= 1i works';
94 }
95
49d08c1 [t] smartlink unbreakage
lwall authored
96 # L<S03/Assignment operators/"If you apply an assignment operator to a protoobject">
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
97 {
98 # yes, this is serious. It's in the specs ;-)
99 my Num $x;
100 $x *= 5;
101 is $x, 5, '*= autovivifies with correct neutral element (with Num proto)';
102 }
103
104 {
105 my $x;
106 $x *= 5;
107 is $x, 5, '*= autovivifies with correct neutral element (without type constraint)';
108 }
109
30469fa [spec]: More unfudging and test correction in autovivification.t
pmichaud authored
110 #?rakudo skip 'type constraint on hashes'
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
111 {
112 my Int %h;
6852496 [t/spec] correct and fudge autovivification.t
moritz authored
113 is (%h<foo> *= 23), 23, '*= autovivifies with correct neutral element (with Int proto on hash items)';
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
114 }
115
116 {
117 my %h;
6852496 [t/spec] correct and fudge autovivification.t
moritz authored
118 is (%h<foo> *= 23), 23, '*= autovivifies with correct neutral element (without proto on hash items)';
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
119 }
d28cbc3 [t] merge smartmatch_autovivifies.t into autovivification.t
moritz authored
120
121 {
122 is +@empty, 0, 'Sanity: empty array, @empty, has 0 elements';
123
124 my $before = @empty.perl;
125 @empty[5] ~~ /nothing/;
126 my $after = @empty.perl;
127
128 #?pugs 2 todo 'bugs'
129 is +@empty,0,'empty array, @empty, has 0 elements';
130
131 is $after,$before,"Array elements are not auto-vivified by smartmatch";
132 }
133
4fa9470 [t/spec] tests for autovivification with assignment meta operators
moritz authored
134 # vim: ft=perl6
Something went wrong with that request. Please try again.