| Age | Commit message (Collapse) | Author |
|
- Float64() now returns (float64, error) instead of just float64
- All arithmetic methods (Add, Sub, Mul, Div, Pow, Mod, Compare) return errors
- IsString() and IsSymbol() added to Number interface
- Float and Rat now implement IsString() and IsSymbol()
- StringNum and Symbol updated to implement complete Number interface
- IsZero() updated to use val, _ := Float64() pattern
- ToFloat() updated to ignore error from Float64()}
|
|
- Changed Number interface methods to return errors instead of panicking
- Float64() now returns (float64, error)
- Add, Sub, Mul, Pow, Compare, Bool() now return (Number, error) or (int, error)
- StringNum and Symbol now return errors for unsupported operations
- Added IsString() and IsSymbol() to Number interface
- Removed unused arithmetic.go file
- Updated operations.go, boolean_ops.go, hyper.go to handle errors
- Added constants registry (internal/rpn/constants.go) with built-in math constants
- Added constants_test.go with comprehensive unit tests
- Updated README.md with constants documentation
|
|
|
|
|
|
|
|
|
|
|
|
- Extracted RPN assignment handlers to fix SRP violation
- Fixed error handling in test files
- Removed unused StackOperations struct
- Moved integration tests to ./integrationtests folder
- Various code quality improvements
|
|
Integration tests that use the gt tool directly via exec.Command
have been moved from cmd/gt/cli_test.go to integrationtests/cli_test.go.
Unit tests in cmd/gt/main_test.go remain in place as they test
internal functions (runCommand) rather than the binary.
Package declaration changed from 'main' to 'integrationtests'.
|
|
|
|
This struct provided stack manipulation operator implementations but was
never used in the codebase. All stack operations are implemented directly
in the Operations struct in operations.go.
|
|
- 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.
|
|
- Fix error handling in test files by explicitly ignoring error returns
- Remove trailing punctuation from error message in rpn_parse.go
Test file changes:
- cli_test.go: Use _ = os.Remove() in Cleanup function
- concurrent_test.go: Use _, _ = runRPN() in concurrent goroutines
Code change:
- rpn_parse.go: Changed error message to end with 'colon' instead of ':'
|
|
Created specialized handlers for each assignment operator type:
- handleAssignRight (for := operator)
- handleAssignLeft (for =: operator)
- handleStandardAssign (for = operator)
The assignmentHandler uses the Strategy pattern to delegate to specialized
handlers based on the assignment operator found in the input. Each handler
has a single, well-defined responsibility, addressing the SRP violation
in the previous monolithic handleAssignment method.
All tests pass and code quality is maintained.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Renamed internal/calculator directory to internal/perc, updated package name from 'calculator' to 'perc', and updated all import references.
|
|
The 'Rational Number Mode (Optional)' section was positioned right after
the title and before 'Installation', which was confusing for users.
This change moves the section to appear after 'Testing' and before
'License', following a more logical documentation flow:
1. What the tool is (title)
2. How to install it
3. How to use it (core features)
4. Optional advanced features (Rational mode)
5. Building and testing
6. License
|
|
- Fixed Ln operation to handle Value conversion before math.Log using Float64() which handles boolean conversion (true → 1, false → 0)
- Added TestLnWithBoolean and TestLnEdgeCases tests for comprehensive coverage
- Refactored operations.go into separate files (arithmetic.go, boolean_ops.go, hyper.go, stack.go, variable.go)
- Removed unused toNumber function from number.go
- Added Float64() method to Value struct for boolean conversion
|
|
|
|
|
|
|
|
- The Subtract operation pops two values from stack
- Uses the Number interface's Sub method for subtraction
- Boolean values are correctly handled (true=1, false=0)
- All tests pass including boolean-to-number coercion tests
|
|
|
|
|
|
The Granular interfaces already exist in internal/rpn/operations.go:
- ArithmeticOperator: Add, Subtract, Multiply, Divide, Power, Modulo, Log2, Log10, Ln
- BooleanOperator: GT, LT, GTE, LTE, EQ, NEQ
- HyperOperator: HyperAdd, HyperSubtract, HyperMultiply, HyperDivide, HyperPower, HyperModulo, HyperLog2, HyperLog10, HyperLn
- StackOperator: Dup, Swap, Pop, Show
- VariableOperator: ListVariables, ClearVariables
- Operator: combines all the above interfaces
The Operations struct uses these interfaces through composition, adhering to the Interface Segregation Principle.
|
|
The Operator interface is already split into:
- ArithmeticOperator: Add, Subtract, Multiply, Divide, Power, Modulo, Log2, Log10, Ln
- BooleanOperator: GT, LT, GTE, LTE, EQ, NEQ
- HyperOperator: HyperAdd, HyperSubtract, HyperMultiply, HyperDivide, HyperPower, HyperModulo, HyperLog2, HyperLog10, HyperLn
- StackOperator: Dup, Swap, Pop, Show
- VariableOperator: ListVariables, ClearVariables
All granular interfaces are properly defined and the Operations struct implements all of them.
|
|
This commit refactors the internal/rpn package to use the Number interface
instead of the old Value struct for stack values. Key changes:
1. Updated Number interface to include IsBool() and Bool() methods for
boolean value support
2. Modified Float and Rat types to support boolean mode with:
- isBool and boolVal fields
- Float64() returns 1 for true, 0 for false
- String() returns 'true' or 'false' for boolean values
3. Updated Stack to use []Number instead of []Value
4. Updated all operations to use the Number interface methods directly
- Add, Sub, Mul, Div, Pow, Mod now use Float64() for values
5. Updated tests to use NewNumber() with mode parameter instead of
NewNumberValue(), and use Float64() instead of Number()
Benefits:
- Simplified code - no need for toNumber() and NewNumberValue() wrappers
- Better type safety - stack values are Number interface instances
- Boolean-to-number coercion works correctly in all operations
|
|
|
|
- Changed GetCurrentStack() to return []Value to preserve value types
- Updated test to use Value.Number() method for comparison
- Boolean values are now correctly preserved in stack inspection
This ensures that boolean values returned from comparison operators
(gt, lt, etc.) are preserved when inspecting the stack.
|