blob: f3a4b9b5d660c531b956ac75c9416ed6af2b6152 (
plain) (
blame)
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
|
// -*- rust -*-
// Regression tests for circular_buffer when using a unit
// that has a size that is not a power of two
use std;
import std.option;
import std._uint;
import std._vec;
// A 12-byte unit to send over the channel
type record = rec(i32 val1, i32 val2, i32 val3);
// Assuming that the default buffer size needs to hold 8 units,
// then the minimum buffer size needs to be 96. That's not a
// power of two so needs to be rounded up. Don't trigger any
// assertions.
impure fn test_init() {
let port[record] myport = port();
auto mychan = chan(myport);
let record val = rec(val1=0i32, val2=0i32, val3=0i32);
mychan <| val;
}
// Dump lots of items into the channel so it has to grow.
// Don't trigger any assertions.
impure fn test_grow() {
let port[record] myport = port();
auto mychan = chan(myport);
let record val = rec(val1=0i32, val2=0i32, val3=0i32);
for each (uint i in _uint.range(0u, 100u)) {
mychan <| val;
}
}
impure fn main() {
test_init();
test_grow();
}
// Local Variables:
// mode: rust;
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
|