Skip to content

Commit 01738d1

Browse files
bors[bot]itarato
andcommitted
Merge #380
380: Port test from Go lang - goroutines r=stjepang a=itarato Porting the [goroutines](https://github.com/golang/go/blob/master/test/chan/goroutines.go) test from the Go lang repository. Part of #201 Any help would be appreciated. Co-authored-by: Peter Arato <[email protected]>
2 parents 240cf90 + c340409 commit 01738d1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

crossbeam-channel/tests/golang.rs

+27
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,33 @@ mod fifo {
314314
}
315315
}
316316

317+
// https://github.com/golang/go/blob/master/test/chan/goroutines.go
318+
mod goroutines {
319+
use super::*;
320+
321+
fn f(left: Chan<i32>, right: Chan<i32>) {
322+
left.send(right.recv().unwrap());
323+
}
324+
325+
#[test]
326+
fn main() {
327+
let n = 10_000i32;
328+
329+
let leftmost = make::<i32>(0);
330+
let mut right = leftmost.clone();
331+
let mut left = leftmost.clone();
332+
333+
for _ in 0..n {
334+
right = make::<i32>(0);
335+
go!(left, right, f(left, right));
336+
left = right.clone();
337+
}
338+
339+
go!(right, right.send(1));
340+
leftmost.recv().unwrap();
341+
}
342+
}
343+
317344
// https://github.com/golang/go/blob/master/test/chan/nonblock.go
318345
mod nonblock {
319346
use super::*;

0 commit comments

Comments
 (0)