| ... | @@ -183,10 +183,10 @@ test "select" { | ... | @@ -183,10 +183,10 @@ test "select" { |
| 183 | return; | 183 | return; |
| 184 | }, | 184 | }, |
| 185 | }; | 185 | }; |
| 186 | defer if (get_a.cancel(io)) |_| @panic("fail") else |err| assert(err == error.Canceled); | 186 | defer if (get_a.cancel(io)) |_| {} else |_| @panic("fail"); |
| 187 | | 187 | |
| 188 | var get_b = try io.concurrent(Io.Queue(u8).getOne, .{ &queue, io }); | 188 | var get_b = try io.concurrent(Io.Queue(u8).getOne, .{ &queue, io }); |
| 189 | defer if (get_b.cancel(io)) |_| @panic("fail") else |err| assert(err == error.Canceled); | 189 | defer if (get_b.cancel(io)) |_| {} else |_| @panic("fail"); |
| 190 | | 190 | |
| 191 | var timeout = io.async(Io.sleep, .{ io, .fromMilliseconds(1), .awake }); | 191 | var timeout = io.async(Io.sleep, .{ io, .fromMilliseconds(1), .awake }); |
| 192 | defer timeout.cancel(io) catch {}; | 192 | defer timeout.cancel(io) catch {}; |
| ... | @@ -198,6 +198,13 @@ test "select" { | ... | @@ -198,6 +198,13 @@ test "select" { |
| 198 | })) { | 198 | })) { |
| 199 | .get_a => return error.TestFailure, | 199 | .get_a => return error.TestFailure, |
| 200 | .get_b => return error.TestFailure, | 200 | .get_b => return error.TestFailure, |
| 201 | .timeout => {}, | 201 | .timeout => { |
| | 202 | // Unblock the queues to avoid making this unit test depend on |
| | 203 | // cancellation. |
| | 204 | queue.putOneUncancelable(io, 1); |
| | 205 | queue.putOneUncancelable(io, 1); |
| | 206 | try testing.expectEqual(1, try get_a.await(io)); |
| | 207 | try testing.expectEqual(1, try get_b.await(io)); |
| | 208 | }, |
| 202 | } | 209 | } |
| 203 | } | 210 | } |