Logging
This commit is contained in:
@@ -42,14 +42,14 @@ test('Playback: stepping liefert driver-native (Radian) Zeilen, Grenzen werfen',
|
||||
const a = new ActiveState();
|
||||
await a.load('play_1');
|
||||
|
||||
const first = a.first();
|
||||
const first = await a.first();
|
||||
expect(first.cursor).toBe(0);
|
||||
expect(first.line).not.toMatch(/;/);
|
||||
const aVal = Number(first.line.split(/\s+/).find((t) => t.startsWith('a')).slice(1));
|
||||
expect(aVal).toBeCloseTo(Math.PI / 2, 4);
|
||||
|
||||
expect(a.next().cursor).toBe(1);
|
||||
expect(() => a.next()).toThrow(); // über das Ende → CURSOR_OUT_OF_RANGE
|
||||
expect((await a.next()).cursor).toBe(1);
|
||||
await expect(a.next()).rejects.toThrow(); // über das Ende → CURSOR_OUT_OF_RANGE
|
||||
});
|
||||
|
||||
test('Cursor liegt im .json-Sidecar, .gcode bleibt sauber (kein !-Marker)', async () => {
|
||||
@@ -62,7 +62,7 @@ test('Cursor liegt im .json-Sidecar, .gcode bleibt sauber (kein !-Marker)', asyn
|
||||
});
|
||||
const a = new ActiveState();
|
||||
await a.load('cur_1');
|
||||
a.next(); // cursor → 1 (kein Persist)
|
||||
await a.next(); // cursor → 1 (kein Persist)
|
||||
await a.appendLine('G4 P0.1'); // persistiert, cursor → 2
|
||||
|
||||
const prog = await store.read('cur_1');
|
||||
@@ -75,9 +75,28 @@ test('Cursor liegt im .json-Sidecar, .gcode bleibt sauber (kein !-Marker)', asyn
|
||||
expect(units.splitComment(prog.lines[2]).code).toBe('G4 P0.1');
|
||||
});
|
||||
|
||||
test('Stepping ohne aktives Programm → NO_ACTIVE_PROGRAM', async () => {
|
||||
test('Stepping ohne aktives Programm → auto-lädt Default (leer → EMPTY_PROGRAM)', async () => {
|
||||
const a = new ActiveState();
|
||||
expect(() => a.next()).toThrow(); // NO_ACTIVE_PROGRAM
|
||||
// next() lädt automatisch das Default-Programm; da es (im tmp) leer ist → EMPTY_PROGRAM
|
||||
await expect(a.next()).rejects.toMatchObject({ code: 'EMPTY_PROGRAM' });
|
||||
expect(a.programId).toBe(cfg.defaultProgramId); // Default wurde geladen
|
||||
});
|
||||
|
||||
test('Stepping nach Neustart liest Default-Programm von Disk (FFirst ohne FLoad)', async () => {
|
||||
// Simuliert: log.gcode liegt auf Disk, frischer ActiveState (wie nach Container-Neustart)
|
||||
await store.write(cfg.defaultProgramId, {
|
||||
name: 'log',
|
||||
lines: [
|
||||
'G90 G1 x0 y300 z0 a90.00 b-90.00 c0.00 e0.00 f1000 ;1',
|
||||
'G90 G1 x10 y300 z0 a0.00 b-90.00 c0.00 e0.00 f1000 ;2',
|
||||
],
|
||||
cursor: 1,
|
||||
});
|
||||
const a = new ActiveState();
|
||||
const r = await a.first(); // ohne vorheriges FLoad → Default wird geladen
|
||||
expect(a.programId).toBe(cfg.defaultProgramId);
|
||||
expect(r.cursor).toBe(0);
|
||||
expect(a.getState().lineCount).toBe(2);
|
||||
});
|
||||
|
||||
test('FPoint ohne aktives Programm → auto-lädt Default-Programm (log)', async () => {
|
||||
|
||||
Reference in New Issue
Block a user