Skip to content

Commit

Permalink
Test initialization of dynamic primitive set (#2044)
Browse files Browse the repository at this point in the history
- **Fix**
- **Test initialization of dynamic primitive set**
  • Loading branch information
raviqqe authored Jan 26, 2025
1 parent 9a94ca7 commit 2e9f860
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/minimal/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions native/src/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,38 @@ impl<const N: usize> PrimitiveSet for DynamicPrimitiveSet<'_, '_, N> {
Ok(())
}
}

#[cfg(test)]
mod tests {
use super::*;
use any_fn::{r#fn, Ref};

struct Foo {
bar: usize,
}

impl Foo {
fn new(bar: usize) -> Self {
Self { bar }
}

fn bar(&self) -> usize {
self.bar
}

fn baz(&mut self, value: usize) {
self.bar += value;
}
}

#[test]
fn create() {
let mut functions = [
r#fn(Foo::new),
r#fn::<(Ref<_>,), _>(Foo::bar),
r#fn(Foo::baz),
];

DynamicPrimitiveSet::<0>::new(&mut functions);
}
}

0 comments on commit 2e9f860

Please sign in to comment.