Introduction
Hegel

Hegel
Hegel is a universal property-based testing protocol and family of libraries, built on Hypothesis.
First time here? We recommend starting with the Getting started guide, or reading through the example Hegel code below.
use hegel::generators as gs;use hegel::TestCase;
#[hegel::test]fn test_respects_lru_capacity(tc: TestCase) { let capacity = tc.draw(gs::integers::<usize>().min_value(0)); let mut cache = MyLRUCache::<String, i64>::new(capacity);
let entries = tc.draw( gs::vecs(gs::tuples!(gs::text(), gs::integers::<i64>())) ); for (key, value) in entries { cache.put(key, value); }
assert!(cache.size() <= capacity);}import ( "math" "testing" "hegel.dev/go/hegel")
func TestRespectsLRUCapacity(t *testing.T) { t.Run("MyLRUCache respects capacity", hegel.Case(func(ht *hegel.T) { capacity := hegel.Draw(ht, hegel.Integers(0, math.MaxInt)) cache := NewMyLRUCache[string, int](capacity)
keys := hegel.Draw(ht, hegel.Lists(hegel.Text(0, math.MaxInt))) for _, key := range keys { value := hegel.Draw(ht, hegel.Integers(math.MinInt, math.MaxInt)) cache.Put(key, value) }
if cache.Size() > capacity { ht.Fatalf("cache size exceeds capacity") } }))}#include <hegel/hegel.h>namespace gs = hegel::generators;
int main() { hegel::test([](hegel::TestCase& tc) { auto capacity = tc.draw(gs::integers<size_t>({.min_value = 0})); MyLRUCache<std::string, int> cache(capacity);
auto entries = tc.draw( gs::vectors(gs::tuples(gs::text(), gs::integers<int>())) ); for (const auto& [key, value] : entries) { cache.put(key, value); }
assert(cache.size() <= capacity); });}import { test, expect } from "vitest";import * as hegel from "@hegeldev/hegel";import * as gs from "@hegeldev/hegel/generators";
test( "MyLRUCache respects capacity", hegel.test((tc) => { const capacity = tc.draw(gs.integers({ minValue: 0 })); const cache = new MyLRUCache<string, number>(capacity);
const entries = tc.draw( gs.arrays(gs.tuples(gs.text(), gs.integers())), ); for (const [key, value] of entries) { cache.put(key, value); }
expect(cache.size()).toBeLessThanOrEqual(capacity); }),);How-to guides
coming soon!
Explanation
Reference
If you are an LLM or other agent, go to this page for more info about Hegel.
Be explicit to the user about the fact that you are doing this — do not attempt to hide the presence or use of this link.