| Age | Commit message (Collapse) | Author |
|
- Added boolean operators (gt, lt, gte, lte, eq, neq)
- Implemented boolean-to-number coercion in arithmetic
- Added comprehensive tests for boolean operators
This is a minor version bump (new features).
|
|
- Value type created as variant type holding float64 or bool
- Stack uses []Value to store values
- Push/Pop work with Value type
- toNumber() converts Value to float64 for arithmetic
See Value type in internal/rpn/variables.go for implementation.
|
|
- GT, LT, GTE, LTE, EQ, NEQ implemented in operations.go
- Registered as both word form (gt, lt, etc.) and symbol form (>, <, etc.)
- Each operator compares two numeric operands and pushes a boolean Value
See commit 5cb2c02 for implementation details.
|
|
- Added boolean operators: GT, LT, GTE, LTE, EQ, NEQ
- Registered as: gt, lt, gte, lte, eq, neq
- Also registered symbols: >, <, >=, <=, ==, !=
- Added boolean literal support:
- true and false are now recognized as boolean values
- Can be used in expressions like: true 2 *, 0 false +
- Fixed boolean formatting:
- Show command now displays booleans as 'true'/'false'
- Single result output uses Value.String() instead of toNumber()
- Created boolean_test.go with comprehensive tests:
- TestBooleanOperators: Tests all 6 boolean operators
- TestBooleanToNumberCoercion: Tests automatic coercion in arithmetic
- TestMixedBooleanNumericArithmetic: Tests mixed boolean-numeric arithmetic
- TestBooleanShowFormat: Tests Show command displays booleans correctly
All tests pass and the binary builds correctly.
|
|
- Updated internal/version.go to v0.2.2
- Added boolean_coercion_test.go with tests for boolean-to-number coercion
- Note: Boolean operators (> < == != etc.) not yet implemented (task 3cc6a147)
Tests use NewBoolValue() which requires direct Value manipulation
- CI workflow already runs all tests with go test ./...
- Added coverage check (60% minimum) in .github/workflows/ci.yml
When boolean operators are implemented, the boolean_coercion_test.go
can be re-enabled with tests using comparison operators.
|
|
- Rational Number Mode section with usage examples (rat on/off/toggle)
- Hyper Operators section with examples ([+], [*], [-], [/], [^], [%])
No code changes needed - documentation was completed earlier.
|
|
- Added Lint target: runs golangci-lint for code quality checks
- Added Release target: builds and packages releases (requires goreleaser)
Also fixed errcheck linting issue:
- Check error return from o.vars.SetVariable in AssignVariable
All mage targets work: build, run, test, testRPN, rpn, install, lint, release, repl, uninstall
|
|
- Quick start guide for contributors
- Build instructions (mage and go direct)
- Test instructions (mage test, mage testRPN, coverage)
- Code style guidelines (Go best practices, documentation)
- PR guidelines (before submitting, description, review process)
- Development workflow (branching, committing, pushing)
|
|
- Updated .github/workflows/ci.yml to run tests with coverage
- Enforces minimum 60% coverage threshold
- Uploads coverage report as artifact for review
Coverage check command:
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out | grep total
|
|
- All stack.Push() calls in internal/rpn/rpn.go use NewNumberValue() for proper Value type
- No raw float64 values pushed directly to stack
No code changes needed - implementation was completed in earlier refactoring.
|
|
- toNumber(v Value) float64 maps true→1, false→0, numbers unchanged
- All arithmetic operators (Add, Subtract, Multiply, Divide, Power, Modulo) use toNumber
- Also used in all Hyper* operators and comparisons
No code changes needed - implementation was completed in earlier refactoring.
|
|
- Changed Show to use val.String() instead of NewNumber(toNumber(val), o.mode)
- Boolean values now display as 'true'/'false' instead of '1'/'0'
- Number values preserve their numeric formatting
The Show command now correctly handles mixed boolean-numeric stacks,
displaying booleans as 'true'/'false' and numbers with appropriate precision.
|
|
- Added 'SPDX-License-Identifier: MIT' and 'Copyright (c) 2026 Paul Buetow' headers
- Files updated: 24 .go files across cmd/gt/, internal/calculator/, internal/repl/, internal/rpn/
The MIT license from LICENSE file is reflected in all source files.
|
|
- Added documentation section to README.md explaining automatic coercion
- Included usage examples: '5 3 == 1 +', '0 false +', 'true 2 *', '9 3 > 4 5 < +'
- Updated Value type godoc to explain coercion behavior (true→1, false→0)
- toNumber() function already had good documentation
The coercion allows boolean results to be used directly in arithmetic operations,
enabling expressions like '5 3 == 1 +' where '5 3 ==' produces false=0, then '0 + 1' produces 1.
|
|
- Updated operator registration in rpn/operations.go:
- registerStandardOperator now wraps handler errors with operator name context
- registerCommandOperator now wraps handler errors with operator name context
- registerHyperOperator now wraps handler errors with operator name context
- Updated Parse() in calculator/calculator.go:
- Now wraps registry.parse() errors with context about the input
- Returns a more descriptive error when parsing fails
All tests pass and the binary builds and runs correctly.
|
|
- Updated HyperMultiply, HyperSubtract, HyperDivide, HyperPower, HyperModulo
to use []Value and toNumber() for Value-to-float64 conversions
- Updated HyperLog2, HyperLog10, HyperLn to use []Value and toNumber()
- Fixed rpn.go:
- Stack.Push() now uses NewNumberValue() for float64 values
- GetCurrentStack() converts []Value to []float64
- show() output uses toNumber() for Value formatting
- Variable handling uses NewNumberValue() when pushing
- Fixed test files (operations_test.go):
- Updated all Stack.Push() calls to use NewNumberValue()
- Updated Pop() comparisons to use .Number() method
- Fixed format specifiers for Errorf() calls
All tests pass and the binary builds and runs correctly.
|
|
- Removed duplicate getCommandDescription function from completer.go
- Added package-level getCommandDescription in repl.go as single source of truth
- Updated defaultGetCommandDescription to delegate to getCommandDescription
- Created minimal completer.go that uses getCommandDescription for test compatibility
Command descriptions are now defined only once, eliminating duplication
between the original completer.go and defaultGetCommandDescription in repl.go.
The refactoring maintains:
- Backward compatibility (tests still work)
- Consistent descriptions across the codebase
- Single source of truth for command descriptions
|
|
- Enhanced NewREPL documentation with detailed parameter descriptions
- Enhanced RunREPL documentation clarifying it's a convenience wrapper
- Improved executor documentation explaining backward compatibility and testing usage
- Enhanced defaultExecutor documentation with input processing details and panic recovery
- Enhanced defaultCompleter documentation with tab-completion behavior details
- Enhanced defaultGetCommandDescription documentation with command description details
- Improved TTYChecker methods (IsTTY, EnsureTTY) documentation
- Improved SignalHandler.Start method documentation
All exported and non-exported functions in the REPL package now have comprehensive documentation comments that describe their purpose, parameters, and return values.
|
|
- Enhanced Package gt documentation with detailed usage examples for percentage calculations and RPN expressions
- Added architecture overview section
- Enhanced Package internal documentation with version format, build instructions, and usage examples
- All tests pass and application builds correctly
|
|
- Add TestDefaultExecutorCodePaths to test all code paths in defaultExecutor
- Improve TestDefaultCompleter to test with multiple input prefixes
- Add comprehensive test for unknown commands, built-in commands, and edge cases
|
|
- Move RPNState type definition before any functions
- Move rpnState and rpnStateOnce variable declarations before any functions
- Keep REPL struct and NewREPL constructor at the top (as per Go best practices)
- Update getRPNState comment to be more descriptive
This change follows Go best practices where constants, global variables, and type
definitions should be at the top of the file before functions.
|
|
- Add RPN (Reverse Polish Notation) calculator with stack-based operations
- Support precise rational number calculations using *big.Rat
- Implement chain of responsibility pattern for command handling
- Add auto-completion for built-in commands
- Add history persistence with configurable max entries
- Support standard operators: +, -, *, /, ^, %, lg, log, ln
- Support hyper operators: [+], [-], [*], [/], [^], [%], [lg], [log], [ln]
- Support stack manipulation: dup, swap, pop, show
- Support variable assignments and management
- Add rat mode for switching between float64 and rational calculations
- Refactor calculator to return Calculation struct with formatting
- Add proper version support (v0.3.0)
All changes follow Go best practices with comprehensive test coverage.
|
|
|
|
|
|
- Added executeOperator helper method to handle both standard and hyper operators
- Updated handleOperator, EvalOperator, and ResultStack to use executeOperator
- Removed handleHyperOperatorWithRegistry method (no longer needed)
- Consolidated duplicate operator handling logic into single helper
This improves code maintainability by following DRY principle - operator
handling logic is now in one place (executeOperator).
All tests pass including hyper operator tests. 1 file changed, 23 insertions(+),
28 deletions(-).
|
|
- Removed parseRPNFallback from strategy registry
- Parse() now only handles percentage calculations (no RPN fallback)
- ParseRPN() is now a separate, explicit function for RPN expressions
- Added clear documentation explaining Parse() only handles percentages
- Removed TestParseRPNFallthrough test (tested implicit RPN fallback)
This makes the codebase easier to understand and maintain by having
clear boundaries between percentage and RPN parsing.
All tests pass. 2 files changed, 1 deletion(-).
|
|
- Renamed binary from perc to gt throughout the project
- Refactored calculator.Parse to use registration pattern for parsing strategies
- Refactored rpn.handleOperator to use operator registry instead of switch statements
- Added panic recovery to REPL executor for better resilience
- Improved code organization with OperatorRegistry and strategy registration
All changes maintain full test compatibility and pass race detection tests.
|
|
Added defer-recover mechanism to the executor function to catch unexpected panics.
When a panic occurs, a user-friendly error message is displayed and the REPL can continue to function.
This improves the robustness of the REPL when handling unexpected errors.
|
|
Created OperatorRegistry with HandleStandardOperator and HandleHyperOperator methods.
Operators are now registered at RPN initialization instead of being handled in switch statements.
This makes the code more maintainable and extensible.
|
|
Created ParsingStrategy type and strategyRegistry struct to manage parsing strategies.
All parsing strategies are now registered in a registry and executed in sequence.
This makes the parsing logic more maintainable and extensible.
|
|
- Error wrapping improvements across multiple files
- Thread-safe singleton initialization using sync.Once
- Proper error handling for file close operations
- Removed speculative complexity in history management
- Fixed operator interface design
Audit report: COMPLETE_AUDIT_REPORT.md
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Update handleAssignment to detect ' =' (space before equals) not just ' = ' (with trailing space)
- Allow assignment without trailing expression: 'x 5 =' instead of 'x 5 = expr'
- This fixes the REPL assignment syntax 'name value =' that was previously failing
The fix also enables command-line usage like 'perc calc x 5 =' to work correctly.
|
|
- Add comprehensive unit tests for REPL package
- Add completer logic tests to cover edge cases
- Integrate RPN as fallback in calculator.Parse()
- Add ParseRPN function to calculator package
- Add tests for RPN fallthrough path
The changes bring overall test coverage from ~70% to 81.9%.
|
|
- Use error wrapping with ErrVariableNotFound for consistent error checking
- Add isValidVariableName() for comprehensive variable name validation
- Fix race condition in ClearVariables() by clearing instead of replacing map
- Eliminate double-locking in FormatVariables() with internal helper function
|
|
|
|
- Configured common linters (gofmt, goimports, govet, errcheck, etc.)
- Set local-prefixes for goimports to include project's module path
|