Skip to content

Commit e899218

Browse files
committed
tests/channels: add tests for built-in cap function
1 parent 987d542 commit e899218

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/channels/main.jule

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,26 @@ fn blockingSelect() {
5555
}
5656
}
5757

58+
fn capacity() {
59+
mut ch := make(chan int, 90)
60+
if cap(ch) != 90 {
61+
panic("expected 90")
62+
}
63+
ch = make(chan int)
64+
if cap(ch) != 0 {
65+
panic("expected 0")
66+
}
67+
ch = nil
68+
if cap(ch) != 0 {
69+
panic("expected 0")
70+
}
71+
}
72+
5873
fn main() {
5974
rangeIteration()
6075
unbuffered()
6176
sendOnly()
6277
recvOnly()
6378
blockingSelect()
79+
capacity()
6480
}

0 commit comments

Comments
 (0)