Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 209 lines (162 sloc) 5.809 kB
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
1 use v6;
2
3 use Test;
4
688ed89 [t/spec] fudged mixed_multi_dimensional.t for rakudo
moritz authored
5 plan 80;
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
6
b22048c [tests] Adding UNSPECCED and smartlinks
eric256 authored
7
4b58c6e [spec] fixed POD
moritz authored
8 =begin description
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
9
10 This tests some mixed multi-dimensional structures.
11
12 NOTE:
13 These tests don't go any more than two levels deep
fcf62f1 @coke Remove any Pugs fudges
coke authored
14 (AoH, AoP) in most cases.
15
16 When we have this support, then
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
17 this test should be added too more.
18
19 Some deeper tests were already added.
20
4b58c6e [spec] fixed POD
moritz authored
21 =end description
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
22
b22048c [tests] Adding UNSPECCED and smartlinks
eric256 authored
23 # UNSPECCED
f3f35ac @coke niecza fudging
coke authored
24 #?niecza skip 'Cannot use hash access on an object of type Pair'
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
25 { # Array of Pairs
26 my @array;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
27 isa-ok(@array, Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
28
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
29 my $pair = ('key' => 'value');
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
30 isa-ok($pair, Pair);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
31
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
32 @array[0] = $pair; # assign a variable
33 is(+@array, 1, 'the array has one value in it');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
34
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
35 isa-ok(@array[0], Pair);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
36 is(@array[0]<key>, 'value', 'got the right pair value');
37
38 @array[1] = ('key1' => 'value1'); # assign it inline
39 is(+@array, 2, 'the array has two values in it');
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
40 isa-ok(@array[1], Pair);
dd1ebc7 [t/spec] Paritally fudged mixed_multi_dimensional.t for rakudo
azawawi authored
41
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
42 is(@array[1]<key1>, 'value1', 'got the right pair value');
43 }
44
b22048c [tests] Adding UNSPECCED and smartlinks
eric256 authored
45 # UNSPECCED
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
46 { # Array of Hashes
47 my @array;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
48 isa-ok(@array, Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
49
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
50 my %hash = ('key', 'value', 'key1', 'value1');
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
51 isa-ok(%hash, Hash);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
52 is(+%hash.keys, 2, 'our hash has two keys');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
53
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
54 @array[0] = %hash;
55 is(+@array, 1, 'the array has one value in it');
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
56 isa-ok(@array[0], Hash);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
57 is(@array[0]{"key"}, 'value', 'got the right value for key');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
58 is(@array[0]<key1>, 'value1', 'got the right value1 for key1');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
59 }
60
61 { # Array of Arrays
b22048c [tests] Adding UNSPECCED and smartlinks
eric256 authored
62 # L<S09/Multidimensional arrays>
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
63 my @array = (1, [2, 3], [4, 5], 6);
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
64 isa-ok(@array, Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
65
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
66 is(+@array, 4, 'got 4 elements in the Array of Arrays');
67 is(@array[0], 1, 'got the right first element');
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
68 isa-ok(@array[1], Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
69 is(@array[1][0], 2, 'got the right second/first element');
70 is(@array[1][1], 3, 'got the right second/second element');
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
71 isa-ok(@array[2], Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
72 is(@array[2][0], 4, 'got the right third/first element');
73 is(@array[2][1], 5, 'got the right third/second element');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
74 is(@array[3], 6, 'got the right fourth element');
75 }
76
b22048c [tests] Adding UNSPECCED and smartlinks
eric256 authored
77 # UNSPECCED
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
78 { # Array of Subs
79 my @array;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
80 isa-ok(@array, Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
81
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
82 @array[0] = sub { 1 };
83 @array[1] = { 2 };
84 @array[2] = -> { 3 };
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
85
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
86 is(+@array, 3, 'got three elements in the Array');
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
87 isa-ok(@array[0], Sub);
88 isa-ok(@array[1], Block);
89 isa-ok(@array[2], Block);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
90
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
91 is(@array[0](), 1, 'the first element (when executed) is 1');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
92 is(@array[1](), 2, 'the second element (when executed) is 2');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
93 is(@array[2](), 3, 'the third element (when executed) is 3');
94 }
95
b22048c [tests] Adding UNSPECCED and smartlinks
eric256 authored
96 # UNSPECCED
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
97 { # Hash of Arrays
98 my %hash;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
99 isa-ok(%hash, Hash);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
100
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
101 %hash<key> = [ 1, 2, 3 ];
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
102 isa-ok(%hash<key>, Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
103
104 is(+%hash<key>, 3, 'it should have 3 values in it');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
105 is(%hash<key>[0], 1, 'got the right value');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
106 is(%hash<key>[1], 2, 'got the right value');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
107 is(%hash<key>[2], 3, 'got the right value');
108
109 {
110 my $array = %hash<key>;
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
111 is(+$array, 3, 'it should have 3 values in it');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
112 is($array[0], 1, 'got the right value (when I pull the array out)');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
113 is($array[1], 2, 'got the right value (when I pull the array out)');
114 is($array[2], 3, 'got the right value (when I pull the array out)');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
115 }
93fbee8 [t/spec] Fudged mixed_multi_dimensional.t for rakudo
azawawi authored
116
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
117 {
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
118 %hash<key>.push(4);
119 is(+%hash<key>, 4, 'it should now have 4 values in it');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
120 is(%hash<key>[3], 4, 'got the right value (which we just pushed onto the list)');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
121 }
122
93fbee8 [t/spec] Fudged mixed_multi_dimensional.t for rakudo
azawawi authored
123 }
124
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
125
126 { # Hash of Array-refs
b22048c [tests] Adding UNSPECCED and smartlinks
eric256 authored
127 # UNSPECCED
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
128 my %hash;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
129 isa-ok(%hash, Hash);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
130
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
131 my @array = ( 1, 2, 3 );
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
132 isa-ok(@array, Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
133
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
134 %hash<key> = @array;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
135 isa-ok(%hash<key>, Array);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
136
137 is(+%hash<key>, 3, 'it should have 3 values in it');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
138 is(%hash<key>[0], 1, 'got the right value');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
139 is(%hash<key>[1], 2, 'got the right value');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
140 is(%hash<key>[2], 3, 'got the right value');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
141
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
142 {
143 my @array = @( %hash<key> );
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
144 is(+@array, 3, 'it should have 3 values in it');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
145 is(@array[0], 1, 'got the right value (when I pull the array out)');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
146 is(@array[1], 2, 'got the right value (when I pull the array out)');
147 is(@array[2], 3, 'got the right value (when I pull the array out)');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
148 }
93fbee8 [t/spec] Fudged mixed_multi_dimensional.t for rakudo
azawawi authored
149
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
150 {
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
151 %hash<key>.push(4);
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
152
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
153 is(+%hash<key>, 4, 'it should now have 4 values in it');
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
154 is(%hash<key>[3], 4, 'got the right value (which we just pushed onto the array)');
93fbee8 [t/spec] Fudged mixed_multi_dimensional.t for rakudo
azawawi authored
155 }
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
156
157 }
158
21b7ed5 @lizmat Use itemizing instead of capturing
lizmat authored
159 { # Itemized hash survives addition to an array.
51bba91 [t/spec] fudge mixed_multi_dimensional.t for rakudo
moritz authored
160 my %h = <a 5 b 6>;
21b7ed5 @lizmat Use itemizing instead of capturing
lizmat authored
161 my $hr = %h;
162 my $a0 = [ $%h ,'extra' ];
163 my $a1 = [ $%h ];
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
164 my $a2 = [ $hr ];
21b7ed5 @lizmat Use itemizing instead of capturing
lizmat authored
165 is($a0.elems,2,'itemized hash should not get decomposed');
166 is($a1.elems,1,'itemized hash should not get decomposed');
167 is($a2.elems,1,'itemized hash should not get decomposed');
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
168 }
169
170 { # nested, declared in one statement
171 my $h = { a => [ 1,2,3 ] };
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
172 isa-ok($h<a>.WHAT, Array, "array nested in hashref in one declaration");
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
173 }
174
175 { # structures deeper than 2 levels
176 my @array;
177 @array[0][0][0][0][0] = 5;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
178 isa-ok(@array, Array);
179 isa-ok(@array[0], Array);
180 isa-ok(@array[0][0], Array);
181 isa-ok(@array[0][0][0], Array);
182 isa-ok(@array[0][0][0][0], Array);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
183 is(@array[0][0][0][0][0], 5, "5 level deep arrays only structure");
184
185 @array[1]<two>[0]<four>[0]<six> = 6;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
186 isa-ok(@array, Array);
187 isa-ok(@array[1], Hash);
188 isa-ok(@array[1]<two>, Array);
189 isa-ok(@array[1]<two>[0], Hash);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
190 is(+@array[1]<two>[0], 1, "one key at level 4");
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
191 isa-ok(@array[1]<two>[0]<four>, Array);
192 isa-ok(@array[1]<two>[0]<four>[0], Hash);
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
193 is(@array[1]<two>[0]<four>[0]<six>, 6, "6 level deep mixed structure");
194
195
196 @array[2]<two>[0]<f><other> = 5;
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
197 isa-ok(@array[1]<two>[0], Hash);
51bba91 [t/spec] fudge mixed_multi_dimensional.t for rakudo
moritz authored
198 #?rakudo todo 'isa hash'
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
199 #?niecza todo
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
200 isa-ok(@array[1]<two>[0]<f>, Hash);
51bba91 [t/spec] fudge mixed_multi_dimensional.t for rakudo
moritz authored
201 #?rakudo 2 todo 'unknown'
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
202 #?niecza todo
688ed89 [t/spec] fudged mixed_multi_dimensional.t for rakudo
moritz authored
203 is(+@array[1]<two>[0], 2, "two keys at level 4");
2e53c69 @coke update todo notes.
coke authored
204 #?niecza todo 'more keys at level 4'
688ed89 [t/spec] fudged mixed_multi_dimensional.t for rakudo
moritz authored
205 is(@array[1]<two>[0]<f><other>, 5, "more keys at level 4");
db93e89 [t/spec] unmark some passing rakudo tests due to container/value refa…
particle authored
206 }
0ca4c11 [gsoc_spectest] t/data_types/* -> t/spec/S02-builtin_data_types/
Auzon authored
207
688ed89 [t/spec] fudged mixed_multi_dimensional.t for rakudo
moritz authored
208 # vim: ft=perl6
Something went wrong with that request. Please try again.