88from evaluation_function .schemas import ValidationError , ErrorCode
99from evaluation_function .schemas .utils import make_fsa
1010from evaluation_function .schemas .result import Result , FSAFeedback
11+ from evaluation_function .schemas .params import Params
1112from evaluation_function .correction import analyze_fsa_correction
1213
1314
1415# =============================================================================
15- # Fixtures
16+ # Fixtures - DFAs
1617# =============================================================================
1718
1819@pytest .fixture
@@ -72,36 +73,54 @@ def equivalent_dfa():
7273 )
7374
7475
76+ # =============================================================================
77+ # Helper: Default Params
78+ # =============================================================================
79+
80+ @pytest .fixture
81+ def default_params ():
82+ """Default Params object for analyze_fsa_correction."""
83+ return Params (
84+ expected_type = "DFA" ,
85+ check_completeness = True ,
86+ check_minimality = True ,
87+ evaluation_mode = "strict" ,
88+ highlight_errors = True ,
89+ feedback_verbosity = "detailed"
90+ )
91+
92+
7593# =============================================================================
7694# Test Main Pipeline - Returns Result
7795# =============================================================================
7896
7997class TestAnalyzeFsaCorrection :
8098 """Test the main analysis pipeline returns Result."""
8199
82- def test_equivalent_fsas_correct (self , dfa_accepts_a , equivalent_dfa ):
83- result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa )
100+ def test_equivalent_fsas_correct (self , dfa_accepts_a , equivalent_dfa , default_params ):
101+ result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa , default_params )
102+ print (result )
84103 assert isinstance (result , Result )
85104 assert result .is_correct is True
86105 assert "Correct" in result .feedback
87106
88- def test_different_fsas_incorrect (self , dfa_accepts_a , dfa_accepts_a_or_b ):
89- result = analyze_fsa_correction (dfa_accepts_a , dfa_accepts_a_or_b )
107+ def test_different_fsas_incorrect (self , dfa_accepts_a , dfa_accepts_a_or_b , default_params ):
108+ result = analyze_fsa_correction (dfa_accepts_a , dfa_accepts_a_or_b , default_params )
90109 assert isinstance (result , Result )
91110 assert result .is_correct is False
92111
93- def test_result_has_fsa_feedback (self , dfa_accepts_a , equivalent_dfa ):
94- result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa )
112+ def test_result_has_fsa_feedback (self , dfa_accepts_a , equivalent_dfa , default_params ):
113+ result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa , default_params )
95114 assert result .fsa_feedback is not None
96115 assert isinstance (result .fsa_feedback , FSAFeedback )
97116
98- def test_fsa_feedback_has_structural_info (self , dfa_accepts_a , equivalent_dfa ):
99- result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa )
117+ def test_fsa_feedback_has_structural_info (self , dfa_accepts_a , equivalent_dfa , default_params ):
118+ result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa , default_params )
100119 assert result .fsa_feedback .structural is not None
101120 assert result .fsa_feedback .structural .num_states == 3
102121
103- def test_different_fsas_have_errors (self , dfa_accepts_a , dfa_accepts_a_or_b ):
104- result = analyze_fsa_correction (dfa_accepts_a , dfa_accepts_a_or_b )
122+ def test_different_fsas_have_errors (self , dfa_accepts_a , dfa_accepts_a_or_b , default_params ):
123+ result = analyze_fsa_correction (dfa_accepts_a , dfa_accepts_a_or_b , default_params )
105124 assert result .fsa_feedback is not None
106125 assert len (result .fsa_feedback .errors ) > 0
107126
@@ -113,36 +132,48 @@ def test_different_fsas_have_errors(self, dfa_accepts_a, dfa_accepts_a_or_b):
113132class TestInvalidFsas :
114133 """Test handling of invalid FSAs."""
115134
116- def test_invalid_initial_state (self ):
135+ def test_invalid_initial_state (self , default_params ):
117136 invalid = make_fsa (
118137 states = ["q0" ],
119138 alphabet = ["a" ],
120139 transitions = [],
121140 initial = "invalid" ,
122141 accept = []
123142 )
124- result = analyze_fsa_correction (invalid , invalid )
143+ result = analyze_fsa_correction (invalid , invalid , default_params )
125144 assert result .is_correct is False
126145 assert result .fsa_feedback is not None
127146 assert len (result .fsa_feedback .errors ) > 0
128147
129- def test_invalid_accept_state (self ):
148+ def test_invalid_accept_state (self , default_params ):
130149 invalid = make_fsa (
131150 states = ["q0" ],
132151 alphabet = ["a" ],
133152 transitions = [],
134153 initial = "q0" ,
135154 accept = ["invalid" ]
136155 )
137- result = analyze_fsa_correction (invalid , invalid )
156+ result = analyze_fsa_correction (invalid , invalid , default_params )
138157 assert result .is_correct is False
139158
140159
160+ # =============================================================================
161+ # Test Minimality
162+ # =============================================================================
163+
141164class TestAnalyzeFsaCorrectionMinimality :
142165 """Test analyze_fsa_correction with minimality checking."""
143166
144167 def test_minimal_fsa_passes (self , dfa_accepts_a , equivalent_dfa ):
145- result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa , require_minimal = True )
168+ params = Params (
169+ expected_type = "DFA" ,
170+ check_completeness = True ,
171+ check_minimality = True ,
172+ evaluation_mode = "strict" ,
173+ highlight_errors = True ,
174+ feedback_verbosity = "detailed"
175+ )
176+ result = analyze_fsa_correction (dfa_accepts_a , equivalent_dfa , params )
146177 assert result .is_correct is True
147178
148179 def test_non_minimal_fsa_fails_when_required (self , equivalent_dfa ):
@@ -162,9 +193,18 @@ def test_non_minimal_fsa_fails_when_required(self, equivalent_dfa):
162193 initial = "q0" ,
163194 accept = ["q1" ]
164195 )
165- result = analyze_fsa_correction (non_minimal , equivalent_dfa , require_minimal = True )
196+ params = Params (
197+ expected_type = "DFA" ,
198+ check_completeness = True ,
199+ check_minimality = True ,
200+ evaluation_mode = "strict" ,
201+ highlight_errors = True ,
202+ feedback_verbosity = "detailed"
203+ )
204+ result = analyze_fsa_correction (non_minimal , equivalent_dfa , params )
166205 # Should have minimality error
167206 assert result .fsa_feedback is not None
207+ assert any (e .code == ErrorCode .NOT_MINIMAL for e in result .fsa_feedback .errors )
168208
169209
170210if __name__ == "__main__" :
0 commit comments