diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-26 09:46:26 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-26 09:46:26 +0200 |
| commit | b0f6b552ed0690e3fad98e9771bbd6a47fbc2e37 (patch) | |
| tree | b76762e50de49436cbe856d5714e640786abf059 | |
| parent | 0bf0381232019fbda419447166d021d8e0852317 (diff) | |
fix: remove unused variable assignments in test files
- internal/repl/repl_test.go: Remove unused state variable assignments
- internal/rpn/rpn_test.go: Remove unused result/err variable assignments
These changes address golangci-lint 'ineffectual assignment' warnings.
| -rw-r--r-- | internal/repl/repl_test.go | 13 | ||||
| -rw-r--r-- | internal/rpn/rpn_test.go | 8 |
2 files changed, 7 insertions, 14 deletions
diff --git a/internal/repl/repl_test.go b/internal/repl/repl_test.go index bf5af49..613bc36 100644 --- a/internal/repl/repl_test.go +++ b/internal/repl/repl_test.go @@ -671,12 +671,11 @@ 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") + + val, exists := getRPNState().vars.GetVariable("z") if !exists { t.Errorf("Variable z should exist after z =:") } @@ -689,12 +688,10 @@ func TestExecutorWithIncrementalAssignment(t *testing.T) { func TestExecutorWithSimpleIncrementalAssignment(t *testing.T) { // First execute 2 to put it on the stack executor("2") - state := getRPNState() // Then use x =: to assign the top of stack to variable x executor("x =:") - state = getRPNState() - val, exists := state.vars.GetVariable("x") + val, exists := getRPNState().vars.GetVariable("x") if !exists { t.Errorf("Variable x should exist after x =:") } @@ -711,14 +708,12 @@ func TestExecutorWithExactUserScenario(t *testing.T) { // The variable should be assigned the value 2 executor("2") - state := getRPNState() // Verify stack has 2 // (can't directly check stack without exposing it, but next command will fail if stack is empty) executor("x =:") - state = getRPNState() - val, exists := state.vars.GetVariable("x") + val, exists := getRPNState().vars.GetVariable("x") if !exists { t.Errorf("Variable x should exist after x =:") } diff --git a/internal/rpn/rpn_test.go b/internal/rpn/rpn_test.go index 8611cf8..0822125 100644 --- a/internal/rpn/rpn_test.go +++ b/internal/rpn/rpn_test.go @@ -698,8 +698,7 @@ func TestIncrementalAssignmentRPN(t *testing.T) { } // Now try x =: - should assign 2 to variable x - result, err = r.ParseAndEvaluate("x =:") - if err != nil { + if _, err := r.ParseAndEvaluate("x =:"); err != nil { t.Fatalf("Assignment failed: %v", err) } @@ -830,13 +829,12 @@ func TestBoundIdentifierPushesValue(t *testing.T) { r := NewRPN(vars) // First bind x to 5 - result, err := r.ParseAndEvaluate("x = 5") - if err != nil { + if _, err := r.ParseAndEvaluate("x = 5"); err != nil { t.Fatalf("ParseAndEvaluate('x = 5') returned error: %v", err) } // Now use x (bound) - should push value - result, err = r.ParseAndEvaluate("x") + result, err := r.ParseAndEvaluate("x") if err != nil { t.Fatalf("ParseAndEvaluate('x') after binding returned error: %v", err) } |
