| 1 | const num_iterations = 10000 |
| 2 | |
| 3 | fn do_send(ch chan int) { |
| 4 | for i in 0 .. num_iterations { |
| 5 | ch <- i |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | fn test_channel_buffered() { |
| 10 | ch := chan int{cap: 1000} |
| 11 | spawn do_send(ch) |
| 12 | mut sum := i64(0) |
| 13 | for _ in 0 .. num_iterations { |
| 14 | sum += <-ch |
| 15 | } |
| 16 | assert sum == u64(num_iterations) * (num_iterations - 1) / 2 |
| 17 | } |
| 18 | |
| 19 | fn test_builtin_enum() { |
| 20 | x := ChanState.closed |
| 21 | assert x == .closed |
| 22 | println(x) |
| 23 | } |
| 24 |