/
precompilation.t
207 lines (174 loc) · 5.57 KB
/
precompilation.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
use v6;
use lib 't/spec/packages';
use Test;
use Test::Util;
plan 40;
my @*MODULES; # needed for calling CompUnit::Repository::need directly
my $precomp-ext := $*VM.precomp-ext;
my $precomp-target := $*VM.precomp-target;
my @precomp-paths;
my @precompiled = Test::Util::run( q:to"--END--").lines;
use lib 't/spec/packages';
for <C A B> {
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name("Example::$_")));
say $comp-unit.precompiled;
}
--END--
is @precompiled.elems, 3;
is $_, 'True' for @precompiled;
# RT #122773
my @keys = Test::Util::run( q:to"--END--").lines;
use lib 't/spec/packages';
use Example::A;
use Example::B;
.say for Example::.keys.sort;
--END--
#?rakudo.jvm todo 'got: $["B", "C"]'
is-deeply @keys, [<A B C>], 'Diamond relationship';
my @precompiled2 = Test::Util::run( q:to"--END--").lines;
use lib 't/spec/packages';
for <T P D N S B G K C E F H R A U> {
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name("Example2::$_")));
say $comp-unit.precompiled;
}
--END--
is @precompiled2.elems, 15;
is $_, 'True' for @precompiled2;
# RT #123272
my @keys2 = Test::Util::run( q:to"--END--").lines;
use v6;
use lib 't/spec/packages';
use Example2::T;
use Example2::G;
use Example2::F;
use Example2::A;
use Example2::U;
.say for Example2::.keys.sort;
--END--
#?rakudo.jvm todo 'got: $["C", "K"]'
is-deeply @keys2, [<C D E F H K N P R S>], 'Twisty maze of dependencies, all different';
#?rakudo.jvm skip 'RT #122896'
#?rakudo.moar skip 'RT #122896'
{
is_run
'use lib "t/spec/packages";
use Example::C;
f();',
{ err => '',
out => '',
status => 0,
},
'precompile exported cached sub';
}
# RT #76456
{
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name<RT76456>));
ok $comp-unit.precompiled, 'precompiled a parameterized role';
}
#RT #122447
{
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name<RT122447>));
ok $comp-unit.precompiled, 'precompiled a sub with params returning a proxy';
}
#RT #115240
{
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name<RT115240>));
ok $comp-unit.precompiled, 'precomp curried role compose';
}
#RT #123276
{
my @precompiled = Test::Util::run( q:to"--END--").lines;
use lib 't/spec/packages';
my $name = 'RT123276';
for "{$name}", "{$name}::B::C1", "{$name}::B::C2" -> $module-name {
my $comp-unit = $*REPO.need(
CompUnit::DependencySpecification.new(:short-name($module-name))
);
say $comp-unit.precompiled;
}
--END--
is @precompiled.elems, 3, "tried to precompile all 3 modules";
is $_, 'True' for @precompiled;
my @keys = Test::Util::run( q:to"--END--").lines;
use lib 't/spec/packages';
use RT123276::B::C1;
use RT123276::B::C2;
say RT123276::B::C1.^methods
--END--
#RT #123276
#?rakudo.jvm todo 'got: $[]'
is-deeply @keys, [<(foo)>], 'RT123276';
}
#RT #124162
{
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name<RT124162>));
ok $comp-unit.precompiled, 'precomp of native array parameterization';
}
{
my $module-name-a = 'InternArrayA';
my $output-path-a = "t/spec/packages/" ~ $module-name-a ~ '.pm.' ~ $precomp-ext;
unlink $output-path-a; # don't care if failed
is_run
'my constant VALUE = array[uint32].new;
sub a() is export { VALUE }',
{ err => '',
out => '',
status => 0,
},
:compiler-args[
'--target', $precomp-target,
'--output', $output-path-a,
],
"precomp of native array parameterization intern test (a)";
ok $output-path-a.IO.e, "did we create a $output-path-a";
my $module-name-b = 'InternArrayB';
my $output-path-b = "t/spec/packages/" ~ $module-name-b ~ '.pm.' ~ $precomp-ext;
unlink $output-path-b; # don't care if failed
is_run
'my constant VALUE = array[uint32].new;
sub b() is export { VALUE }',
{ err => '',
out => '',
status => 0,
},
:compiler-args[
'--target', $precomp-target,
'--output', $output-path-b,
],
"precomp of native array parameterization intern test (b)";
ok $output-path-b.IO.e, "did we create a $output-path-b";
#?rakudo.jvm todo 'no 6model parametrics interning yet'
#?rakudo.moar todo 'no 6model parametrics interning yet'
is_run
"use $module-name-a;
use $module-name-b;
print a().WHAT =:= b().WHAT",
{ err => '',
out => "True",
status => 0,
},
:compiler-args['-I', 't/spec/packages'],
'precompile load of both and identity check passed';
unlink $_ for $output-path-a, $output-path-b; # don't care if failed
}
# RT #125090
{
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name<RT125090>));
ok $comp-unit.precompiled, 'precomp of BEGIN using $*KERNEL and $*DISTRO';
}
# RT #125245
{
my $comp-unit = $*REPO.need(CompUnit::DependencySpecification.new(:short-name<RT125245>));
ok $comp-unit.precompiled, 'precomp of assignment to variable using subset type';
}
# RT #127176
{
is_run '',
{
out => '',
err => { not $_ ~~ / ( "SORRY!" .*) ** 2 / },
status => { $_ != 0 },
},
:compiler-args['-I', 't/spec/packages', '-M', 'RT127176'],
'no duplicate compilation error';
}