@@ -7,14 +7,15 @@ import (
7
7
"testing"
8
8
"time"
9
9
10
+ "github.com/stretchr/testify/assert"
11
+ "github.com/stretchr/testify/require"
12
+
10
13
"github.com/antonmedv/expr"
11
14
"github.com/antonmedv/expr/builtin"
12
15
"github.com/antonmedv/expr/checker"
13
16
"github.com/antonmedv/expr/conf"
14
17
"github.com/antonmedv/expr/parser"
15
18
"github.com/antonmedv/expr/test/mock"
16
- "github.com/stretchr/testify/assert"
17
- "github.com/stretchr/testify/require"
18
19
)
19
20
20
21
func TestBuiltin (t * testing.T ) {
@@ -403,6 +404,7 @@ func TestBuiltin_sort(t *testing.T) {
403
404
env := map [string ]any {
404
405
"ArrayOfString" : []string {"foo" , "bar" , "baz" },
405
406
"ArrayOfInt" : []int {3 , 2 , 1 },
407
+ "ArrayOfFloat" : []float64 {3.0 , 2.0 , 1.0 },
406
408
"ArrayOfFoo" : []mock.Foo {{Value : "c" }, {Value : "a" }, {Value : "b" }},
407
409
}
408
410
tests := []struct {
@@ -411,6 +413,7 @@ func TestBuiltin_sort(t *testing.T) {
411
413
}{
412
414
{`sort([])` , []any {}},
413
415
{`sort(ArrayOfInt)` , []any {1 , 2 , 3 }},
416
+ {`sort(ArrayOfFloat)` , []any {1.0 , 2.0 , 3.0 }},
414
417
{`sort(ArrayOfInt, 'desc')` , []any {3 , 2 , 1 }},
415
418
{`sortBy(ArrayOfFoo, 'Value')` , []any {mock.Foo {Value : "a" }, mock.Foo {Value : "b" }, mock.Foo {Value : "c" }}},
416
419
{`sortBy([{id: "a"}, {id: "b"}], "id", "desc")` , []any {map [string ]any {"id" : "b" }, map [string ]any {"id" : "a" }}},
0 commit comments