mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 12:32:10 +01:00
* Extract the material graph runtime from TextureCraft Preserve its evaluator, compiler, existing verification, and format reference from TextureCraft #777 at 22a37c29. Original TextureCraft importer author: xilefenko (TextureCraft #521). * Adapt graph helpers to the shared workspace lints Preserve node evaluation and version tracking while splitting long dispatch branches. Update the EXR doctest and rule table references for the shared crate. * Read the format reference with LF endings in its test * Test that the format reference example reads the same with CRLF line endings * Make the kind versions follow module attributes, arm order, raw strings, includes and the epoch * Fix graph cache keys, publish, import and subgraph extraction; harden the graph tests * Keep the cubic sampler from panicking on NaN texels; say what RGBE drops; check NaN halves by their bits * Lower vector inputs of f_to_bool and f_vec to valid WGSL; tighten the FX-map error and pattern coverage tests; document clamping and the splatter data cutoff * Say which composite glyph placements the font reader lacks; fail the y-up text test on a blank render * Leave publish as it was; unit-test the WGSL vector lowering; document EPOCH and keep_outputs results * Satisfy clippy in the version scanner and the WGSL lowering; compare cache hits by relation
48 lines
1.7 KiB
Rust
48 lines
1.7 KiB
Rust
//! The format reference's example parses and renders and its tables list every node kind.
|
|
|
|
use craft_material_graph::graph::{self, Graph};
|
|
|
|
const RAW_DOC: &str = include_str!("../../docs/format.md");
|
|
|
|
/// The reference as LF text: a Windows checkout may convert its line endings.
|
|
fn lf(text: &str) -> String {
|
|
text.replace("\r\n", "\n")
|
|
}
|
|
|
|
/// The first ```text block of the reference.
|
|
fn example(raw: &str) -> String {
|
|
let doc = lf(raw);
|
|
let start = doc.find("```text\n").expect("an example") + "```text\n".len();
|
|
let len = doc.get(start..).and_then(|r| r.find("```")).expect("the example ends");
|
|
doc[start..start + len].to_string()
|
|
}
|
|
|
|
#[test]
|
|
fn the_example_renders() {
|
|
let g = Graph::parse(&example(RAW_DOC)).expect("the example parses");
|
|
assert_eq!(g.format, graph::FORMAT_VERSION);
|
|
let out = g.evaluate(Some(16)).expect("the example renders");
|
|
assert!(out.contains_key("height"));
|
|
}
|
|
|
|
/// A Windows checkout has CRLF line endings; the example must read the same there.
|
|
#[test]
|
|
fn the_example_reads_the_same_with_crlf_line_endings() {
|
|
let crlf = lf(RAW_DOC).replace('\n', "\r\n");
|
|
assert_eq!(example(&crlf), example(RAW_DOC));
|
|
}
|
|
|
|
#[test]
|
|
fn every_node_kind_is_listed() {
|
|
let doc = lf(RAW_DOC);
|
|
let all = graph::SPECS
|
|
.iter()
|
|
.chain(craft_material_graph::compiled_ops::SPECS)
|
|
.chain(craft_material_graph::atomic::SPECS)
|
|
.chain(craft_material_graph::func::FUNC_SPECS)
|
|
.chain(craft_material_graph::fxmap::FXM_SPECS)
|
|
.chain(craft_material_graph::patterns::SPECS);
|
|
let missing: Vec<&str> = all.map(|s| s.kind).filter(|k| !doc.contains(&format!("| `{k}` |"))).collect();
|
|
assert!(missing.is_empty(), "docs/format.md does not list {missing:?}");
|
|
}
|