Skip to content

HTTPS clone URL

Subversion checkout URL

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