feat: Add binder name option in `TacticHave`

This commit is contained in:
Leni Aniva 2024-10-02 11:09:58 -07:00
parent 5effc63d9e
commit 8ce8e9d389
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) @dataclass(frozen=True)
class TacticHave: class TacticHave:
branch: str branch: str
binder_name: Optional[str] = None
@dataclass(frozen=True) @dataclass(frozen=True)
class TacticCalc: class TacticCalc:
step: str step: str

View File

@ -123,6 +123,8 @@ class Server:
args["tactic"] = tactic args["tactic"] = tactic
elif isinstance(tactic, TacticHave): elif isinstance(tactic, TacticHave):
args["have"] = tactic.branch args["have"] = tactic.branch
if tactic.binder_name:
args["binderName"] = tactic.binder_name
elif isinstance(tactic, TacticCalc): elif isinstance(tactic, TacticCalc):
args["calc"] = tactic.step args["calc"] = tactic.step
else: 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): def test_conv_calc(self):
server = Server(options={"automaticMode": False}) server = Server(options={"automaticMode": False})