diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-25 23:02:32 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-25 23:02:32 +0200 |
| commit | 19986b99d188c6f190f7592dfe6631e67a011aff (patch) | |
| tree | 4ccff6395cb489160937690c8944e714d37c4c3a | |
| parent | 3d6781c22c4512a896b5dffc0b22b30e36b4993c (diff) | |
rpn: Add test for incremental assignment with =: operator
| -rw-r--r-- | internal/repl/repl_test.go | 18 |
1 files changed, 18 insertions, 0 deletions
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) + } +} |
