From fa09d425a012a291057bff9c1a90ead1beb51b67 Mon Sep 17 00:00:00 2001 From: cozis Date: Fri, 19 Jun 2026 13:26:47 +0200 Subject: [PATCH] examples: minor cleanup --- examples/example.zig | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/example.zig b/examples/example.zig index 224bf8c..dd983b6 100644 --- a/examples/example.zig +++ b/examples/example.zig @@ -2,6 +2,8 @@ const std = @import("std"); const Io = std.Io; const Simulator = @import("zigmulator"); +const assertSometimes = Simulator.assertSometimes; +const reachableSometimes = Simulator.reachableSometimes; fn programA(init: std.process.Init) anyerror!void { 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.flush(); - // 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"); + // Taken on the last iteration, so it shows up as taken in the report. + assertSometimes(i == 2, @src(), "program A reached its last iteration"); - // Never satisfied in this run, so it shows up as not-taken (✗). - Simulator.assertSometimes(i > 100, @src(), "program A looped more than 100 times"); + // Reaching this line is enough to mark this branch as taken. + 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"); } }