diff --git a/test/test-fork.js b/test/test-fork.js new file mode 100644 index 0000000..5b5fc83 --- /dev/null +++ b/test/test-fork.js @@ -0,0 +1,47 @@ +function master(xy) { + this.data=xy; + this.z=0; + this.child=null; + this.act = { + start : () => { + log('start'); + this.child = fork({ + data:{ + x:random(1,50), + y:random(1,50) + } + }) + }, + compA: () => { + this.z=this.data.x+this.data.y; + log('z='+this.z) + }, + compB: () => { + this.z=this.data.x*this.data.y; + log('z='+this.z); + }, + end : () => { + log(keys(this)) + log(keys(this.act)) + log(keys(this.trans)) + if (this.on) log(keys(this.on)) + kill() + } + } + this.trans = { + start:() => { + return this.data.x<10 && this.data.y<10?compB:compA + }, + compA:end, + compB:end + } + this.on = { + SIG1: () => { + log('got SIG1') + } + } + this.next=start +} +compile(master) +create('master',{x:5,y:7}) +start()