File size: 7,177 Bytes
463f868
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//! Love Live Card Game Rust Engine - Test Suite Organization
//!
//! # Test Architecture Overview
//!
//! This engine includes 568 comprehensive tests organized into multiple categories:
//!
//! ## Test Categories
//!
//! ### 1. QA Verification Tests (163 tests)
//! - **Location**: `qa/` module and `qa_verification_tests.rs`
//! - **Purpose**: Official Q&A rule clarifications from game documentation
//! - **Coverage**: Q1-Q300+ official rulings
//! - **Command**: `cargo test --lib qa`
//!
//! ### 2. Opcode & Bytecode Tests (~150 tests)
//! - **Locations**: `opcode_*.rs` modules (opcode_tests, opcode_coverage_gap_2, etc.)
//! - **Purpose**: Individual bytecode instruction validation
//! - **Coverage**: O_DRAW, O_REVEAL_UNTIL, O_LOOK_DECK, etc.
//! - **Command**: `cargo test --lib opcode`
//!
//! ### 3. Mechanics & Game Flow Tests (~180 tests)
//! - **Locations**: `*_tests.rs` modules (mechanics_tests, game_flow_tests, etc.)
//! - **Purpose**: High-level game mechanics and interactions
//! - **Coverage**: Phase transitions, card interactions, state consistency
//! - **Command**: `cargo test --lib mechanics`
//!
//! ### 4. Edge Cases & Stress Tests (~75 tests)
//! - **Locations**: Various regression and special-case test files
//! - **Purpose**: Rare scenarios, stress tests, regression prevention
//! - **Coverage**: Complex bytecode sequences, boundary conditions
//! - **Command**: `cargo test --lib edge` or `cargo test --lib stress`
//!
//! ## Performance Metrics
//!
//! - **Full Suite**: 568 tests in ~17-18 seconds (parallelized)
//! - **Single-threaded**: ~70 seconds (deterministic ordering)
//! - **Parallelization**: Auto-scales to CPU core count (4-8 threads typical)
//! - **Memory**: ~200MB peak during execution
//!
//! ## Running Tests
//!
//! ```bash
//! # All tests with parallelization (default, ~18s)
//! cargo test --lib
//!
//! # Single category
//! cargo test --lib qa
//! cargo test --lib opcode
//! cargo test --lib mechanics
//!
//! # Deterministic (single-threaded, ~70s)
//! cargo test --lib -- --test-threads=1
//!
//! # Specific test
//! cargo test --lib test_q166_reveal_until_refresh
//!
//! # With output
//! cargo test --lib test_opcode_draw -- --nocapture
//! ```
//!
//! ## Test File Organization
//!
//! **Current Structure** (src/ directory):
//! ```text
//! src/
//! β”œβ”€β”€ qa/                          # QA rule verification (mod)
//! β”‚   β”œβ”€β”€ batch_1.rs
//! β”‚   β”œβ”€β”€ batch_2.rs
//! β”‚   β”œβ”€β”€ batch_3.rs
//! β”‚   β”œβ”€β”€ batch_4_unmapped_qa.rs
//! β”‚   └── ...
//! β”œβ”€β”€ qa_verification_tests.rs     # Additional QA tests
//! β”œβ”€β”€ opcode_tests.rs              # Basic opcode tests
//! β”œβ”€β”€ opcode_coverage_gap_2.rs     # Coverage gap analysis
//! β”œβ”€β”€ opcode_missing_tests.rs      # Missing opcode implementations
//! β”œβ”€β”€ opcode_rigor_tests.rs        # Rigorous opcode validation
//! β”œβ”€β”€ mechanics_tests.rs           # Game mechanics
//! β”œβ”€β”€ game_flow_tests.rs           # Phase transitions
//! β”œβ”€β”€ card_interaction_tests.rs    # Card interactions
//! β”œβ”€β”€ regression_tests.rs          # Regression prevention
//! └── [other test files]
//! ```
//!
//! **Planned Structure** (tests/ directory reference):
//! See `../tests/README.md` for future reorganization planning.
//! This provides a blueprint for scaling test organization.
//!
//! ## Adding New Tests
//!
//! ### For a New Q&A Ruling (Q301+)
//! 1. Add test to `src/qa/batch_4_unmapped_qa.rs` or create `batch_5.rs`
//! 2. Name: `test_q###_descriptive_name`
//! 3. Add official Q&A reference as comment
//! 4. Test command: `cargo test --lib test_q###`
//!
//! ### For a New Opcode Feature
//! 1. Add test to appropriate `opcode_*.rs` file
//! 2. Name: `test_opcode_name_scenario`
//! 3. Add opcode documentation comment
//! 4. Test command: `cargo test --lib test_opcode_name`
//!
//! ### For Regression Testing
//! 1. Add test to `regression_tests.rs`
//! 2. Name: `test_regression_issue_number` or `test_regression_card_name`
//! 3. Reference the issue/bug fixed
//! 4. Test command: `cargo test --lib test_regression`
//!
//! ### For Stress/Edge Cases
//! 1. Add test to `../tests/edge_cases/stress_rare_bytecode_sequences.rs`
//! 2. Name: `test_stress_scenario_name`
//! 3. Document complexity metrics (bytecode length, nesting depth, etc.)
//! 4. Test command: `cargo test --lib test_stress`
//!
//! ## Test Isolation Issue (Known)
//!
//! Q166 test currently fails in full suite due to test state contamination
//! but passes in isolation. Investigation ongoing. Workaround:
//! ```bash
//! cargo test --lib test_q166
//! ```
//! All 567 other tests pass independently.

// Incremental build verification comment
pub mod core;
#[cfg(feature = "extension-module")]
pub mod py_bindings;
pub mod repro;
pub mod test_helpers;
#[cfg(feature = "wasm")]
pub mod wasm_bindings;

#[cfg(test)]
mod ability_tests;
#[cfg(test)]
mod baton_pass_tests;
#[cfg(test)]
mod card_interaction_tests;
#[cfg(test)]
mod comprehensive_tests;
#[cfg(test)]
mod coverage_gap_tests;
#[cfg(test)]
mod database_tests;
#[cfg(test)]
mod deck_refresh_tests;
#[cfg(test)]
mod game_end_tests;
#[cfg(test)]
mod game_flow_tests;
#[cfg(test)]
mod mechanics_tests;
#[cfg(test)]
mod meta_rule_tests;
#[cfg(test)]
mod opcode_coverage_gap_2;
#[cfg(test)]
mod opcode_missing_tests;
#[cfg(test)]
mod opcode_tests;
#[cfg(test)]
mod phase_transition_tests;
#[cfg(test)]
mod regression_tests;
#[cfg(test)]
mod response_flow_tests;
#[cfg(test)]
mod rule_parity_regression_tests;
#[cfg(test)]
mod size_test;
#[cfg(test)]
mod stabilized_tests;
#[cfg(test)]
mod structural_tests;
#[cfg(test)]
mod tests;
#[cfg(test)]
mod tie_breaker_tests;
#[cfg(test)]
mod trigger_tests;
#[cfg(test)]
mod verification_tests;
#[cfg(test)]
mod wave2_tests;
#[cfg(test)]
mod wave6_tests;
// #[cfg(test)]
// // mod archetype_runner;
#[cfg(test)]
mod count_group_tests;
#[cfg(test)]
mod enforcement_tests;
#[cfg(test)]
mod filter_audit_tests;
#[cfg(test)]
mod qa_verification_tests;
#[cfg(test)]
mod rule_alignment_tests;
#[cfg(test)]
mod semantic_assertions;
#[cfg(test)]
mod qa;
#[cfg(test)]
mod perf_tests;

#[cfg(test)]
mod meta_rule_card_tests;

#[cfg(test)]
mod opcode_rigor_tests;

#[cfg(test)]
mod untested_opcode_tests;

#[cfg(test)]
mod new_opcode_tests;

#[cfg(test)]
mod alphazero_verification_tests;
#[cfg(test)]
mod debug_q203;
#[cfg(test)]
mod unique_ability_tests;

// #[cfg(test)]
// mod gpu_smoke_tests;  // Requires gpu_manager module (not yet implemented)

#[cfg(test)]
mod manual_verification_tests;

#[cfg(test)]
mod vanilla_encoding_tests;

#[cfg(test)]
mod debug_consts;

// #[cfg(test)]
// mod gpu_parity_tests;

// pub mod repro_pl_bp3_004; // Deleted

#[cfg(feature = "extension-module")]
use pyo3::prelude::*;

#[cfg(feature = "extension-module")]
#[pymodule]
fn engine_rust(m: &Bound<'_, PyModule>) -> PyResult<()> {
    py_bindings::register_python_module(m)
}