From a1e9f488c16ef079f04210e1caa73513878586c3 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:15:33 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-fork.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/test-fork.js 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()