Thing contract, C#: GameCult.Thing.Contract (thing2 cut 1b) (#5)
All checks were successful
Portable Eve contracts and browser lowering / ubuntu-latest eve-browser-lowering (push) Successful in 6m56s
Portable Eve contracts and browser lowering / ubuntu-latest eve-contracts (push) Successful in 3m20s

This commit is contained in:
Eureka 2026-11-27 17:54:25 +00:00
commit 7654e27364
34 changed files with 6773 additions and 22 deletions

View file

@ -3,8 +3,29 @@
#![allow(dead_code)]
use std::path::PathBuf;
use thing_contract::*;
pub fn goldens_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/goldens")
}
pub fn blessing() -> bool {
std::env::var("THING_BLESS").as_deref() == Ok("1")
}
/// Bless the file or compare against it. Returns the committed bytes.
pub fn golden_bytes(file: &str, produced: &[u8]) -> Vec<u8> {
let path = goldens_dir().join(file);
if blessing() {
std::fs::write(&path, produced).unwrap_or_else(|error| panic!("{file}: {error}"));
}
let committed = std::fs::read(&path).unwrap_or_else(|error| panic!("{file}: {error}"));
assert_eq!(committed, produced, "{file}: the committed golden differs from what the crate writes");
committed
}
pub fn seq(value: i32) -> Seq {
Seq::new(value).unwrap()
}