mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Lower a creator's IList return to a level-pushing record
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
//! wiring is by hand until the compiler pass constructs layouts.
|
||||
|
||||
use core_types::attribute::{Attr, Opacity, RemoveAttr};
|
||||
use core_types::context::ExtractArena;
|
||||
use core_types::context::{ExtractArena, ExtractIndex};
|
||||
use core_types::gpoll::{ErrorKind, GraphError, Interrupt};
|
||||
use core_types::{Context, Ctx};
|
||||
|
||||
@@ -50,6 +50,14 @@ fn fade<T>(_: impl Ctx, (element, opacity): (T, Attr<Opacity>), factor: f64) ->
|
||||
(element, Attr(*opacity * factor))
|
||||
}
|
||||
|
||||
/// Test-only structure creator: the `IList` return pushes one rank level and
|
||||
/// writes a per-copy opacity indexed by the copy's own index.
|
||||
#[node_macro::node(category("Test"))]
|
||||
fn repeat_opacity(ctx: impl Ctx + ExtractIndex, element: f64, count: u32) -> IList<(f64, Attr<Opacity>)> {
|
||||
let _ = count;
|
||||
emit(element, Attr(ctx.innermost_index() as f64))
|
||||
}
|
||||
|
||||
#[node_macro::node(category("Test"))]
|
||||
fn source_opacity(_: impl Ctx, _: (), element: f64, opacity: f64) -> (f64, Attr<Opacity>) {
|
||||
(element, Attr(opacity))
|
||||
@@ -221,6 +229,14 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn creator_pushes_a_rank_level() {
|
||||
let base = f64_layout(&[]);
|
||||
let leveled = repeat_opacity_layout(&base);
|
||||
assert_eq!(leveled.depth, 1, "the IList return pushed one rank level above the depth-0 carrier");
|
||||
assert_eq!(repeat_opacity_layout_meta().fold(&[Some(&base)]), leveled, "the level_delta metadata folds to the same leveled layout");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layout_meta_folds_to_construction() {
|
||||
let base = f64_layout(&[]);
|
||||
|
||||
Reference in New Issue
Block a user