# Use std.testing.expect in language reference samples · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/ddd39b994b1eb9751d06227c6db02f15a5f71e9f)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: ddd39b994b1eb9751d06227c6db02f15a5f71e9f

Requested commit: ddd39b994b1eb9751d06227c6db02f15a5f71e9f

Commit: ddd39b994b1eb9751d06227c6db02f15a5f71e9f

Tree: 0ca901104b628f09ed01446a260daef11a0e9c42

Author: Paul Espinosa

Committer: Andrew Kelley

## Message

```
Use std.testing.expect in language reference samples

In this commit, the code samples in the language reference have been changed to
use `std.testing.expect` rather than `std.debug.assert` when they are
written in `test` code. This will teach Zig learners best practices when
they write their own test code.

Not all uses of `std.debug.assert` have been replaced. There are examples where
using `assert` fits the context of the sample.

Using `std.debug.assert` in test code can lead to errors if running tests in
ReleaseFast mode. In ReleaseFast mode, the `unreachable` in `assert` is
undefined behavior. It is possible that `assert` always causes `zig test` to
pass thus possibly leading to incorrect test code outcomes. The goal is to
prevent incorrect code from passing test cases.

Closes #5836

```

## Parents

- [1e13e8e8172c1409c5152e8b4e935c5a1d31704b](https://git.cafe/gitcafe/zig/commit/1e13e8e8172c1409c5152e8b4e935c5a1d31704b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/ddd39b994b1eb9751d06227c6db02f15a5f71e9f?format=markdown)
