hn.today

Unit-testing in the Ü programming language

panzerschrek.github.io3 points0 comments
Screenshot of Unit-testing in the Ü programming language

Ü now has built-in unit testing: developers define tests with `fn_test` and run them through the build system’s `test` command, without adding a framework or custom build steps. Test functions are specially marked and collected for test executables, while being removed from ordinary program binaries. The system builds a test executable for each target, reusing compiled source files; tests are built by default, even though cross-compiled executables may need to be run on the target platform rather than the host. The feature is intended to reduce the effort and risk of adopting tests, encouraging broader use and better software quality.

Because Ü deliberately has neither exceptions nor stack unwinding, a failing test cannot simply unwind and let the remaining tests continue. After rejecting `setjmp`/`longjmp` and running every test in its own process as impractical or too slow, the implementation runs tests sequentially in a child process and restarts it after a failure or crash, tracking progress through shared memory. This catches ordinary test failures as well as crashes such as access violations and stack overflows, though deadlocks remain difficult to detect; reporting is capped at 32 failed cases. When a debugger is detected, tests run in the current process to make debugging easier. Initial tests have been added to the compiler and build system, and linking test executables has caused no substantial build-time increase; coverage remains incomplete, with further tests expected as new functionality is developed.

Read on panzerschrek.github.io0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Big Data Is Dead

Big Data Is Dead

Big data is not the main obstacle to useful insights: hardware has kept pace with data growth, while teams still struggle to make sense of their information. The author argues that organizations should focus on making data easier to understand and use, rather than buying tools built for ever-larger datasets. (motherduck.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.