Built-In Testing
- test blocks. Tests are test blocks in the source file: zig build test running them all.
- std.testing. std.testing asserts equality and errors: with the testing allocator watching memory.
- Doctests by proximity. Tests beside the code they pin: the file is implementation, contract and proof together.
Debugging Native Programs
- Debug builds. Debug builds keep safety checks on: bounds, overflow, unreachable: crashes at the true line.
- Stack traces. Panics print full traces: including error return traces on failure paths.
- Debuggers. Native debuggers work as on C: breakpoints, memory views, the systems toolkit intact.
Safety Modes
- Release modes. Zig ships modes: Debug, ReleaseSafe, ReleaseFast, ReleaseSmall: safety chosen per build.
- ReleaseSafe honestly. ReleaseSafe keeps checks in production: the default worth defending until profiles argue.
- undefined behaviour named. Zig names its UB and checks it in safe modes: unreachable is a promise, tested.
Before and after this level
- Before: Level 8: C Interoperability: Calling C, Exporting Zig, Replacing or Extending C Components.
- Next: Level 10: Performance: Memory Layout, Profiling, Systems-Level Optimisation.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Zig Level 9: Testing & Debugging cover?
Built-In Testing, Debugging Native Programs, Safety Modes: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 8: C Interoperability, which covers Calling C, Exporting Zig, Replacing or Extending C Components.