Skip to content

Commit

Permalink
test 6 chans incrementing to 7
Browse files Browse the repository at this point in the history
  • Loading branch information
reqshark committed Mar 3, 2016
1 parent 00288da commit 0a5953f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ check:
cc -o inproc test/inproc.c $(flags)
cc -o ipc test/ipc.c $(flags)
cc -o tcp test/tcp.c $(flags)
./inproc && ./ipc && ./tcp && rm inproc ipc tcp
cc -o ch test/ch.c $(flags)
./inproc && ./ipc && ./tcp && ./ch && rm inproc ipc tcp ch
@echo verified consistent behavior among common transports

run: example.c
Expand Down
56 changes: 56 additions & 0 deletions test/ch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
Copyright (c) 2016 Bent Cardan
Copyright (c) 2016 Fatih Kaya
Copyright (c) 2016 Martin Sustrik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/

#include <stdio.h>
#include <libmill.h>

static coroutine void c1 (int i, chan o) { chs(o, int, ++i); }
static coroutine void c2 (chan i, chan o) { chs(o, int, ++chr(i, int)); }
static coroutine void c3 (chan i, chan o) { chs(o, int, ++chr(i, int)); }
static coroutine void c4 (chan i, chan o) { chs(o, int, ++chr(i, int)); }
static coroutine void c5 (chan i, chan o) { chs(o, int, ++chr(i, int)); }
static coroutine void c6 (chan i, chan o) { chs(o, int, ++chr(i, int)); }

int main (const int argc, const char **argv) {

chan ch = chmake(int, 0);
chan ch2 = chmake(int, 0);
chan ch3 = chmake(int, 0);
chan ch4 = chmake(int, 0);
chan ch5 = chmake(int, 0);
chan ch6 = chmake(int, 0);

go( c1( 1, ch) );
go( c2( ch, ch2) );
go( c3( ch2, ch3) );
go( c4( ch3, ch4) );
go( c5( ch4, ch5) );
go( c6( ch5, ch6) );

printf("incremented to: %d\n", chr(ch6, int)); // incremented to 7

return 0;
}

0 comments on commit 0a5953f

Please sign in to comment.