summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-23 20:25:44 +0300
committerPaul Buetow <paul@buetow.org>2026-05-23 20:25:44 +0300
commit1042acacd2d875afec9e56a021cd3d254044de9d (patch)
treea9bf04b2d6f92915ee92e6a553862b13087ecd57
parent6094b92ea44db5ac74183fc339574852254c9f23 (diff)
refactor: remove dead boolean_ops.go (YAGNI/DRY)
Delete internal/rpn/boolean_ops.go which defines BooleanOperations struct with GT/LT/GTE/LTE/EQ/NEQ methods using raw float64 comparisons (no metric awareness). NewBooleanOperations() was never called by any live code path. The authoritative metric-aware comparison operators live on the Operations struct in operations_compare.go via compareValues(). boolean_test.go tests via ParseAndEvaluate which uses the live Operations implementation. Removes 167 lines of dead code.
-rw-r--r--internal/rpn/boolean_ops.go167
1 files changed, 0 insertions, 167 deletions
diff --git a/internal/rpn/boolean_ops.go b/internal/rpn/boolean_ops.go
deleted file mode 100644
index fdad862..0000000
--- a/internal/rpn/boolean_ops.go
+++ /dev/null
@@ -1,167 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright (c) 2026 Paul Buetow
-
-package rpn
-
-import (
- "fmt"
-)
-
-// BooleanOperations provides boolean comparison operator implementations.
-type BooleanOperations struct {
-}
-
-// NewBooleanOperations creates a new BooleanOperations instance.
-func NewBooleanOperations() *BooleanOperations {
- return &BooleanOperations{}
-}
-
-// GT pops two values from stack, compares (a > b), and pushes a boolean result.
-func (o *BooleanOperations) GT(stack *Stack) error {
- b, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for gt: %w", err)
- }
-
- a, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for gt: %w", err)
- }
-
- aF, err := toFloat64(a, "gt")
- if err != nil {
- return err
- }
- bF, err := toFloat64(b, "gt")
- if err != nil {
- return err
- }
-
- stack.Push(NewFloatFromBool(aF > bF))
- return nil
-}
-
-// LT pops two values from stack, compares (a < b), and pushes a boolean result.
-func (o *BooleanOperations) LT(stack *Stack) error {
- b, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for lt: %w", err)
- }
-
- a, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for lt: %w", err)
- }
-
- aF, err := toFloat64(a, "lt")
- if err != nil {
- return err
- }
- bF, err := toFloat64(b, "lt")
- if err != nil {
- return err
- }
-
- stack.Push(NewFloatFromBool(aF < bF))
- return nil
-}
-
-// GTE pops two values from stack, compares (a >= b), and pushes a boolean result.
-func (o *BooleanOperations) GTE(stack *Stack) error {
- b, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for gte: %w", err)
- }
-
- a, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for gte: %w", err)
- }
-
- aF, err := toFloat64(a, "gte")
- if err != nil {
- return err
- }
- bF, err := toFloat64(b, "gte")
- if err != nil {
- return err
- }
-
- stack.Push(NewFloatFromBool(aF >= bF))
- return nil
-}
-
-// LTE pops two values from stack, compares (a <= b), and pushes a boolean result.
-func (o *BooleanOperations) LTE(stack *Stack) error {
- b, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for lte: %w", err)
- }
-
- a, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for lte: %w", err)
- }
-
- aF, err := toFloat64(a, "lte")
- if err != nil {
- return err
- }
- bF, err := toFloat64(b, "lte")
- if err != nil {
- return err
- }
-
- stack.Push(NewFloatFromBool(aF <= bF))
- return nil
-}
-
-// EQ pops two values from stack, compares (a == b), and pushes a boolean result.
-func (o *BooleanOperations) EQ(stack *Stack) error {
- b, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for eq: %w", err)
- }
-
- a, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for eq: %w", err)
- }
-
- aF, err := toFloat64(a, "eq")
- if err != nil {
- return err
- }
- bF, err := toFloat64(b, "eq")
- if err != nil {
- return err
- }
-
- stack.Push(NewFloatFromBool(aF == bF))
- return nil
-}
-
-// NEQ pops two values from stack, compares (a != b), and pushes a boolean result.
-func (o *BooleanOperations) NEQ(stack *Stack) error {
- b, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for neq: %w", err)
- }
-
- a, err := stack.Pop()
- if err != nil {
- return fmt.Errorf("insufficient operands for neq: %w", err)
- }
-
- aF, err := toFloat64(a, "neq")
- if err != nil {
- return err
- }
- bF, err := toFloat64(b, "neq")
- if err != nil {
- return err
- }
-
- stack.Push(NewFloatFromBool(aF != bF))
- return nil
-}