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
// Purpose: Provides shared test assertions and logic for verifying the constructors generated
// by `#[ derive( Former ) ]` for enums with unit variants, including with `#[ standalone_constructors ]`.
// This file is included by both `unit_variant_derive.rs` and `unit_variant_manual.rs`.
//
// Coverage:
// - Rule 3a (Unit + Default): Tests static methods `Status::pending()` and `Status::complete()`.
// - Rule 1a (Unit + `#[ scalar ]`): Tests static methods (as default for unit is scalar).
// - Rule 4a (#[ standalone_constructors ]): Tests standalone functions `pending()` and `complete()`.
//
// Test Relevance/Acceptance Criteria:
// - Defines test functions (`unit_variant_constructors`, `unit_variant_standalone_constructors`) that
// invoke constructors provided by the including file (either derived or manual).
// - Asserts that the instances created by these constructors are equal to the expected
// enum variants (`Status::Pending`, `Status::Complete`).
//
// # Test Matrix for Unit Variants
//
// This matrix outlines the combinations of `former` attributes tested for enum **unit variants**
// and the expected behavior of the generated constructors.
//
// Factors considered:
// 1. **Variant-Level Attribute:** None (Default behavior), `#[ scalar ]`, `#[ subform_scalar ]` (Expected: Error)
// 2. **Enum-Level Attribute:** None, `#[ standalone_constructors ]`
//
// | # | Variant Attribute | Enum Attribute | Expected Constructor Signature (Static Method on Enum) | Expected Standalone Constructor (if `#[ standalone_constructors ]`) | Relevant Rule(s) | Handler File (Meta) |
// |---|-------------------|-----------------------------|------------------------------------------------------|--------------------------------------------------------------------|------------------|----------------------------|
// | 1 | Default | None | `MyEnum::my_unit_variant() -> MyEnum` | N/A | 3a | `unit_variant_handler.rs` |
// | 2 | `#[ scalar ]` | None | `MyEnum::my_unit_variant() -> MyEnum` | N/A | 1a | `unit_variant_handler.rs` |
// | 3 | Default | `#[ standalone_constructors ]` | `MyEnum::my_unit_variant() -> MyEnum` | `fn my_unit_variant() -> MyEnum` | 3a, 4 | `unit_variant_handler.rs` |
// | 4 | `#[ scalar ]` | `#[ standalone_constructors ]` | `MyEnum::my_unit_variant() -> MyEnum` | `fn my_unit_variant() -> MyEnum` | 1a, 4 | `unit_variant_handler.rs` |
// | 5 | `#[ subform_scalar ]`| (Any) | *Compile Error* | *Compile Error* | 2a | (Dispatch logic in `former_enum.rs` should error) |
//
// *(Note: "Default" for unit variants behaves like `#[ scalar ]`)*
//
// File: module/core/former/tests/inc/former_enum_tests/unit_variant_only_test.rs
use *;