Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 189 lines (150 sloc) 4.71 kb
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
1 use v6;
2
db4bde7 [t/spec] add 'use MONKEY_TYPING' where appropriate
lwall authored
3 use MONKEY_TYPING;
4
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
5 use Test;
6
0477942 some more smartlinks updated
szabgab authored
7 # L<S02/Lists>
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
8 # XXX -- Lists are not real datatypes, but I haven't found a better location
9 # for this test. See
10 # L<"http://www.nntp.perl.org/group/perl.perl6.language/22924">
11
1b0fdc4 @pmichaud regression test for nom's duplicate-reification bug ("bacon bacon").
pmichaud authored
12 plan 29;
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
13
14 # Indexing lists
88b5007 @coke Convert regression to RT
coke authored
15
16 # RT #105368
17 #?rakudo todo "Can't assign to a variable in a list"
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
18 {
19 my $foo = 42;
20
21 try { ($foo, "does_not_matter")[0] = 23 };
f25f151 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
22 #?pugs todo 'bug'
23 is $foo, 23, "assigning a list element changed the original variable";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
24 }
25
26 {
27 my $foo = 42;
28
29 is ($foo, "does_not_matter")[*-2], 42,
30 "indexing lists by a negative index works correctly";
31 }
32
33 # List construction does not create new containers
7805860 @coke nom fudge
coke authored
34 #?rakudo todo 'nom regression'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
35 {
36 my $foo = 42;
37
f25f151 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
38 #?pugs todo 'unspecced'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
39 ok ($foo, "does_not_matter")[0] =:= $foo,
f25f151 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
40 "list construction should not create new containers";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
41 }
42
7805860 @coke nom fudge
coke authored
43 #?rakudo todo 'nom regression'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
44 {
45 my $foo = 42;
f25f151 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
46 #?pugs todo 'unspecced'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
47 ok ($foo, "does_not_matter", 17)[0,1][0] =:= $foo,
f25f151 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
48 "list construction and list slicing should not create new containers";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
49 }
50
51 # Lists as lvalues
52 {
53 my $foo = 42;
54 my $bar = 43;
55
56 ($foo, $bar) = (23, 24);
57 ok $foo == 23 && $bar eq 24,
58 "using lists as lvalues works";
59 }
60
61 {
62 my $foo = 42;
63
946cccf @coke niecza fudging
coke authored
64 #?niecza todo
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
65 lives_ok { ($foo, *) = (23, 24) },
66 "using lists with embedded Whatevers as lvalues works (1)";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
67 ok $foo == 23,
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
68 "using lists with embedded Whatevers as lvalues works (2)";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
69 }
70
71 # List slices as lvalues
72 {
73 my $foo = 42;
74 my $bar = 43;
75
76 try { ($foo, 42, $bar, 19)[0, 2] = (23, 24) };
77 ok $foo == 23 && $bar == 24,
8b919b0 [t/spec] update some skip reasons in lists.t (and finer graded fudging)
moritz authored
78 "using list slices as lvalues works (1)";
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
79
80 dies_ok { ($foo, 42, $bar, 19)[1, 3] = (23, 24) },
81 "using list slices as lvalues works (2)";
82 }
83
84 # Lists as lvalues used to swap variables
85 {
86 my $foo = 42;
87 my $bar = 23;
88
89 ($foo, $bar) = ($bar, $foo);
90 ok $foo == 23 && $bar == 42,
91 "using lists as lvalues to swap two variables works";
92 }
93
94 {
95 my $foo = 1;
96 my $bar = 2;
97 my $baz = 3;
98
99 ($foo, $bar, $baz) = ($baz, $foo, $bar);
100 ok $foo == 3 && $bar == 1 && $baz == 2,
101 "using lists as lvalues to swap three variables works";
102 }
103
104 # Lists as lvalues to swap, this time we use binding instead of assignment
8b919b0 [t/spec] update some skip reasons in lists.t (and finer graded fudging)
moritz authored
105 #?rakudo skip 'list binding'
ff382f2 @coke niecza fudge
coke authored
106 #?niecza skip 'Cannot use bind operator with this LHS'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
107 {
108 my $foo = 42;
109 my $bar = 23;
110
111 ($foo, $bar) := ($bar, $foo);
112 ok $foo == 23 && $bar == 42,
113 "using lists as lvalues in a binding operation to swap two variables works";
114
115 $foo = "some_new_value";
116 is $foo, "some_new_value",
117 "the vars didn't lose the readwrite-ness";
118 }
119
8b919b0 [t/spec] update some skip reasons in lists.t (and finer graded fudging)
moritz authored
120 #?rakudo skip 'list binding'
ff382f2 @coke niecza fudge
coke authored
121 #?niecza skip 'Cannot use bind operator with this LHS'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
122 {
123 my $foo = 1;
124 my $bar = 2;
125 my $baz = 3;
126
127 ($foo, $bar, $baz) := ($baz, $foo, $bar);
128 ok $foo == 3 && $bar == 1 && $baz == 2,
129 "using lists as lvalues in a binding operation to swap three variables works";
130 }
131
a5d2261 @coke rakudo (auto)unfudge
coke authored
132 #?rakudo todo 'auto-dereferencing of captures (?)'
ff382f2 @coke niecza fudge
coke authored
133 #?niecza skip 'Cannot use value like Capture as a number'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
134 {
135 my @array = (1,2,3);
136 my $arrayref = \@array;
137
138 is +$arrayref, 3, '\@array creates an arrayref (1)';
139 is +$arrayref[1], 2, '\@array creates an arrayref (2)';
140 }
d970028 [t/spec] Test for RT #62836
kyle authored
141
ff382f2 @coke niecza fudge
coke authored
142 #?niecza skip 'Unable to resolve method rt62836 in class Parcel'
d970028 [t/spec] Test for RT #62836
kyle authored
143 {
144 sub List::rt62836 { 62836 }
145
146 dies_ok { <1 2 3>.rt62836 },
147 'call to user-declared sub in List:: class dies';
001e798 @moritz &eval does not catch exceptions.
moritz authored
148 try { eval '<1 2 3>.rt62836' };
d970028 [t/spec] Test for RT #62836
kyle authored
149 ok "$!" ~~ /rt62836/, 'error message contains name of sub';
150 ok "$!" ~~ /not \s+ found/, 'error message says "not found"';
2622d1d [t/spec] fudge lists.t for rakudo; some corrections
moritz authored
151 diag $!;
152 ok "$!" ~~ /Seq|Parcel/, 'error message contains name of class';
d970028 [t/spec] Test for RT #62836
kyle authored
153
d9fc912 [t/spec] Change "is also" to "augment" (and skip)
kyle authored
154 augment class List { method rt62836_x { 62836 } };
6aea80b [t/spec] Adjust some skip fudges
kyle authored
155 #?rakudo skip 'unskip when "augment" works'
d970028 [t/spec] Test for RT #62836
kyle authored
156 is <1 2 3>.rt62836_x, 62836, 'call user-declared method in List:: class';
157 }
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
158
9fbb95a [t/spec] Test for RT #66304: list promoted to array when assigned to …
kyle authored
159 # RT #66304
ff382f2 @coke niecza fudge
coke authored
160 #?niecza skip 'Undeclared name: "Seq"'
9fbb95a [t/spec] Test for RT #66304: list promoted to array when assigned to …
kyle authored
161 {
162 my $rt66304 = (1, 2, 4);
7805860 @coke nom fudge
coke authored
163 #?rakudo todo 'nom regression'
2622d1d [t/spec] fudge lists.t for rakudo; some corrections
moritz authored
164 isa_ok $rt66304, Seq, 'List assigned to scalar is-a Seq';
9fbb95a [t/spec] Test for RT #66304: list promoted to array when assigned to …
kyle authored
165 is( $rt66304.WHAT, (1, 2, 4).WHAT,
166 'List.WHAT is the same as .WHAT of list assigned to scalar' );
167 dies_ok { $rt66304[1] = 'ro' }, 'literal List element is immutable';
168 is $rt66304, (1, 2, 4), 'List is not changed by attempted assignment';
2622d1d [t/spec] fudge lists.t for rakudo; some corrections
moritz authored
169
9fbb95a [t/spec] Test for RT #66304: list promoted to array when assigned to …
kyle authored
170 my $x = 44;
171 $rt66304 = ( 11, $x, 22 );
05fd86e [t/spec] Fixes to RT 66304 test after conversation with moritz++
kyle authored
172 dies_ok { $rt66304[1] = 'rw' }, 'variable List element is immutable';
173 is $x, 44, 'variable not changed via assignment to list element';
9fbb95a [t/spec] Test for RT #66304: list promoted to array when assigned to …
kyle authored
174 }
175
1b0fdc4 @pmichaud regression test for nom's duplicate-reification bug ("bacon bacon").
pmichaud authored
176 # nom regression bug
ff382f2 @coke niecza fudge
coke authored
177 #?niecza skip 'Excess arguments to CORE List.new'
1b0fdc4 @pmichaud regression test for nom's duplicate-reification bug ("bacon bacon").
pmichaud authored
178 {
179 my $x = List.new('bacon');
180 my $y = $x.Str;
181 my $z = $x.Str;
27617a5 @jnthn Fix a couple of syntax fails in a recently added test.
jnthn authored
182 is $y, 'bacon', "3rd-party reification of List doesn't duplicate rest";
183 is $z, 'bacon', "3rd-party reification of List doesn't duplicate rest";
1b0fdc4 @pmichaud regression test for nom's duplicate-reification bug ("bacon bacon").
pmichaud authored
184 }
185
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
186 done;
9fbb95a [t/spec] Test for RT #66304: list promoted to array when assigned to …
kyle authored
187
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
188 # vim: ft=perl6
Something went wrong with that request. Please try again.