- geom.rs, RS1: the levels and the closed forms in i64, and the 32-bit quotient-remainder identity behind cfg(test, kani) and the i32-forms feature; - cover.rs, RS2-RS6: the row split, the cell split walked left to right with the columns left of the canvas folded into one contribution per row piece, the delta buffer over the fill's canvas-clipped box, the scan, the quantisers and the run's glyph-wise sum; a debug build asserts D_r <= 256 p <= 2^22 - 256 before accumulating; - paint.rs, RS7-RS9: p' = div255(p o), then div255(p' alpha) and source-over; the group pop div255(m o_g) then div255(G k); RGBA8S; - frame.rs: R(P, S, z, r, g), with a run's outlines placed and flattened once per glyph ID; render_request's size_unlisted, rate_unlisted and frame_range. Vectors: flatten (levels and vertices), fills, runs (a set drawn here from formulas), composite (with RGBA8S), motion, clock and slicing, each frame's SHA-256 and each (size, rate)'s clip digest in its expected file and in sha256.json. Co-Authored-By: Claude Opus 5.5 <[email protected]>
52 lines
2.1 KiB
Rust
52 lines
2.1 KiB
Rust
//! `vector-conformance/`: the generator reproduces every committed file, and every
|
|
//! expected file is recomputed from its vector alone.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use wai_vector::vectors::{self, CORPUS};
|
|
use wai_vector::wvg1::SetStore;
|
|
|
|
fn wai() -> PathBuf {
|
|
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("..")
|
|
}
|
|
|
|
#[test]
|
|
fn the_generator_reproduces_the_committed_corpus() {
|
|
let files = vectors::generate().unwrap();
|
|
assert!(files.len() > 500);
|
|
for (rel, bytes) in files {
|
|
let have = std::fs::read(wai().join(&rel)).unwrap_or_else(|e| panic!("{rel}: {e}"));
|
|
assert!(have == bytes, "{rel}: the generator writes other bytes");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn every_expected_file_is_recomputed_from_its_vector() {
|
|
let corpus = wai().join(CORPUS);
|
|
let mut store = SetStore::new();
|
|
let mut sets: Vec<PathBuf> = std::fs::read_dir(corpus.join("sets")).unwrap().flatten().map(|e| e.path()).collect();
|
|
sets.sort();
|
|
for p in sets {
|
|
store.add(std::fs::read(p).unwrap());
|
|
}
|
|
let mut n = 0;
|
|
let mut groups: Vec<PathBuf> = std::fs::read_dir(corpus.join("vectors")).unwrap().flatten().map(|e| e.path()).collect();
|
|
groups.sort();
|
|
for gdir in groups {
|
|
let group = gdir.file_name().unwrap().to_string_lossy().into_owned();
|
|
let mut files: Vec<PathBuf> = std::fs::read_dir(&gdir).unwrap().flatten().map(|e| e.path()).collect();
|
|
files.sort();
|
|
for f in files {
|
|
let name = f.file_stem().unwrap().to_string_lossy().into_owned();
|
|
let ext = f.extension().unwrap().to_string_lossy().into_owned();
|
|
if name == "index" || (ext == "json" && !vectors::INPUT_GROUPS.contains(&group.as_str())) {
|
|
continue;
|
|
}
|
|
let got = vectors::recompute(&group, &ext, &std::fs::read(&f).unwrap(), &mut store).unwrap();
|
|
let exp = std::fs::read_to_string(corpus.join("expected").join(&group).join(format!("{name}.json"))).unwrap();
|
|
assert_eq!(got, exp, "{group}/{name}.{ext}");
|
|
n += 1;
|
|
}
|
|
}
|
|
assert!(n > 250, "{n} vectors");
|
|
}
|