diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 18:27:42 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 18:27:42 +0300 |
| commit | 4fdc92269e36c695fa96f91dd62b0715b4583587 (patch) | |
| tree | 7985cff1d0e69a325967bbb2c804e8668ac57ff1 | |
| parent | ab3e44d33cbe4ac09b68de2a65f35de1937574a4 (diff) | |
fix(rpn): remove unused IsBool/IsString/IsSymbol from StackValue (task 8k)
| -rw-r--r-- | internal/rpn/number.go | 42 | ||||
| -rw-r--r-- | internal/rpn/number_test.go | 54 |
2 files changed, 0 insertions, 96 deletions
diff --git a/internal/rpn/number.go b/internal/rpn/number.go index de6fa93..a0b9778 100644 --- a/internal/rpn/number.go +++ b/internal/rpn/number.go @@ -14,12 +14,6 @@ import ( type StackValue interface { // String returns the string representation of the value. String() string - // IsBool returns true if this value represents a boolean value. - IsBool() bool - // IsString returns true if this value represents a string value. - IsString() bool - // IsSymbol returns true if this value represents a symbol. - IsSymbol() bool // Metric returns the metric unit for this value. Metric() *Metric } @@ -137,10 +131,6 @@ func (f *Float) Float64() (float64, error) { return f.n, nil } -// IsBool returns true if this number represents a boolean value. -func (f *Float) IsBool() bool { - return f.isBool -} // Bool returns the boolean value. // Returns error if the number is not a boolean. @@ -163,15 +153,7 @@ func (f *Float) IsNegative() bool { return f.n < 0 } -// IsString returns true if this number represents a string value. -func (f *Float) IsString() bool { - return false -} -// IsSymbol returns true if this number represents a symbol. -func (f *Float) IsSymbol() bool { - return false -} // Metric returns the metric for this number. func (f *Float) Metric() *Metric { @@ -270,10 +252,6 @@ func (r *Rat) Float64() (float64, error) { return f, nil } -// IsBool returns true if this number represents a boolean value. -func (r *Rat) IsBool() bool { - return r.isBool -} // Bool returns the boolean value. // Returns error if the number is not a boolean. @@ -294,15 +272,7 @@ func (r *Rat) IsNegative() bool { return r.n.Sign() < 0 } -// IsString returns true if this number represents a string value. -func (r *Rat) IsString() bool { - return false -} -// IsSymbol returns true if this number represents a symbol. -func (r *Rat) IsSymbol() bool { - return false -} // Metric returns the metric for this number. func (r *Rat) Metric() *Metric { @@ -368,13 +338,7 @@ func (s *StringNum) String() string { return s.value } -// IsString returns true for StringNum. -func (s *StringNum) IsString() bool { - return true -} -func (s *StringNum) IsBool() bool { return false } -func (s *StringNum) IsSymbol() bool { return false } func (s *StringNum) Metric() *Metric { return GetCoolMetric() } // Symbol represents a variable symbol on the stack. @@ -401,13 +365,7 @@ func (s *Symbol) Name() string { return s.name } -// IsSymbol returns true for Symbol. -func (s *Symbol) IsSymbol() bool { - return true -} -func (s *Symbol) IsBool() bool { return false } -func (s *Symbol) IsString() bool { return false } func (s *Symbol) Metric() *Metric { return GetCoolMetric() } diff --git a/internal/rpn/number_test.go b/internal/rpn/number_test.go index 724e817..71a3657 100644 --- a/internal/rpn/number_test.go +++ b/internal/rpn/number_test.go @@ -36,9 +36,6 @@ func TestFloatString(t *testing.T) { func TestFloatBool(t *testing.T) { f := NewFloatFromBool(true) - if !f.IsBool() { - t.Error("FloatFromBool(true).IsBool() should be true") - } if f.String() != "true" { t.Errorf("FloatFromBool(true).String() = %q, want 'true'", f.String()) } @@ -64,9 +61,6 @@ func TestFloatBool(t *testing.T) { func TestFloatBoolOnNonBool(t *testing.T) { f := NewFloat(42) - if f.IsBool() { - t.Error("Float(42).IsBool() should be false") - } _, err := f.Bool() if err == nil { t.Error("Bool() on non-bool should return error") @@ -100,15 +94,6 @@ func TestFloatIsNegative(t *testing.T) { } } -func TestFloatIsSymbolIsString(t *testing.T) { - f := NewFloat(42) - if f.IsSymbol() { - t.Error("Float.IsSymbol() should be false") - } - if f.IsString() { - t.Error("Float.IsString() should be false") - } -} func TestFloatSetMetricCopy(t *testing.T) { reg := GetMetricRegistry() @@ -192,9 +177,6 @@ func TestRatString(t *testing.T) { func TestRatFromBool(t *testing.T) { r := NewRatFromBool(true) - if !r.IsBool() { - t.Error("RatFromBool(true).IsBool() should be true") - } if r.String() != "true" { t.Errorf("RatFromBool(true).String() = %q, want 'true'", r.String()) } @@ -215,9 +197,6 @@ func TestRatFromBool(t *testing.T) { func TestRatBoolOnNonBool(t *testing.T) { r := NewRat(42) - if r.IsBool() { - t.Error("Rat(42).IsBool() should be false") - } _, err := r.Bool() if err == nil { t.Error("Bool() on non-bool Rat should return error") @@ -242,15 +221,6 @@ func TestRatIsNegative(t *testing.T) { } } -func TestRatIsSymbolIsString(t *testing.T) { - r := NewRat(42) - if r.IsSymbol() { - t.Error("Rat.IsSymbol() should be false") - } - if r.IsString() { - t.Error("Rat.IsString() should be false") - } -} func TestRatSetMetricCopy(t *testing.T) { reg := GetMetricRegistry() @@ -348,18 +318,6 @@ func TestStringNumString(t *testing.T) { } } -func TestStringNumIsString(t *testing.T) { - s := NewStringNum("test") - if !s.IsString() { - t.Error("StringNum.IsString() should be true") - } - if s.IsBool() { - t.Error("StringNum.IsBool() should be false") - } - if s.IsSymbol() { - t.Error("StringNum.IsSymbol() should be false") - } -} func TestStringNumMetricNil(t *testing.T) { s := NewStringNum("test") @@ -384,18 +342,6 @@ func TestSymbolName(t *testing.T) { } } -func TestSymbolIsSymbol(t *testing.T) { - s := NewSymbol("y") - if !s.IsSymbol() { - t.Error("Symbol.IsSymbol() should be true") - } - if s.IsBool() { - t.Error("Symbol.IsBool() should be false") - } - if s.IsString() { - t.Error("Symbol.IsString() should be false") - } -} func TestSymbolMetricNil(t *testing.T) { s := NewSymbol("z") |
