mirror of
https://github.com/hanzoai/numscript.git
synced 2026-10-30 18:26:57 +00:00
* feat: feature flag syntax * feat: change syntax * feat: reject invalid features * feat: add static check of unknown features * feat: more defensive args handling * fix: fix typo
27 lines
608 B
Go
27 lines
608 B
Go
package parser_test
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
|
|
"github.com/formancehq/numscript/internal/parser"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPercentageLiteralToRatio(t *testing.T) {
|
|
assert.Equal(t, big.NewRat(123, 100), parser.PercentageLiteral{
|
|
Amount: big.NewInt(123),
|
|
FloatingDigits: 0,
|
|
}.ToRatio())
|
|
|
|
assert.Equal(t, big.NewRat(123, 1000), parser.PercentageLiteral{
|
|
Amount: big.NewInt(123),
|
|
FloatingDigits: 1,
|
|
}.ToRatio())
|
|
|
|
assert.Equal(t, big.NewRat(123, 10000), parser.PercentageLiteral{
|
|
Amount: big.NewInt(123),
|
|
FloatingDigits: 2,
|
|
}.ToRatio())
|
|
}
|