From 1402ca7d6c2bb0cea2cf52a4ecce7b809ebf31b1 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 28 Oct 2026 10:31:32 +0100 Subject: Reject malformed spline counts and unsorted knots Co-Authored-By: Claude Haiku 5.5 --- tests/test_formula.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests/test_formula.py') diff --git a/tests/test_formula.py b/tests/test_formula.py index 7440681..10065d2 100644 --- a/tests/test_formula.py +++ b/tests/test_formula.py @@ -168,3 +168,29 @@ class SplineTest(unittest.TestCase): g.add_prop("b") g.add_formula("b", spline_ops("spline_linear", [[0, 0], [1, 10]])) self.assertAlmostEqual(g.evaluate()["b"], 5.0) + + def test_fractional_count_is_fatal(self): + g = Graph() + g.add_prop("a", 0.5) + g.add_prop("b") + ops = [push("a"), val([0, 0]), val([1, 1]), val(2.5), {"op": "spline_linear"}] + g.add_formula("b", ops, source="f") + with self.assertRaisesRegex(Error, "malformed formula for b"): + g.evaluate() + + def test_unsorted_knots_are_fatal(self): + g = Graph() + g.add_prop("a", 0.5) + g.add_prop("b") + g.add_formula("b", spline_ops("spline_linear", [[1, 1], [0, 0], [2, 5]]), source="f") + with self.assertRaisesRegex(Error, "malformed formula for b"): + g.evaluate() + + def test_count_larger_than_stack_is_fatal(self): + g = Graph() + g.add_prop("a", 0.5) + g.add_prop("b") + ops = [push("a"), val(0), val(1), {"op": "spline_linear"}] + g.add_formula("b", ops, source="f") + with self.assertRaisesRegex(Error, "malformed formula for b"): + g.evaluate() -- cgit v1.2.3