#[macro_use] extern crate pretty_assertions; use hotg_rune_proc_blocks::{ Dimension, Dimensions, ProcBlock, ProcBlockDescriptor, TensorDescriptor, Transform, TransformDescriptor, }; use std::marker::PhantomData; use hotg_rune_core::{Tensor, ElementType}; /// A dummy proc block. /// /// Can it handle multiple lines of input? #[derive(hotg_rune_proc_block_macros::ProcBlock, Default, PartialEq)] #[transform(inputs = [f32; 3], outputs = u8)] #[transform(inputs = [u8; _], outputs = [f32; 1])] struct Foo { /// Some parameter. a: u32, #[proc_block(skip)] skipped: Vec, } impl Transform> for Foo { type Output = Tensor; fn transform(&mut self, _: Tensor) -> Self::Output { unimplemented!() } } impl Transform> for Foo { type Output = Tensor; fn transform(&mut self, _: Tensor) -> Self::Output { unimplemented!() } } #[derive(ProcBlock)] struct Generic { #[proc_block(skip)] _output_type: PhantomData, } impl Default for Generic { fn default() -> Self { Generic { _output_type: PhantomData, } } } #[test] fn generate_expected_descriptor() { let should_be = ProcBlockDescriptor { type_name: "Foo".into(), description: "A dummy proc block.\n\nCan it handle multiple lines of input?" .into(), available_transforms: vec![ TransformDescriptor { inputs: TensorDescriptor { element_type: ElementType::F32, dimensions: vec![Dimension::Any; 3].into(), } .into(), outputs: TensorDescriptor { element_type: ElementType::U8, dimensions: vec![Dimension::Value(1)].into(), } .into(), }, TransformDescriptor { inputs: TensorDescriptor { element_type: ElementType::U8, dimensions: Dimensions::Arbitrary, } .into(), outputs: TensorDescriptor { element_type: ElementType::F32, dimensions: vec![Dimension::Any].into(), } .into(), }, ] .into(), }; let got = ::DESCRIPTOR; assert_eq!(got, should_be); }