Add hegeltest for property-based testing
Assisted-by: Claude Opus 4.7 via Claude Code
change znxqmkyrmqrvnmpqkttsmqoxuvvmpytt
commit 476af88aee2928c7ff318da7975615145b4535bf
author Alpha Chen <alpha@kejadlen.dev>
date
parent llvlqszt
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 5e13731..435c489 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,6 +23,7 @@ jobs:
           persist-credentials: false
       - run: rustup component add clippy rustfmt
       - run: cargo install just
+      - uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
       - run: cargo fmt --check
       - run: just clippy test
       # Coverage and mutation testing disabled during early exploratory work.
diff --git a/.gitignore b/.gitignore
index ea8c4bf..6980cf2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 /target
+/.hegel
diff --git a/Cargo.lock b/Cargo.lock
index bf4aa56..ae14394 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -441,6 +441,33 @@ version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
 
+[[package]]
+name = "ciborium"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
+dependencies = [
+ "ciborium-io",
+ "ciborium-ll",
+ "serde",
+]
+
+[[package]]
+name = "ciborium-io"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
+
+[[package]]
+name = "ciborium-ll"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
+dependencies = [
+ "ciborium-io",
+ "half",
+]
+
 [[package]]
 name = "clap"
 version = "4.6.1"
@@ -540,6 +567,21 @@ version = "0.8.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
 
+[[package]]
+name = "crc32fast"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "crunchy"
+version = "0.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
+
 [[package]]
 name = "debugid"
 version = "0.8.0"
@@ -846,6 +888,17 @@ dependencies = [
  "tracing",
 ]
 
+[[package]]
+name = "half"
+version = "2.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
+dependencies = [
+ "cfg-if",
+ "crunchy",
+ "zerocopy",
+]
+
 [[package]]
 name = "hashbrown"
 version = "0.15.5"
@@ -867,6 +920,32 @@ version = "0.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
 
+[[package]]
+name = "hegeltest"
+version = "0.8.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3dd9ff270d73f0ea5b0b5e507c4551b36fe0363c0dddca3bbba3f21a78065274"
+dependencies = [
+ "ciborium",
+ "crc32fast",
+ "hegeltest-macros",
+ "parking_lot",
+ "paste",
+ "serde",
+ "tempfile",
+]
+
+[[package]]
+name = "hegeltest-macros"
+version = "0.8.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c1862be4b472891951d26627364df4682c6527bb138d1649383811f7b1dbf14"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "hex"
 version = "0.4.3"
@@ -1748,6 +1827,12 @@ dependencies = [
  "windows-link",
 ]
 
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
 [[package]]
 name = "percent-encoding"
 version = "2.3.2"
@@ -1932,6 +2017,7 @@ dependencies = [
  "clap",
  "clap_complete",
  "fs-err",
+ "hegeltest",
  "jiff",
  "miette",
  "mlua",
diff --git a/Cargo.toml b/Cargo.toml
index 0a8688e..96891dd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,5 +34,6 @@ walkdir = "*"
 
 [dev-dependencies]
 assert_cmd = "*"
+hegeltest = "*"
 predicates = "*"
 serde_json = "*"
diff --git a/tests/property.rs b/tests/property.rs
new file mode 100644
index 0000000..0200779
--- /dev/null
+++ b/tests/property.rs
@@ -0,0 +1,9 @@
+use hegel::TestCase;
+use hegel::generators::integers;
+
+#[hegel::test]
+fn integer_addition_is_commutative(tc: TestCase) {
+    let x = tc.draw(integers::<i64>());
+    let y = tc.draw(integers::<i64>());
+    assert_eq!(x.wrapping_add(y), y.wrapping_add(x));
+}