1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Purpose: Tests the `#[ derive( Former ) ]` macro's generation of a former builder for a named
//! (struct-like) variant (`V1`) within a generic enum (`EnumG4<T>`), where the variant contains
//! a field with a shared generic type (`InnerG4<T>`). This file focuses on verifying the
//! derive-based implementation's handling of shared generics and the generation of appropriate
//! setters in the implicit former.
//!
//! Coverage:
//! - Rule 3g (Struct + Multi-Field + Default): Verifies that for a named variant without specific attributes, the derived constructor is a former builder (`v_1()` returns a former).
//! - Rule 4b (Option 2 Logic): Demonstrates the usage of the former builder's setters (`.inner()`, `.flag()`) and `.form()` method, verifying the subformer mechanism in the context of shared generics.
//!
//! Test Relevance/Acceptance Criteria:
//! - Defines a generic enum `EnumG4<T: BoundA + BoundB>` with a named variant `V1 { inner: InnerG4<T>, flag: bool }`.
//! - Defines the inner struct `InnerG4<T: BoundB>` which also derives `Former`.
//! - Defines dummy bounds (`BoundA`, `BoundB`) and a concrete type (`MyType`) in the included test file.
//! - Applies `#[ derive( Former ) ]` to both `EnumG4` and `InnerG4`.
//! - Includes shared test logic from `generics_shared_struct_only_test.rs`.
//! - The included tests call the derived static method `EnumG4::<MyType>::v_1()`, use the returned former's setters (`.inner()`, `.flag()`), and call `.form()`.
//! - Asserts that the resulting enum instances match manually constructed expected values. This verifies that the derived former builder correctly handles fields with shared generic types and non-generic fields within a generic enum.
// File: module/core/former/tests/inc/former_enum_tests/generics_shared_struct_derive.rs
//! # Derive Test: Shared Generics in Struct Variants
//!
//! This test file focuses on verifying the `#[ derive( Former ) ]` macro's ability to handle
//! enums with struct-like variants where the generic parameter is shared between the enum
//! and a field within the variant.
//! Specifically, it tests an enum `EnumG4<T>` where a variant `V1` contains a field
//! whose type uses the *same* generic parameter `T` (`InnerG4<T>`).
//!
//! ## Purpose:
//!
//! - To ensure the derive macro correctly generates the implicit former infrastructure
//! (storage, definitions, former struct, end struct) for the struct variant `V1`.
//! - To verify that the generated code correctly handles the shared generic parameter `T`
//! and its bounds (`BoundA`, `BoundB`) throughout the generated types and implementations.
//! - To confirm that the generated setters within the implicit former work for fields
//! containing generic types like `InnerG4<T>`.
//! - It uses the shared test logic from `generics_shared_struct_only_test.rs`.
use *; // Imports testing infrastructure and potentially other common items
// --- Dummy Bounds ---
// Defined in _only_test.rs, but repeated here conceptually for clarity
// pub trait BoundA : core::fmt::Debug + Default + Clone + PartialEq {}
// pub trait BoundB : core::fmt::Debug + Default + Clone + PartialEq {}
// --- Inner Struct Definition with Bounds ---
// Needs to derive Former for the enum's derive to work correctly for subforming.
// Added Default and Former
// --- Enum Definition with Bounds ---
// Apply Former derive here. This is what we are testing.
// #[ debug ] // Uncomment to see generated code later
// --- Include the Test Logic ---
// This file contains the actual #[ test ] functions.
include!;
// qqq : xxx : uncomment please