47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const wasm_loader = require('wasm_loader')
|
|
|
|
var mod;
|
|
wasm_loader('douwco_hivemind_loader', 'douwco_hivemind_module').then((instance) => {
|
|
console.log("WASM module loaded.");
|
|
mod = instance;
|
|
});
|
|
|
|
module.exports.loop = function () {
|
|
if (mod !== undefined)
|
|
mod.loop();
|
|
}
|
|
|
|
// Expose runTests function for console testing
|
|
module.exports.runTests = function () {
|
|
if (mod !== undefined && typeof mod.runTests === 'function') {
|
|
console.log("Running Douwco Hivemind tests...");
|
|
mod.runTests();
|
|
|
|
// Get and display test results
|
|
try {
|
|
const results = mod.getTestResults();
|
|
const passed = mod.getPassedCount();
|
|
const failed = mod.getFailedCount();
|
|
const total = mod.getTotalCount();
|
|
|
|
console.log(results);
|
|
console.log(`Test Summary: ${passed}/${total} passed, ${failed} failed`);
|
|
|
|
return `Tests completed: ${passed} passed, ${failed} failed`;
|
|
} catch (e) {
|
|
console.log("Tests completed. Could not retrieve detailed results:", e.message);
|
|
return "Tests completed. Check console for basic output.";
|
|
}
|
|
} else {
|
|
console.log("ERROR: runTests function not available in WASM module");
|
|
return "ERROR: Testing framework not available";
|
|
}
|
|
}
|
|
|
|
// Also expose globally for direct console access
|
|
if (typeof global !== 'undefined') {
|
|
global.runTests = module.exports.runTests;
|
|
}
|