: produce-values ( Channel -- )
    dup 1 swap chan.send drop
    dup 2 swap chan.send drop
    dup 3 swap chan.send drop
    chan.close
;

: sum-from-channel ( Channel -- Int )
    # Receive all three values and sum them
    dup chan.receive drop     # ( chan 1 )
    over chan.receive drop    # ( chan 1 2 )
    rot chan.receive drop     # ( 1 2 3 )
    i.+ i.+                   # ( 6 )
;

: test-patterns ( -- )
    chan.make
    dup produce-values
    sum-from-channel
    6 test.assert-eq
;
