Skip to content

Commit 09f577f

Browse files
committed
docs(former): Add purpose and coverage to enum_named_fields_unnamed tests
1 parent 97d0a79 commit 09f577f

File tree

4 files changed

+86
-20
lines changed

4 files changed

+86
-20
lines changed

module/core/former/plan.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,39 @@ This section shows an example of the documentation comments that will be added t
281281
* `module/core/former/tests/inc/enum_unnamed_tests/basic_only_test.rs`
282282
* Commit Message: `docs(former): Add purpose and coverage to basic unnamed enum tests`
283283

284-
* [] **Increment 9:** Document `enum_named_fields_unnamed_*` files
284+
* [] **Increment 9:** Document `enum_named_fields_unnamed_*` files
285+
* Detailed Plan Step 1: Read the content of the target files to perform pre-analysis.
286+
* Detailed Plan Step 2: Perform pre-analysis based on file content and plan rules.
287+
* Detailed Plan Step 3: Draft the `//!` comments (Purpose, Coverage, Test Relevance/Acceptance Criteria) for each target file based on pre-analysis and plan requirements.
288+
* Detailed Plan Step 4: Apply the drafted comments to the target files using `write_to_file`.
289+
* Detailed Plan Step 5: Request user to run verification command.
290+
* Pre-Analysis:
291+
* Identified enum variant structures in target file(s): Zero-field unnamed (tuple) variants (`VariantZeroUnnamedDefault()`, `VariantZeroUnnamedScalar()`).
292+
* Key attributes present: `#[derive(Former)]`, `#[debug]`, `#[standalone_constructors]` on the enum; `#[scalar]` on the `VariantZeroUnnamedScalar` variant.
293+
* Relevant "Expected Enum Former Behavior Rule IDs": 3b, 1b, 4a. Rule 4a is applicable due to the enum attribute but not explicitly tested in the provided test file.
294+
* Brief summary of how test functions appear to exercise these rules: `enum_named_fields_unnamed_only_test.rs` contains tests that call the static methods (`EnumWithNamedFields::variant_zero_unnamed_scalar()`, `EnumWithNamedFields::variant_zero_unnamed_default()`) and assert that the returned value is the direct enum variant.
295+
* Crucial Design Rules: Comments and Documentation, Comments: Spaces, Comments: Focus on Rationale, Preserve Existing Tasks, Comments: Add Tasks and Label Simplifications, Comments: Annotate Addressed Tasks, Structuring: Proc Macro Development Workflow.
296+
* Relevant Behavior Rules: Rule 3b (Tuple + Zero-Field + Default), Rule 1b (Tuple + Zero-Field + `#[scalar]`), Rule 4a (#[standalone_constructors]).
297+
* Verification Strategy: After comments are added, request user to run `cargo check --package former --tests`. The code must compile without errors.
298+
* Test Matrix: N/A
285299
* Enum Aspect Focus: Unnamed/Tuple (zero-field tuple variants)
286300
* Target File(s):
287301
* `module/core/former/tests/inc/enum_unnamed_tests/enum_named_fields_unnamed_derive.rs`
288302
* `module/core/former/tests/inc/enum_unnamed_tests/enum_named_fields_unnamed_manual.rs`
289303
* `module/core/former/tests/inc/enum_unnamed_tests/enum_named_fields_unnamed_only_test.rs`
290304
* Commit Message: `docs(former): Add purpose and coverage to enum_named_fields_unnamed tests`
291305

292-
* [] **Increment 10:** Document `generics_independent_tuple_*` files
306+
* [] **Increment 10:** Document `generics_independent_tuple_*` files
307+
* Detailed Plan Step 1: Read the content of the target files to perform pre-analysis.
308+
* Detailed Plan Step 2: Perform pre-analysis based on file content and plan rules.
309+
* Detailed Plan Step 3: Draft the `//!` comments (Purpose, Coverage, Test Relevance/Acceptance Criteria) for each target file based on pre-analysis and plan requirements.
310+
* Detailed Plan Step 4: Apply the drafted comments to the target files using `write_to_file`.
311+
* Detailed Plan Step 5: Request user to run verification command.
312+
* Pre-Analysis: (To be filled after reading files)
313+
* Crucial Design Rules: Comments and Documentation, Comments: Spaces, Comments: Focus on Rationale, Preserve Existing Tasks, Comments: Add Tasks and Label Simplifications, Comments: Annotate Addressed Tasks, Structuring: Proc Macro Development Workflow.
314+
* Relevant Behavior Rules: (To be filled after pre-analysis)
315+
* Verification Strategy: After comments are added, request user to run `cargo check --package former --tests`. The code must compile without errors.
316+
* Test Matrix: N/A
293317
* Enum Aspect Focus: Unnamed/Tuple (single-field tuple with independent generics, `#[scalar]`)
294318
* Target File(s):
295319
* `module/core/former/tests/inc/enum_unnamed_tests/generics_independent_tuple_derive.rs`
@@ -453,3 +477,4 @@ This section shows an example of the documentation comments that will be added t
453477
* **[2025-05-10/Inc 6] Note:** Started detailed planning for Increment 6: Document `standalone_constructor_args_unit_*` files. Pre-analysis complete. Proceeding to draft and apply comments. Successfully applied comments and verified compilation with `cargo check --package former --tests`. Increment 6 complete.
454478
* **[2025-05-10/Inc 7] Note:** Started detailed planning for Increment 7: Document `compile_fail/unit_subform_scalar_error.rs`. Pre-analysis complete. Proceeding to draft and apply comments. Successfully applied comments and verified compilation with `cargo check --package former --tests`. Increment 7 complete.
455479
* **[2025-05-10/Inc 8] Note:** Started detailed planning for Increment 8: Document `basic_*` files. Pre-analysis complete. Proceeding to draft and apply comments. Successfully applied comments and verified compilation with `cargo check --package former --tests`. Increment 8 complete.
480+
* **[2025-05-10/Inc 9] Note:** Started detailed planning for Increment 9: Document `enum_named_fields_unnamed_*` files. Pre-analysis complete. Proceeding to draft and apply comments. Successfully applied comments and verified compilation with `cargo check --package former --tests`. Increment 9 complete.

module/core/former/tests/inc/enum_unnamed_tests/enum_named_fields_unnamed_derive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//! This file focuses on verifying the derive-based implementation.
44
//!
55
//! Coverage:
6-
//! - Rule 3b (Tuple + Zero-Field + Default): Verifies `EnumWithNamedFields::variant_zero_unnamed_default() -> EnumWithNamedFields`.
7-
//! - Rule 1b (Tuple + Zero-Field + `#[scalar]`): Verifies `EnumWithNamedFields::variant_zero_unnamed_scalar() -> EnumWithNamedFields`.
6+
//! - Rule 3b (Tuple + Zero-Field + Default): Tests static method `EnumWithNamedFields::variant_zero_unnamed_default()`.
7+
//! - Rule 1b (Tuple + Zero-Field + `#[scalar]`): Tests static method `EnumWithNamedFields::variant_zero_unnamed_scalar()`.
88
//! - Rule 4a (#[standalone_constructors]): Verifies generation of top-level constructor functions (though not explicitly tested in `_only_test.rs`).
99
//!
1010
//! Test Relevance/Acceptance Criteria:
@@ -14,7 +14,7 @@
1414
//! defined in `enum_named_fields_unnamed_only_test.rs`.
1515
//! - Asserts that these constructors produce the correct `EnumWithNamedFields` enum instances by comparing
1616
//! with manually constructed variants.
17-
// File: module/core/former/tests/inc/former_enum_tests/unnamed_tests/enum_named_fields_unnamed_derive.rs
17+
1818
use super::*;
1919

2020
// Define the enum with zero-field unnamed (tuple) variants for testing.

module/core/former/tests/inc/enum_unnamed_tests/enum_named_fields_unnamed_manual.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,47 @@ impl EnumWithNamedFields
4040
pub fn variant_zero_unnamed_default() -> Self { Self::VariantZeroUnnamedDefault() } // New (Default is scalar)
4141
}
4242

43+
// --- FormingEnd Implementations for End Structs ---
44+
45+
// End for Break variant
46+
impl former::FormingEnd
47+
<
48+
BreakFormerDefinitionTypes< (), FunctionStep > // Context is (), Formed is FunctionStep
49+
>
50+
for FunctionStepBreakEnd
51+
{
52+
#[ inline( always ) ]
53+
fn call
54+
(
55+
&self,
56+
sub_storage : BreakFormerStorage, // Storage of the inner type (Break)
57+
_context : Option< () >, // Context is () from ::begin
58+
) -> FunctionStep // Returns the Enum type
59+
{
60+
let data = sub_storage.preform(); // Get the Break data
61+
FunctionStep::Break( data ) // Construct the enum variant
62+
}
63+
}
64+
65+
// End for Run variant
66+
impl former::FormingEnd
67+
<
68+
RunFormerDefinitionTypes< (), FunctionStep > // Context is (), Formed is FunctionStep
69+
>
70+
for FunctionStepRunEnd
71+
{
72+
#[ inline( always ) ]
73+
fn call
74+
(
75+
&self,
76+
sub_storage : RunFormerStorage, // Storage of the inner type (Run)
77+
_context : Option< () >, // Context is () from ::begin
78+
) -> FunctionStep // Returns the Enum type
79+
{
80+
let data = sub_storage.preform(); // Get the Run data
81+
FunctionStep::Run( data ) // Construct the enum variant
82+
}
83+
}
84+
4385
// Include the test logic file
4486
include!( "enum_named_fields_unnamed_only_test.rs" );

module/core/former/tests/inc/enum_unnamed_tests/enum_named_fields_unnamed_only_test.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
// Purpose: Provides shared test assertions and logic for verifying the constructors generated
2-
// by `#[derive(Former)]` for enums with zero-field unnamed (tuple) variants using named fields syntax.
3-
// This file is included by both `enum_named_fields_unnamed_derive.rs` and `enum_named_fields_unnamed_manual.rs`.
4-
//
5-
// Coverage:
6-
// - Rule 3b (Tuple + Zero-Field + Default): Tests static method `EnumWithNamedFields::variant_zero_unnamed_default()`.
7-
// - Rule 1b (Tuple + Zero-Field + `#[scalar]`): Tests static method `EnumWithNamedFields::variant_zero_unnamed_scalar()`.
8-
//
9-
// Test Relevance/Acceptance Criteria:
10-
// - Defines test functions (`variant_zero_unnamed_scalar_test`, `variant_zero_unnamed_default_test`) that
11-
// invoke static methods provided by the including file (either derived or manual).
12-
// - Asserts that the instances created by these constructors are equal to the expected
13-
// enum variants (`EnumWithNamedFields::VariantZeroUnnamedScalar()`, `EnumWithNamedFields::VariantZeroUnnamedDefault()`).
14-
//
15-
// File: module/core/former/tests/inc/former_enum_tests/unnamed_tests/enum_named_fields_unnamed_only_test.rs
1+
//! Purpose: Provides shared test assertions and logic for verifying the constructors generated
2+
//! by `#[derive(Former)]` for enums with zero-field unnamed (tuple) variants using named fields syntax.
3+
//! This file is included by both `enum_named_fields_unnamed_derive.rs` and `enum_named_fields_unnamed_manual.rs`.
4+
//!
5+
//! Coverage:
6+
//! - Rule 3b (Tuple + Zero-Field + Default): Tests static method `EnumWithNamedFields::variant_zero_unnamed_default()`.
7+
//! - Rule 1b (Tuple + Zero-Field + `#[scalar]`): Tests static method `EnumWithNamedFields::variant_zero_unnamed_scalar()`.
8+
//!
9+
//! Test Relevance/Acceptance Criteria:
10+
//! - Defines test functions (`variant_zero_unnamed_scalar_test`, `variant_zero_unnamed_default_test`) that
11+
//! invoke static methods provided by the including file (either derived or manual).
12+
//! - Asserts that the instances created by these constructors are equal to the expected
13+
//! enum variants (`EnumWithNamedFields::VariantZeroUnnamedScalar()`, `EnumWithNamedFields::VariantZeroUnnamedDefault()`).
14+
1615
use super::*; // Imports EnumWithNamedFields
1716

1817
// --- Zero Fields (Unnamed) ---

0 commit comments

Comments
 (0)