From 7feb9f066eda5973fe2ab1f02e89b04408ea1d29 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:15:52 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-jamlib1.js | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 test/test-jamlib1.js diff --git a/test/test-jamlib1.js b/test/test-jamlib1.js new file mode 100644 index 0000000..beccf9e --- /dev/null +++ b/test/test-jamlib1.js @@ -0,0 +1,48 @@ +var jamlib = require('../build/lib/jamlib.debug'); +var util = require('util'); +var N = 1; + +print('Checkpoint 0: Creating JAM...'); + +// Create the JAM and JAM world consisting of one logical node +var JAM = jamlib.Jam({ + print:function (msg) {console.log('[JAMLIB] '+msg);}, + verbose:1, +}); + +JAM.init(); +print(util.inspect(JAM.stats('node'))) + +print('Checkpoint 2: Compiling agent constructor function...'); + +function ac(options) { + this.options=options; + this.act = { + a1:function () {}, + a2:function () {}, + a3:function () {}, + a4:function () {log('Checkpoint a4'); kill()}, + } + this.trans = { + a1:"a2", + a2:function () { if (this.options.state<100) return "a3"; else return "a4"; }, + a3:"a4", + } + this.next="a1"; +} + +try { JAM.compileClass(undefined,ac,{verbose:1}); } +catch (e) { return print(e); }; + + +print('Checkpoint 1: Starting JAM...'); +JAM.start(); + +print('Checkpoint 3: Creating agents ...'); +for(var i = 0; i