From 19986b99d188c6f190f7592dfe6631e67a011aff Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 25 Mar 2026 23:02:32 +0200 Subject: rpn: Add test for incremental assignment with =: operator --- internal/repl/repl_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/repl/repl_test.go b/internal/repl/repl_test.go index 9276135..b07036e 100644 --- a/internal/repl/repl_test.go +++ b/internal/repl/repl_test.go @@ -666,3 +666,21 @@ func TestExecutorWithAssignmentAfterCalculation(t *testing.T) { t.Errorf("Variable z = %v, want 3", val) } } + +func TestExecutorWithIncrementalAssignment(t *testing.T) { + // Test that assignment works after a calculation with separate commands + // This should use the value from the stack for assignment + executor("1 2 +") + state := getRPNState() + + // Now use z =: to assign the top of stack (3) to variable z + executor("z =:") + state = getRPNState() + val, exists := state.vars.GetVariable("z") + if !exists { + t.Errorf("Variable z should exist after z =:") + } + if val != 3 { + t.Errorf("Variable z = %v, want 3", val) + } +} -- cgit v1.2.3