Debian Codegraph @

execution/func_abs_test.go

raw symbols SCIP
1 package execution_test
2
3 import (
4 "testing"
5
6 "github.com/tomwright/dasel/v3/model"
7 )
8
9 func TestFuncAbs(t *testing.T) {
10 t.Run("positive int", testCase{
11 s: `abs(5)`,
12 out: model.NewIntValue(5),
13 }.run)
14 t.Run("negative int", testCase{
15 s: `abs(-5)`,
16 out: model.NewIntValue(5),
17 }.run)
18 t.Run("zero", testCase{
19 s: `abs(0)`,
20 out: model.NewIntValue(0),
21 }.run)
22 t.Run("positive float", testCase{
23 s: `abs(3.14)`,
24 out: model.NewFloatValue(3.14),
25 }.run)
26 t.Run("negative float", testCase{
27 s: `abs(-3.14)`,
28 out: model.NewFloatValue(3.14),
29 }.run)
30 t.Run("chained int", testCase{
31 s: `(-5).abs()`,
32 out: model.NewIntValue(5),
33 }.run)
34 }