use fp_macros::document_module;
#[document_module(no_validation)]
mod test_no_validation {
pub struct MyType;
impl MyType {
pub fn new() -> Self {
Self
}
#[expect(dead_code, reason = "Test fixture for document_module macro")]
pub fn process<T>(
&self,
_value: T,
) -> T {
_value
}
}
}
#[test]
fn test_no_validation_mode_compiles() {
let _ = test_no_validation::MyType::new();
}
#[document_module(no_validation)]
mod test_impl_type_params {
pub struct MyType<T>(T);
impl<T> MyType<T> {
pub fn new(value: T) -> Self {
Self(value)
}
pub fn get(&self) -> &T {
&self.0
}
}
}
#[test]
fn test_impl_type_params_no_validation() {
let instance = test_impl_type_params::MyType::new(100);
assert_eq!(*instance.get(), 100);
}
#[document_module(no_validation)]
mod test_nested_no_validation {
pub struct Outer;
impl Outer {
pub fn outer_method(&self) {}
}
pub mod inner {
pub struct Inner;
impl Inner {
pub fn inner_method(&self) {}
}
}
}
#[test]
fn test_nested_no_validation_compiles() {
let outer = test_nested_no_validation::Outer;
outer.outer_method();
let inner = test_nested_no_validation::inner::Inner;
inner.inner_method();
}
#[document_module(no_validation)]
mod test_impl_trait_lint_suppressed {
pub struct MyType;
impl MyType {
#[allow(dead_code, reason = "Test fixture exists to exercise document_module macro")]
#[allow_named_generics]
pub fn apply<F: Fn(i32) -> i32>(
f: F,
x: i32,
) -> i32 {
f(x)
}
}
}
#[test]
fn test_impl_trait_lint_suppressed() {
let result = test_impl_trait_lint_suppressed::MyType::apply(|x| x * 2, 5);
assert_eq!(result, 10);
}
#[document_module(no_validation)]
mod test_no_validation_mode_skips_lint {
pub struct MyType;
impl MyType {
#[allow(dead_code, reason = "Test fixture exists to exercise document_module macro")]
pub fn apply<F: Fn(i32) -> i32>(
f: F,
x: i32,
) -> i32 {
f(x)
}
}
}
#[test]
fn test_no_validation_mode_skips_lint() {
let result = test_no_validation_mode_skips_lint::MyType::apply(|x| x + 10, 5);
assert_eq!(result, 15);
}
#[document_module(no_validation)]
mod test_allow_named_generics_stripped {
pub struct MyType;
impl MyType {
#[allow(dead_code, reason = "Test fixture exists to exercise document_module macro")]
#[allow_named_generics]
pub fn transform<F: Fn(i32) -> i32>(
f: F,
x: i32,
) -> i32 {
f(x)
}
}
}
#[test]
fn test_allow_named_generics_stripped() {
let result = test_allow_named_generics_stripped::MyType::transform(|x| x * 3, 4);
assert_eq!(result, 12);
}