Tue 27 Aug 00:14:56 CEST 2024

This commit is contained in:
sbosse 2024-08-27 00:15:52 +02:00
parent a95666ca37
commit 7feb9f066e

48
test/test-jamlib1.js Normal file
View File

@ -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<N;i++) {
JAM.createAgent('ac',{verbose:0});
}
print(util.inspect(JAM.stats('process')))
print(util.inspect(JAM.stats('vm')))
print('All checks passed.');