Skip to content

Commit

Permalink
test: add new tests for const global vars and generic params
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiPashkin committed Jan 27, 2025
1 parent 91cfc4a commit ad14645
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/compile/const_var_compose.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use compose_idents::compose_idents;

compose_idents!(my_var = [foo, _, var]; {
const my_var: u32 = 42;
});

fn main() {
assert_eq!(foo_var, 42);
}
11 changes: 11 additions & 0 deletions tests/compile/generic_param_compose.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use compose_idents::compose_idents;

compose_idents!(DATA_LEN = [FOO, _, BAR]; {
fn my_fn<T, const DATA_LEN: usize>(_data: &[T; DATA_LEN]) -> usize {
DATA_LEN
}
});

fn main() {
assert_eq!(my_fn(&[1, 2, 3]), 3);
}
2 changes: 2 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ fn compile_tests() {
t.pass("tests/compile/simple_compose.rs");
t.pass("tests/compile/nested_compose.rs");
t.pass("tests/compile/multi_compose.rs");
t.pass("tests/compile/const_var_compose.rs");
t.pass("tests/compile/generic_param_compose.rs");
}

0 comments on commit ad14645

Please sign in to comment.