Answer architecture round 3, stability round 1 and product-owner round 1: CalcName and proven.OfCalc for one meaning per name, a lazy load placed where its lookup found it, DataType's constants typed under it, and cover printing the module's total

This commit is contained in:
2026-10-05 15:53:56 +02:00
committed by Lillem4n
parent 679bd43c7c
commit 4f484cd780
11 changed files with 34 additions and 33 deletions
+7 -7
View File
@@ -41,7 +41,7 @@ func TestOrKeepsTheBoundsOfBothAndTheFirstReason(t *testing.T) {
}
}
func TestCalcBoundsAnExpressionFromItsOperands(t *testing.T) {
func TestOfCalcBoundsAnExpressionFromItsOperands(t *testing.T) {
operand := func(name string) Value {
return map[string]Value{"a": Bounded(1, 9, true), "b": Bounded(0, 9, true), "big": Bounded(0, 1e299, true), "word": Unproven("it is text")}[name]
}
@@ -57,20 +57,20 @@ func TestCalcBoundsAnExpressionFromItsOperands(t *testing.T) {
if err != nil {
t.Fatal(err)
}
v, doubt := Calc(c.Expr, operand)
v, doubt := OfCalc(c.Expr, operand)
if doubt != want {
t.Errorf("Calc(%s) doubts %q, want %q", expr, doubt, want)
t.Errorf("OfCalc(%s) doubts %q, want %q", expr, doubt, want)
}
if expr == "a * 2 + 1" && (v.Lo != 3 || v.Hi != 19 || !v.Integral || v.NonZero != 3) {
t.Errorf("Calc(%s) = %+v, want [3, 19], integral, nonzero by 3", expr, v)
t.Errorf("OfCalc(%s) = %+v, want [3, 19], integral, nonzero by 3", expr, v)
}
if expr == "-(a - 10)" && (v.Lo != 1 || v.Hi != 9) {
t.Errorf("Calc(%s) = %+v, want [1, 9]", expr, v)
t.Errorf("OfCalc(%s) = %+v, want [1, 9]", expr, v)
}
}
lone, _ := grammar.ParseCalc("x")
if _, doubt := Calc(lone.Expr, func(string) Value { return Bounded(0, 1e301, true) }); doubt != "x is not proven within 1e300" {
t.Errorf("Calc(x) doubts %q, want a lone operand held to the limit", doubt)
if _, doubt := OfCalc(lone.Expr, func(string) Value { return Bounded(0, 1e301, true) }); doubt != "x is not proven within 1e300" {
t.Errorf("OfCalc(x) doubts %q, want a lone operand held to the limit", doubt)
}
}