From a4a8510a0bf8abaf3c58ce276d619fa30dad26f5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 25 Mar 2026 22:45:49 +0200 Subject: rpn: Fix =: operator pop order for REPL mode --- internal/repl/repl_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'internal/repl/repl_test.go') diff --git a/internal/repl/repl_test.go b/internal/repl/repl_test.go index cd062cb..2b7ed16 100644 --- a/internal/repl/repl_test.go +++ b/internal/repl/repl_test.go @@ -627,3 +627,39 @@ func TestDefaultExecutorCodePaths(t *testing.T) { // Path 5: Whitespace only (trimmed to empty, returns early) executor(" ") } + +func TestExecutorWithAssignmentRight(t *testing.T) { + // Test := and =: operators + executor("5 x :=") + state := getRPNState() + val, exists := state.vars.GetVariable("x") + if !exists { + t.Errorf("Variable x should exist after x :=") + } + if val != 5 { + t.Errorf("Variable x = %v, want 5", val) + } + + executor("y 3 =:") + state = getRPNState() + val, exists = state.vars.GetVariable("y") + if !exists { + t.Errorf("Variable y should exist after y =:") + } + if val != 3 { + t.Errorf("Variable y = %v, want 3", val) + } +} + +func TestExecutorWithAssignmentAfterCalculation(t *testing.T) { + // Test that assignment works after a calculation + executor("1 2 + x =:") + state := getRPNState() + val, exists := state.vars.GetVariable("x") + if !exists { + t.Errorf("Variable x should exist") + } + if val != 3 { + t.Errorf("Variable x = %v, want 3", val) + } +} -- cgit v1.2.3