(nodeCount: number)
| 240 | ]; |
| 241 | |
| 242 | async function runTest(nodeCount: number) { |
| 243 | logEl.innerHTML = ''; |
| 244 | log(`=== Test: ${nodeCount} nodes ===`); |
| 245 | |
| 246 | // 1. Init |
| 247 | log('Initializing WASM module...'); |
| 248 | try { |
| 249 | // Worker script must be served from the correct path. |
| 250 | // In Vite dev mode, node_modules are served directly. |
| 251 | lbug.setWorkerPath('/lbug_wasm_worker.js'); |
| 252 | await lbug.init(); |
| 253 | const version = await lbug.getVersion(); |
| 254 | log(`WASM loaded — LadybugDB ${version}`, 'ok'); |
| 255 | } catch (err) { |
| 256 | log(`WASM init failed: ${err}`, 'err'); |
| 257 | return; |
| 258 | } |
| 259 | |
| 260 | let db: InstanceType<typeof lbug.Database>; |
| 261 | let conn: InstanceType<typeof lbug.Connection>; |
| 262 | |
| 263 | try { |
| 264 | db = new lbug.Database(':memory:'); |
| 265 | await db.init(); |
| 266 | conn = new lbug.Connection(db); |
| 267 | await conn.init(); |
| 268 | log('Database + Connection created', 'ok'); |
| 269 | } catch (err) { |
| 270 | log(`Database/Connection failed: ${err}`, 'err'); |
| 271 | return; |
| 272 | } |
| 273 | |
| 274 | // 2. Schema |
| 275 | log('Creating schema...'); |
| 276 | for (const type of NODE_TYPES) { |
| 277 | const r = await conn.query( |
| 278 | `CREATE NODE TABLE IF NOT EXISTS ${type}(id STRING PRIMARY KEY, name STRING, properties STRING)`, |
| 279 | ); |
| 280 | await r.close(); |
| 281 | } |
| 282 | const pairs = [ |
| 283 | 'FROM Function TO Function', |
| 284 | 'FROM Function TO File', |
| 285 | 'FROM Function TO Class', |
| 286 | 'FROM Class TO File', |
| 287 | 'FROM Class TO Class', |
| 288 | 'FROM File TO Directory', |
| 289 | 'FROM File TO File', |
| 290 | 'FROM File TO Package', |
| 291 | 'FROM File TO Repository', |
| 292 | 'FROM Directory TO Directory', |
| 293 | 'FROM Directory TO Repository', |
| 294 | 'FROM Repository TO Package', |
| 295 | ].join(', '); |
| 296 | const relResult = await conn.query( |
| 297 | `CREATE REL TABLE GROUP IF NOT EXISTS RELATES(${pairs}, id STRING, type STRING, properties STRING)`, |
| 298 | ); |
| 299 | await relResult.close(); |
nothing calls this directly
no test coverage detected