Skip to content

Commit 97d0a79

Browse files
committed
docs(former): Add purpose and coverage to basic unnamed enum tests
1 parent d280ef4 commit 97d0a79

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

module/core/former/plan.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,21 @@ This section shows an example of the documentation comments that will be added t
259259
---
260260
**Phase 2: Unnamed/Tuple Variant Tests (`enum_unnamed_tests`)**
261261

262-
* [] **Increment 8:** Document `basic_*` files
262+
* [] **Increment 8:** Document `basic_*` files
263+
* Detailed Plan Step 1: Read the content of the target files to perform pre-analysis.
264+
* Detailed Plan Step 2: Perform pre-analysis based on file content and plan rules.
265+
* Detailed Plan Step 3: Draft the `//!` comments (Purpose, Coverage, Test Relevance/Acceptance Criteria) for each target file based on pre-analysis and plan requirements.
266+
* Detailed Plan Step 4: Apply the drafted comments to the target files using `write_to_file`.
267+
* Detailed Plan Step 5: Request user to run verification command.
268+
* Pre-Analysis:
269+
* Identified enum variant structures in target file(s): Single-field tuple variants (`Break(Break)`, `Run(Run)`).
270+
* Key attributes present: `#[derive(Former)]`, `#[standalone_constructors]` on the enum; `#[subform_scalar]` on the `Break` variant.
271+
* Relevant "Expected Enum Former Behavior Rule IDs": 3d, 2d, 4a, 4b. Rule 1d is not applicable to this test case.
272+
* Brief summary of how test functions appear to exercise these rules: `basic_only_test.rs` contains tests that call the static methods (`FunctionStep::r#break()`, `FunctionStep::run()`) and the standalone constructor (`FunctionStep::break_variant()`). These tests then use the returned subformers to set fields and call `.form()`, asserting the final enum instance matches the expected value.
273+
* 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.
274+
* Relevant Behavior Rules: Rule 3d (Tuple + Default -> Subform), Rule 2d (Tuple + `#[subform_scalar]` -> InnerFormer), Rule 4a (#[standalone_constructors]), Rule 4b (Option 2 Logic).
275+
* Verification Strategy: After comments are added, request user to run `cargo check --package former --tests`. The code must compile without errors.
276+
* Test Matrix: N/A
263277
* Enum Aspect Focus: Unnamed/Tuple (basic single-field subform)
264278
* Target File(s):
265279
* `module/core/former/tests/inc/enum_unnamed_tests/basic_derive.rs`
@@ -413,7 +427,7 @@ This section shows an example of the documentation comments that will be added t
413427
* What is the nature of the primary assertion (e.g., "Asserts the `got` instance (produced by the former) is equal to an `expected` instance (manually constructed to represent the correct state).", "Asserts that a subformer is returned and can be used to set inner fields.", "Asserts that a compile-time error occurs for an invalid attribute combination using `trybuild`.").
414428
* **For `_derive.rs` files:** Mention that it relies on `#[derive(Former)]` for code generation and typically includes shared test logic via `include!("...")`.
415429
* **For `_manual.rs` files:** Mention that it contains a hand-written former implementation and includes shared test logic via `include!("...")`.
416-
* **For `compile_fail/*.rs` files:** The file contains code that intentionally uses an attribute or enum structure in a way that violates a documented behavior rule (e.e., `#[subform_scalar]` on a unit variant). The test is accepted if `trybuild` confirms this results in a compilation error, thereby validating the macro's error reporting for this specific invalid scenario."
430+
* **For `compile_fail/*.rs` files:** The file contains code that intentionally uses an attribute or enum structure in a way that violates a documented behavior rule (i.e., `#[subform_scalar]` on a unit variant). The test is accepted if `trybuild` confirms this results in a compilation error, thereby validating the macro's error reporting for this specific invalid scenario."
417431
* **Comment Style:** All added `//!` comments should be clear, concise, grammatically correct, and follow Rust documentation comment conventions. Use Markdown for lists or emphasis if it enhances readability. Aim for reasonable line lengths.
418432
* **Pre-Analysis Output:** Before proposing comments for an increment, the AI must provide its pre-analysis findings for the targeted file(s) as specified in the "Increment Template".
419433
* **Incremental Processing:** Modify files one increment at a time, following the "Increment Template."
@@ -438,3 +452,4 @@ This section shows an example of the documentation comments that will be added t
438452
* **[2025-05-10/Inc 5] Note:** Started detailed planning for Increment 5: Document `standalone_constructor_unit_*` files. Pre-analysis complete. Proceeding to draft and apply comments. Successfully applied comments and verified compilation with `cargo check --package former --tests`. Increment 5 complete.
439453
* **[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.
440454
* **[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.
455+
* **[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.

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
//! Purpose: Tests the `#[derive(Former)]` macro's generation of constructors for unnamed (tuple)
2-
//! variants, including with `#[subform_scalar]` and `#[standalone_constructors]`. This file
3-
//! focuses on verifying the derive-based implementation.
2+
//! variants that return subformers, including with `#[subform_scalar]` and `#[standalone_constructors]`.
3+
//! This file focuses on verifying the derive-based implementation.
44
//!
55
//! Coverage:
6-
//! - Rule 3d (Tuple + Default -> Subform): Verifies `FunctionStep::run() -> RunFormer`.
7-
//! - Rule 1d (Tuple + `#[scalar]` -> Scalar): Not explicitly tested in this file's enum definition.
8-
//! - Rule 2d (Tuple + `#[subform_scalar]` -> InnerFormer): Verifies `FunctionStep::r#break() -> BreakFormer`.
6+
//! - Rule 3d (Tuple + Default -> Subform): Tests static method `FunctionStep::run()`.
7+
//! - Rule 2d (Tuple + `#[subform_scalar]` -> InnerFormer): Tests static method `FunctionStep::r#break()`.
98
//! - Rule 4a (#[standalone_constructors]): Verifies generation of top-level constructor functions.
109
//! - Rule 4b (Option 2 Logic): Implicitly covered by the standalone constructor returning a subformer.
1110
//!
@@ -16,7 +15,6 @@
1615
//! standalone constructor (`FunctionStep::break_variant()`) defined in `basic_only_test.rs`.
1716
//! - Asserts that these constructors return the expected subformers and that using the subformers
1817
//! to set fields and call `.form()` results in the correct `FunctionStep` enum instances.
19-
// File: module/core/former/tests/inc/former_enum_tests/basic_derive.rs
2018
2119
use super::*;
2220

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//!
55
//! Coverage:
66
//! - Rule 3d (Tuple + Default -> Subform): Manual implementation of static method `FunctionStep::run()`.
7-
//! - Rule 1d (Tuple + `#[scalar]` -> Scalar): Not applicable to the variants in this file.
87
//! - Rule 2d (Tuple + `#[subform_scalar]` -> InnerFormer): Manual implementation of static method `FunctionStep::r#break()`.
98
//! - Rule 4a (#[standalone_constructors]): Manual implementation of the standalone subformer starter `break_variant()`.
109
//! - Rule 4b (Option 2 Logic): Manual implementation of `FormingEnd` for the variant end types.
@@ -16,7 +15,6 @@
1615
//! - Manually implements `FormingEnd` for the end types associated with the variant subformers.
1716
//! - This file is included by `basic_only_test.rs` to provide the manual implementations that
1817
//! the shared tests compare against.
19-
// File: module/core/former/tests/inc/former_enum_tests/basic_derive.rs
2018
2119
use super::*;
2220
use former::StoragePreform;

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
// Purpose: Provides shared test assertions and logic for verifying the constructors generated
2-
// by `#[derive(Former)]` for enums with unnamed (tuple) variants that return subformers.
3-
// This file is included by both `basic_derive.rs` and `basic_manual.rs`.
4-
//
5-
// Coverage:
6-
// - Rule 3d (Tuple + Default -> Subform): Tests static method `FunctionStep::run()`.
7-
// - Rule 2d (Tuple + `#[subform_scalar]` -> InnerFormer): Tests static method `FunctionStep::r#break()`.
8-
// - Rule 4a (#[standalone_constructors]): Tests the standalone subformer starter `FunctionStep::break_variant()`.
9-
// - Rule 4b (Option 2 Logic): Tests the use of subformer methods and `.form()`.
10-
//
11-
// Test Relevance/Acceptance Criteria:
12-
// - Defines test functions (`build_break_variant_static`, `build_run_variant_static`, `standalone_break_variant`)
13-
// that invoke constructors provided by the including file (either derived or manual).
14-
// - These constructors return subformers (`BreakFormer`, `RunFormer`).
15-
// - The tests use the subformer methods (`.condition()`, `.command()`) to set fields and call `.form()`
16-
// to finalize the construction.
17-
// - Asserts that the resulting `FunctionStep` enum instances are equal to the expected variants
18-
// (`FunctionStep::Break(...)`, `FunctionStep::Run(...)`).
1+
//! Purpose: Provides shared test assertions and logic for verifying the constructors generated
2+
//! by `#[derive(Former)]` for enums with unnamed (tuple) variants that return subformers.
3+
//! This file is included by both `basic_derive.rs` and `basic_manual.rs`.
4+
//!
5+
//! Coverage:
6+
//! - Rule 3d (Tuple + Default -> Subform): Tests static method `FunctionStep::run()`.
7+
//! - Rule 2d (Tuple + `#[subform_scalar]` -> InnerFormer): Tests static method `FunctionStep::r#break()`.
8+
//! - Rule 4a (#[standalone_constructors]): Tests the standalone subformer starter `FunctionStep::break_variant()`.
9+
//! - Rule 4b (Option 2 Logic): Tests the use of subformer methods and `.form()`.
10+
//!
11+
//! Test Relevance/Acceptance Criteria:
12+
//! - Defines test functions (`build_break_variant_static`, `build_run_variant_static`, `standalone_break_variant`)
13+
//! that invoke constructors provided by the including file (either derived or manual).
14+
//! - These constructors return subformers (`BreakFormer`, `RunFormer`).
15+
//! - The tests use the subformer methods (`.condition()`, `.command()`) to set fields and call `.form()`
16+
//! to finalize the construction.
17+
//! - Asserts that the resulting `FunctionStep` enum instances are equal to the expected variants
18+
//! (`FunctionStep::Break(...)`, `FunctionStep::Run(...)`).
19+
1920
#[ test ]
2021
fn build_break_variant_static() // Test name kept for clarity, could be renamed
2122
{

0 commit comments

Comments
 (0)