33import pyreason .scripts .numba_wrapper .numba_types .interval_type as interval
44
55
6- # Tests in this class were generated with Claude Sonnet 4.5.
6+ # Tests in this class were partially generated with Claude Sonnet 4.5.
77class TestValidFactParsing :
88 """Test cases for valid fact inputs that should parse successfully."""
99
@@ -112,8 +112,26 @@ def test_interval_with_ones(self):
112112 assert pred == "pred"
113113 assert bound .lower == 1.0 and bound .upper == 1.0
114114
115+ def test_negation_with_interval_bound (self ):
116+ """Test that negation with interval bound."""
117+ pred , component , bound , fact_type = parse_fact ("~pred(node):[0.5,0.8]" )
118+ assert pred == "pred"
119+ assert bound .lower == 0.2 and bound .upper == 0.5
115120
116- # Tests in this class were generated with Claude Sonnet 4.5.
121+ def test_negation_with_explicit_bound_true (self ):
122+ """Test that negation with an explicit bound true."""
123+ pred , component , bound , fact_type = parse_fact ("~pred(node):True" )
124+ assert pred == "pred"
125+ assert bound .lower == 0.0 and bound .upper == 0.0
126+
127+ def test_negation_with_explicit_bound_false (self ):
128+ """Test that negation with an explicit bound false."""
129+ pred , component , bound , fact_type = parse_fact ("~pred(node):False" )
130+ assert pred == "pred"
131+ assert bound .lower == 1.0 and bound .upper == 1.0
132+
133+
134+ # Tests in this class were partially generated with Claude Sonnet 4.5.
117135class TestInvalidFactParsing :
118136 """Test cases for invalid fact inputs that should raise validation errors."""
119137
@@ -193,7 +211,7 @@ def test_missing_opening_bracket(self):
193211 parse_fact ("pred(node):0.5,0.8]" )
194212
195213 def test_interval_lower_greater_than_upper (self ):
196- """Test that interval with lower > upper raises an error or warning ."""
214+ """Test that interval with lower > upper raises an error."""
197215 with pytest .raises (ValueError ):
198216 parse_fact ("pred(node):[0.9,0.1]" )
199217
@@ -207,6 +225,11 @@ def test_interval_out_of_range_greater_than_one(self):
207225 with pytest .raises (ValueError ):
208226 parse_fact ("pred(node):[0.5,1.5]" )
209227
228+ def test_interval_out_of_range_greater_than_one_with_negation (self ):
229+ """Test that interval values > 1 for a negated predicate raises an error."""
230+ with pytest .raises (ValueError ):
231+ parse_fact ("~pred(node):[0.5,1.5]" )
232+
210233 def test_empty_component_in_edge (self ):
211234 """Test that empty component in edge fact raises an error."""
212235 with pytest .raises (ValueError ):
@@ -227,15 +250,15 @@ def test_too_many_components_in_edge(self):
227250 with pytest .raises (ValueError ):
228251 parse_fact ("pred(node1,node2,node3)" )
229252
230- def test_negation_with_explicit_bound (self ):
231- """Test that negation with explicit bound raises an error (ambiguous) ."""
253+ def test_negation_with_invalid_bound (self ):
254+ """Test that negation with invalid bound raises an error."""
232255 with pytest .raises (ValueError ):
233- parse_fact ("~pred(node):True " )
256+ parse_fact ("~pred(node):Undefined " )
234257
235- def test_negation_with_interval_bound (self ):
236- """Test that negation with interval bound raises an error (ambiguous) ."""
258+ def test_negation_with_invalid_interval_bound (self ):
259+ """Test that negation with invalid bound raises an error."""
237260 with pytest .raises (ValueError ):
238- parse_fact ("~pred(node):[0.5,0.8 ]" )
261+ parse_fact ("~pred(node):[ham, sandwitch ]" )
239262
240263 def test_double_negation (self ):
241264 """Test that double negation raises an error."""
0 commit comments