summaryrefslogtreecommitdiff
path: root/internal/repl/repl_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-25 22:45:49 +0200
committerPaul Buetow <paul@buetow.org>2026-03-25 22:45:49 +0200
commita4a8510a0bf8abaf3c58ce276d619fa30dad26f5 (patch)
treebe98570510035617e184bfd7ac1ef62530069e99 /internal/repl/repl_test.go
parent7d0747df9c4298aa4044684f8cdd6b6e09b57442 (diff)
rpn: Fix =: operator pop order for REPL mode
Diffstat (limited to 'internal/repl/repl_test.go')
-rw-r--r--internal/repl/repl_test.go36
1 files changed, 36 insertions, 0 deletions
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)
+ }
+}