mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 04:08:12 +08:00
Recognize a reducer's IList input level in build
This commit is contained in:
@@ -754,6 +754,18 @@ mod tests {
|
|||||||
assert_eq!(node.output.shape.depth as i8 - subject_depth as i8, 1, "creator level_delta is +1");
|
assert_eq!(node.output.shape.depth as i8 - subject_depth as i8, 1, "creator level_delta is +1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reducer_ilist_input_collapses_a_level() {
|
||||||
|
let mut parsed = parse_node_fn(quote!(category("")), quote!(fn sum(_: impl Ctx, items: IList<f64>) -> f64 { items.into_iter().sum() })).unwrap();
|
||||||
|
parsed.replace_impl_trait_in_input();
|
||||||
|
let node = build(&parsed);
|
||||||
|
// The `IList` input is a depth-1 subject; the scalar output collapses it.
|
||||||
|
let subject = node.inputs.iter().find(|input| input.subject).expect("the reduced input is the subject");
|
||||||
|
assert_eq!(subject.shape.depth, 1);
|
||||||
|
assert_eq!(node.output.shape.depth, 0);
|
||||||
|
assert_eq!(node.output.shape.depth as i8 - subject.shape.depth as i8, -1, "the reducer collapses one level");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn monomorphizations_key_by_generic() {
|
fn monomorphizations_key_by_generic() {
|
||||||
let node = assert_bridge(
|
let node = assert_bridge(
|
||||||
|
|||||||
Reference in New Issue
Block a user