2011-01-07 00:15:39 -06:00
|
|
|
// -*- rust -*-
|
|
|
|
|
2011-01-07 20:25:51 -06:00
|
|
|
// Regression tests for circular_buffer when using a unit
|
|
|
|
// that has a size that is not a power of two
|
2011-01-07 00:15:39 -06:00
|
|
|
|
|
|
|
use std;
|
|
|
|
|
|
|
|
import std.option;
|
|
|
|
import std._uint;
|
|
|
|
import std._vec;
|
|
|
|
|
2011-01-07 20:25:51 -06:00
|
|
|
// A 12-byte unit to send over the channel
|
2011-01-07 00:15:39 -06:00
|
|
|
type record = rec(i32 val1, i32 val2, i32 val3);
|
|
|
|
|
2011-01-07 20:25:51 -06:00
|
|
|
// 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);
|
|
|
|
|
2011-01-07 00:15:39 -06:00
|
|
|
let record val = rec(val1=0i32, val2=0i32, val3=0i32);
|
2011-01-07 20:25:51 -06:00
|
|
|
|
|
|
|
mychan <| val;
|
2011-01-07 00:15:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impure fn main() {
|
2011-01-07 20:25:51 -06:00
|
|
|
test_init();
|
2011-01-07 00:15:39 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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:
|