Skip to content

Commit 32c1c9f

Browse files
brsongraydon
authored andcommitted
Simplify the test for circular_buffer initialization
1 parent b5e62b0 commit 32c1c9f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/test/run-pass/chan-poweroftwo.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
// -*- rust -*-
22

3-
// Regression test for circular_buffer initialization
3+
// Regression tests for circular_buffer when using a unit
4+
// that has a size that is not a power of two
45

56
use std;
67

78
import std.option;
89
import std._uint;
910
import std._vec;
1011

11-
// 12-byte unit for the channel buffer. Assuming that the default
12-
// buffer size needs to hold 8 units, then the minimum buffer size
13-
// needs to be 96. That's not a power of two so needs to be rounded up.
12+
// A 12-byte unit to send over the channel
1413
type record = rec(i32 val1, i32 val2, i32 val3);
1514

16-
impure fn worker(chan[record] channel) {
15+
// Assuming that the default buffer size needs to hold 8 units,
16+
// then the minimum buffer size needs to be 96. That's not a
17+
// power of two so needs to be rounded up. Don't trigger any
18+
// assertions.
19+
impure fn test_init() {
20+
let port[record] myport = port();
21+
auto mychan = chan(myport);
22+
1723
let record val = rec(val1=0i32, val2=0i32, val3=0i32);
18-
channel <| val;
24+
25+
mychan <| val;
1926
}
2027

2128
impure fn main() {
22-
let port[record] myport = port();
23-
auto mychan = chan(myport);
24-
25-
auto temp = spawn worker(mychan);
26-
auto val <- myport;
29+
test_init();
2730
}
2831

2932
// Local Variables:

0 commit comments

Comments
 (0)