Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
		
							parent
							
								
									cecb2f3085
								
							
						
					
					
						commit
						f81e2b1e54
					
				
							
								
								
									
										21
									
								
								test/test-sh1.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								test/test-sh1.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
// Simple jamsh test creating and starting hello world agent
 | 
			
		||||
 | 
			
		||||
function agent(msg) {
 | 
			
		||||
  this.msg=msg;
 | 
			
		||||
  this.act =  {
 | 
			
		||||
    init : function () { log('Starting hello '+this.msg) },
 | 
			
		||||
    wait: function ()  { log('Sleeping'); sleep(1000) },
 | 
			
		||||
    end: function ()   { if (random(1)) throw "test exception"; /* not reached */ 
 | 
			
		||||
                         log('Terminating'); 
 | 
			
		||||
                         kill() }
 | 
			
		||||
  }
 | 
			
		||||
  this.trans = {
 | 
			
		||||
    init: wait,
 | 
			
		||||
    wait: function () { return random(1)?init:end } 
 | 
			
		||||
  }
 | 
			
		||||
  this.next = init
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
compile(agent)
 | 
			
		||||
create('agent','world')
 | 
			
		||||
start()
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user