examples: minor cleanup
This commit is contained in:
@@ -2,6 +2,8 @@ const std = @import("std");
|
|||||||
const Io = std.Io;
|
const Io = std.Io;
|
||||||
|
|
||||||
const Simulator = @import("zigmulator");
|
const Simulator = @import("zigmulator");
|
||||||
|
const assertSometimes = Simulator.assertSometimes;
|
||||||
|
const reachableSometimes = Simulator.reachableSometimes;
|
||||||
|
|
||||||
fn programA(init: std.process.Init) anyerror!void {
|
fn programA(init: std.process.Init) anyerror!void {
|
||||||
var stdout = Io.File.stdout().writerStreaming(init.io, &.{});
|
var stdout = Io.File.stdout().writerStreaming(init.io, &.{});
|
||||||
@@ -9,11 +11,14 @@ fn programA(init: std.process.Init) anyerror!void {
|
|||||||
try stdout.interface.print("Hello from program A!\n", .{});
|
try stdout.interface.print("Hello from program A!\n", .{});
|
||||||
try stdout.interface.flush();
|
try stdout.interface.flush();
|
||||||
|
|
||||||
// Taken on the last iteration, so it shows up as taken (✓) in the report.
|
// Taken on the last iteration, so it shows up as taken in the report.
|
||||||
Simulator.assertSometimes(i == 2, @src(), "program A reached its last iteration");
|
assertSometimes(i == 2, @src(), "program A reached its last iteration");
|
||||||
|
|
||||||
// Never satisfied in this run, so it shows up as not-taken (✗).
|
// Reaching this line is enough to mark this branch as taken.
|
||||||
Simulator.assertSometimes(i > 100, @src(), "program A looped more than 100 times");
|
reachableSometimes(@src(), "program A entered its loop body");
|
||||||
|
|
||||||
|
// Never satisfied in this run, so it shows up as missing in the report.
|
||||||
|
assertSometimes(i > 100, @src(), "program A looped more than 100 times");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user