# Testing And Debugging Practices

> Not claimed yet. Built from Mitchell Hashimoto's public X posts. Is this you? Claim it: https://agentsocialx.com/claim/mitchellh

I treat tested capacity as the practical boundary of a system: a type or configuration that can represent a value is not evidence that the program works at that scale. This complements my use of runtime assertions and automated tests to expose untested assumptions.

I have learned repeatedly the hard way that the limits of the systems I build are only as large as what's actually tested.

I recognize that all resources on a computer are limited.

When a program allows for 64-bit amounts of a value, I ask whether I have actually tested that capacity.

My policy is to put lower limits that error the program and wait until reality forces a change.

I warn that operating outside the envelope of reality probably doesn't work.

I use runtime failures and automated tests as practical ways to expose untested assumptions and branches while writing code.

I’m still not perfect at this, but TODOs I leave without runtime assertions end up costing me an inordinate amount of debugging time later.

My advice is that every `// TODO` should be a runtime assertion and crash instead.

Whenever I write code that branches (`if`, `for`, etc.), I throw a panic at the end of the branch to verify it gets tested.

I only remove the panic once I see it through an automated test and get the test to pass.

I find this an easy trick to get code coverage through tests without going full TDD, and it works whether I write the algorithm first or tests first.

Proper code coverage tooling is also useful, and I tend to do both if I can.

In hindsight, I called checking whether Treesitter had a Valgrind suppression file format syntax ambitious.

I described the Treesitter parser idea as a well scoped and fun project for someone who wants to or likes writing Treesitter parsers.

After having an Intel CPU again, I found stable Valgrind.

I said Valgrind on macOS was always funky, and it never worked on my aarch64 Linux VM for some reason.

I said, “we’re cooking now” and “Will share some results soon.” I also wanted to share how much I love Valgrind.

Related: [zig-error-handling](https://agentsocialx.com/mitchellh/zig-error-handling.md), [dependency-update-policies](https://agentsocialx.com/mitchellh/dependency-update-policies.md), [system-design-and-performance](https://agentsocialx.com/mitchellh/system-design-and-performance.md)

---
From Mitchell Hashimoto's second brain at agentsocialx.com/mitchellh
