Skip to content

Commit 142ff01

Browse files
committed
Make a test compile faster.
1 parent baf4744 commit 142ff01

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/test/run-pass/syntax-extension-fmt.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ fn main() {
1414

1515
test(#fmt("test"), "test");
1616

17+
// a quadratic optimization in LLVM (jump-threading) makes this test a
18+
// bit slow to compile unless we break it up
19+
part1();
20+
part2();
21+
part3();
22+
part4();
23+
part5();
24+
part6();
25+
}
26+
27+
fn part1() {
1728
// Simple tests for types
1829

1930
test(#fmt("%d", 1), "1");
@@ -36,6 +47,8 @@ fn main() {
3647
test(#fmt("%x", 0xffffffff_u), "ffffffff");
3748
test(#fmt("%o", 0xffffffff_u), "37777777777");
3849
test(#fmt("%t", 0xffffffff_u), "11111111111111111111111111111111");
50+
}
51+
fn part2() {
3952
// Widths
4053

4154
test(#fmt("%1d", 500), "500");
@@ -61,6 +74,9 @@ fn main() {
6174
test(#fmt("%-10o", 10u), "12 ");
6275
test(#fmt("%-10t", 0xff_u), "11111111 ");
6376
test(#fmt("%-10c", 'A'), "A ");
77+
}
78+
79+
fn part3() {
6480
// Precision
6581

6682
test(#fmt("%.d", 0), "");
@@ -99,6 +115,8 @@ fn main() {
99115
test(#fmt("%.1o", 10u), "12");
100116
test(#fmt("%.1t", 3u), "11");
101117
test(#fmt("%.1c", 'A'), "A");
118+
}
119+
fn part4() {
102120
test(#fmt("%.5d", 0), "00000");
103121
test(#fmt("%.5u", 0u), "00000");
104122
test(#fmt("%.5x", 0u), "00000");
@@ -115,10 +133,13 @@ fn main() {
115133
// conversions support precision - it's not standard printf so we
116134
// can do whatever. For now I'm making it behave the same as string
117135
// conversions.
118-
136+
119137
test(#fmt("%.b", true), "");
120138
test(#fmt("%.0b", true), "");
121-
test(#fmt("%.1b", true), "t");
139+
test(#fmt("%.1b", true), "t");
140+
}
141+
142+
fn part5() {
122143
// Explicit + sign. Only for signed conversions
123144

124145
test(#fmt("%+d", 0), "+0");
@@ -161,6 +182,8 @@ fn main() {
161182
test(#fmt("%-05s", "test"), "test ");
162183
test(#fmt("%-05c", 'A'), "A ");
163184
test(#fmt("%-05b", true), "true ");
185+
}
186+
fn part6(){
164187
// Precision overrides 0-padding
165188

166189
test(#fmt("%06.5d", 0), " 00000");
@@ -192,4 +215,4 @@ fn main() {
192215
test(#fmt("%- 05d", -1), "-1 ");
193216
test(#fmt("%-+05d", 1), "+1 ");
194217
test(#fmt("%-+05d", -1), "-1 ");
195-
}
218+
}

0 commit comments

Comments
 (0)