use macro_tools ::generic_params;
use quote ::quote;
use syn ::parse_quote;
#[ test ]
fn test_trailing_comma_issue_mre()
{
let generics: syn ::Generics = parse_quote! { < 'a > };
let (_, impl_gen, ty_gen, _) = generic_params ::decompose(&generics);
let impl_code = quote! { impl< #impl_gen > MyTrait for MyStruct };
let type_code = quote! { MyStruct< #ty_gen > };
println!("Test 1 - Single lifetime: ");
println!(" impl_gen: {}", quote! { #impl_gen });
println!(" ty_gen: {}", quote! { #ty_gen });
println!(" Generated impl: {impl_code}");
println!(" Generated type: {type_code}");
assert!(!impl_gen.trailing_punct(), "impl_gen should not have trailing comma");
assert!(!ty_gen.trailing_punct(), "ty_gen should not have trailing comma");
let generics: syn ::Generics = parse_quote! { < 'a, T: Clone, const N: usize > };
let (_, impl_gen, ty_gen, _) = generic_params ::decompose(&generics);
let impl_code = quote! { impl< #impl_gen > MyTrait for MyStruct };
let type_code = quote! { MyStruct< #ty_gen > };
println!("\nTest 2 - Multiple parameters: ");
println!(" impl_gen: {}", quote! { #impl_gen });
println!(" ty_gen: {}", quote! { #ty_gen });
println!(" Generated impl: {impl_code}");
println!(" Generated type: {type_code}");
assert!(!impl_gen.trailing_punct(), "impl_gen should not have trailing comma");
assert!(!ty_gen.trailing_punct(), "ty_gen should not have trailing comma");
let generics: syn ::Generics = parse_quote! { };
let (_, impl_gen, ty_gen, _) = generic_params ::decompose(&generics);
println!("\nTest 3 - Empty generics: ");
println!(" impl_gen is empty: {}", impl_gen.is_empty());
println!(" ty_gen is empty: {}", ty_gen.is_empty());
let generics: syn ::Generics = parse_quote! { < T > };
let (_, impl_gen, ty_gen, _) = generic_params ::decompose(&generics);
let impl_code = quote! { impl< #impl_gen > MyTrait for MyStruct };
let type_code = quote! { MyStruct< #ty_gen > };
println!("\nTest 4 - Single type parameter: ");
println!(" impl_gen: {}", quote! { #impl_gen });
println!(" ty_gen: {}", quote! { #ty_gen });
println!(" Generated impl: {impl_code}");
println!(" Generated type: {type_code}");
assert!(!impl_gen.trailing_punct(), "impl_gen should not have trailing comma");
assert!(!ty_gen.trailing_punct(), "ty_gen should not have trailing comma");
}