ZT_CLAIM(3)

πŸ’– zt_claim β€” the little struct that holds your hot take before anyone checks it πŸ’–

okay so bestie, this is a page from the LOCAL manual, and it's all about zt_claim β€” a structure capturing an unevaluated assertion. yes she's a struct, yes she's serving, let's get into it πŸŽ€


✨ NAME ✨

zt_claim β€” structure capturing unevaluated assertion

like... a claim you made but haven't actually verified yet. the receipts are pending, the vibe is immaculate πŸ’…


🌸 SYNOPSIS 🌸

#include <zt.h>

typedef struct zt_claim { ... } zt_claim;

and here's what's inside her, member by member, no skips:

  • struct zt_verifier *(*)(void) β†’ make_verifier β€” the verifier factory 🏭
  • zt_value[3] β†’ args β€” the verifier arguments
  • zt_location β†’ location β€” where the claim came from, aka the origin story of the claim πŸ“

πŸ¦‹ DESCRIPTION πŸ¦‹

so zt_claim binds a verifier factory function together with concrete arguments. that's the whole point, bestie β€” it means the entire claim can be passed around like a lil note in the group chat and evaluated whenever you feel like it, on demand. ⏳

and if things go wrong (failure, ugh 😭), the location where the claim was made can be referenced so you can construct error messages that actually tell you where the mess happened.


πŸ‘‘ IMPLEMENTATION NOTES πŸ‘‘

okay this is the lore. the verification system is a whole chain of cooperating elements, and when it works it works. for example, a trivial integer relationship assertion behaves like this:

ZT_CMP_INT(), or another similar macro, invokes zt_cmp_int(), providing source code location as zt_location, and packaging specific types into the common variant type zt_value. the result is a zt_claim which is then passed to zt_assert() or zt_check() for evaluation. ✨

and here's the cast of characters, all the essential types and functions, summarized below:

  • zt_value captures values expressed in a test case
  • zt_claim transports up to three values and an opaque verifier
  • zt_check() and zt_assert() validate the claim by instantiating zt_verifier
  • zt_verifier (private) wraps a verification function, including the arity and expected kind of each argument
  • zt_arg_info (private) pairs expected argument kind with a customized error message used on kind mismatch
  • zt_verify_claim() (private) ensures verifier function arity and argument kind matches what is encoded in the claim and invokes the verifier function
  • the specific verifier function inspects the argument and performs the actual verification of the desired property that the test is measuring
  • zt_test (private) keeps track of test outcome, provides a stream for writing error messages and assists in performing non-local exit

so many little guys doing their part. teamwork makes the dream work 🫢


πŸ’œ SEE ALSO πŸ’œ

go read those too, iykyk πŸ“š


🌈 HISTORY 🌈

zt_claim first appeared in libzt 0.1 β€” a true OG πŸ‘‘


πŸ’€ BUGS πŸ’€

part of the API is private, which prevents third party verification functions from being written. this is done on purpose (fr fr, on purpose) to allow for some more experimentation before stabilizing the interface. so like, it's not a bug it's a choice, but we're still putting it here under BUGS. πŸ™ˆ


πŸŽ€ AUTHORS πŸŽ€

Zygmunt Krynicki <me@zygoon.pl>


and that's the page!! πŸ’– this one's from libzt 0.3.1, dated January 12, 2020 β€” mwah, periodt ✨🌸