Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
		
							parent
							
								
									98556c426e
								
							
						
					
					
						commit
						f6d60aaa17
					
				
							
								
								
									
										53
									
								
								test/test-fork-subclass.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								test/test-fork-subclass.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,53 @@
 | 
				
			||||||
 | 
					function master(xy) {
 | 
				
			||||||
 | 
					  this.data=xy;
 | 
				
			||||||
 | 
					  this.z=0;
 | 
				
			||||||
 | 
					  this.child=null;
 | 
				
			||||||
 | 
					  this.act = {
 | 
				
			||||||
 | 
					    start : () => {
 | 
				
			||||||
 | 
					      log('start');
 | 
				
			||||||
 | 
					      this.child = create({
 | 
				
			||||||
 | 
					        z:0,
 | 
				
			||||||
 | 
					        data:{
 | 
				
			||||||
 | 
					          x:random(1,50),
 | 
				
			||||||
 | 
					          y:random(1,50)
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        act : [compA,end],
 | 
				
			||||||
 | 
					        trans : {
 | 
				
			||||||
 | 
					          start:compA
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      })
 | 
				
			||||||
 | 
					      log(this.child)
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    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()
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user