Merge branch 'feat/binder_name' into experiments/dsp

This commit is contained in:
Leni Aniva 2024-10-02 11:11:34 -07:00
commit 2e8cff0647
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 17 additions and 0 deletions

View File

@ -92,6 +92,7 @@ class GoalState:
@dataclass(frozen=True)
class TacticHave:
branch: str
binder_name: Optional[str] = None
@dataclass(frozen=True)
class TacticCalc:
step: str

View File

@ -123,6 +123,8 @@ class Server:
args["tactic"] = tactic
elif isinstance(tactic, TacticHave):
args["have"] = tactic.branch
if tactic.binder_name:
args["binderName"] = tactic.binder_name
elif isinstance(tactic, TacticCalc):
args["calc"] = tactic.step
else:
@ -285,6 +287,20 @@ class TestServer(unittest.TestCase):
)
])
def test_have(self):
server = Server()
state0 = server.goal_start("1 + 1 = 2")
state1 = server.goal_tactic(state0, goal_id=0, tactic=TacticHave(branch="2 = 1 + 1", binder_name="h"))
self.assertEqual(state1.goals, [
Goal(
variables=[],
target="2 = 1 + 1",
),
Goal(
variables=[Variable(name="h", t="2 = 1 + 1")],
target="1 + 1 = 2",
),
])
def test_conv_calc(self):
server = Server(options={"automaticMode": False})