mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
committed by
Bjørn Erik Pedersen
parent
d70f828e2b
commit
325a0dba63
@@ -115,6 +115,13 @@ func init() {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ns.AddMethodMapping(ctx.MaxInt64,
|
||||||
|
nil,
|
||||||
|
[][2]string{
|
||||||
|
{"{{ math.MaxInt64 }}", "9223372036854775807"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
ns.AddMethodMapping(ctx.Min,
|
ns.AddMethodMapping(ctx.Min,
|
||||||
nil,
|
nil,
|
||||||
[][2]string{
|
[][2]string{
|
||||||
|
@@ -147,6 +147,11 @@ func (ns *Namespace) Max(inputs ...any) (maximum float64, err error) {
|
|||||||
return ns.applyOpToScalarsOrSlices("Max", math.Max, inputs...)
|
return ns.applyOpToScalarsOrSlices("Max", math.Max, inputs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaxInt64 returns the maximum value for a signed 64-bit integer.
|
||||||
|
func (ns *Namespace) MaxInt64() int64 {
|
||||||
|
return math.MaxInt64
|
||||||
|
}
|
||||||
|
|
||||||
// Min returns the smaller of all numbers in inputs. Any slices in inputs are flattened.
|
// Min returns the smaller of all numbers in inputs. Any slices in inputs are flattened.
|
||||||
func (ns *Namespace) Min(inputs ...any) (minimum float64, err error) {
|
func (ns *Namespace) Min(inputs ...any) (minimum float64, err error) {
|
||||||
return ns.applyOpToScalarsOrSlices("Min", math.Min, inputs...)
|
return ns.applyOpToScalarsOrSlices("Min", math.Min, inputs...)
|
||||||
|
@@ -879,3 +879,14 @@ func TestToRadians(t *testing.T) {
|
|||||||
c.Assert(result, qt.Equals, test.expect)
|
c.Assert(result, qt.Equals, test.expect)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMaxInt64(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
ns := New(nil)
|
||||||
|
|
||||||
|
var want int64 = 9223372036854775807
|
||||||
|
got := ns.MaxInt64()
|
||||||
|
if want != got {
|
||||||
|
t.Errorf("want %d, got %d", want, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user