Skip to content

HTTPS clone URL

Subversion checkout URL

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