From a8315c39d5658aba0a987cb66f1ce174c789b146 Mon Sep 17 00:00:00 2001 From: takunomi-build-bot Date: Thu, 17 Apr 2025 16:38:00 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Repository=20layout=20updated=20?= =?UTF-8?q?to=20latest=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit was automatically generated by [a script](https://gitfub.space/Jmaa/repo-manager) --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index ab998d0..df4b14e 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,41 @@ Lua Library that replaces the default [assert](https://www.lua.org/manual/5.4/ma assert condition, inspects the state of the program and emits an improved error message. + ## Example + + ```lua + function f (a) + +``` +assert(type(a) == 'string') +``` + + end + + f(42) + ``` + + Without [assert-gooder](index.html#), the above code would fail with the error message + `assertion failed!`. With [assert-gooder](index.html#), it will fail with this error message: + `assertion failed! bad argument #1 'a' to 'f' (string expected, but got number: 42)`, + + ## Motivation + + Assertions are useful to ensure internal consistency, when you're writing code + in a hurry, but in Lua (and most other languages), these assert constructs never + produce useful error messages, but rather unhelpful `assert failed!` errors and + a stack trace. + + By making it a runtime library, instead of a "compile-time" rewrite, we gain + flexibility. It's much easier to import a library, than restructuring then + compile pipeline. It also means that we have access to runtime values, allowing + even more helpful messages. + + ## Setup + + Download, and use `assert = require "assert-gooder"` to overwrite Lua's default + assert with [assert-gooder](index.html#). + - Author: Jon Michael Aanes (jonjmaa@gmail.com) ## Dependencies