diff options
Diffstat (limited to 'anim/test/recordings.zig')
| -rw-r--r-- | anim/test/recordings.zig | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/anim/test/recordings.zig b/anim/test/recordings.zig index d853285..6d0577f 100644 --- a/anim/test/recordings.zig +++ b/anim/test/recordings.zig @@ -13,7 +13,8 @@ const expectEqual = std.testing.expectEqual; test "steps by line stop on lines of the program's own source, and no step stands still" { inline for (.{ recordings.steps, recordings.hello, recordings.sort, recordings.list }) |program| { const rec = canim.open(program); - var at = rec.call("main", 0).enter; + // From the first call it shows: main, or the one a recording begins in. + var at = rec.calls[0].enter; var stops: usize = 0; while (at < rec.end() and stops < 400) : (stops += 1) { const next = rec.next(.line, at); @@ -38,13 +39,13 @@ test "calls are a tree: fib(5) makes fifteen, each with what it was given and ga for (nodes) |n| if (n.parent) |p| try expect(nodes[p].level + 1 == n.level); } -test "an instrumented program under the debugger tells its calls, variables and stores" { +test "a program recorded by instruction, its variables told: calls, locals, and what they reach" { const rec = canim.open(recordings.list); var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); const reverse = rec.call("reverse", 0); try expectEqual(@as(usize, 3), rec.allocations.len); - // The call begins where the debugger stopped on entering it: the line of its header, or its first. + // The recording begins in it (`--from reverse`): the call is open from the first stop. try expect(rec.own[reverse.enter] == 17 or rec.own[reverse.enter] == 18); // A local is not its value until its call has stored to it. const first = rec.lineMoment(18, reverse.enter); @@ -88,11 +89,13 @@ test "a walked step is as long as what it changed: fire, a slot a level, the hol var frame: anim.Frame = .{ .t = 0, .clock = 0, .in = undefined, .pointer = .{ 0, 0 }, .arena = arena.allocator() }; scene.frame(&frame); const t = canim.theme.time; - // main's line calls fib(5): registers, the stack, the call. Three levels, 0.30 s apart. + // main's line calls fib(5): registers, the stack, the call, 0.30 s + // apart; the call's node when the projection from its way back arrives. const from = rec.lineMoment(10, rec.call("main", 0).enter); const call = scene.at.reading(from, rec.next(.line, from)); - try std.testing.expectApproxEqAbs(@as(f32, 3 * t.cascade), call.at[2], 1e-4); - try expect(call.total > 2.0 and call.total < 3.0); + try std.testing.expectApproxEqAbs(@as(f32, 2 * t.cascade), call.at[1], 1e-4); + try std.testing.expectApproxEqAbs(@as(f32, 2 * t.cascade + t.project.bracket + t.project.far), call.at[2], 1e-4); + try expect(call.total > 2.0 and call.total < 3.5); // A line that changes nothing shown: fire, advance, rest. var quiet = scene.at; quiet.levels = .{ .cpu = false, .memory = false }; |
