@@ -7,14 +7,15 @@ import (
77 "testing"
88 "time"
99
10+ "github.com/stretchr/testify/assert"
11+ "github.com/stretchr/testify/require"
12+
1013 "github.com/antonmedv/expr"
1114 "github.com/antonmedv/expr/builtin"
1215 "github.com/antonmedv/expr/checker"
1316 "github.com/antonmedv/expr/conf"
1417 "github.com/antonmedv/expr/parser"
1518 "github.com/antonmedv/expr/test/mock"
16- "github.com/stretchr/testify/assert"
17- "github.com/stretchr/testify/require"
1819)
1920
2021func TestBuiltin (t * testing.T ) {
@@ -403,6 +404,7 @@ func TestBuiltin_sort(t *testing.T) {
403404 env := map [string ]any {
404405 "ArrayOfString" : []string {"foo" , "bar" , "baz" },
405406 "ArrayOfInt" : []int {3 , 2 , 1 },
407+ "ArrayOfFloat" : []float64 {3.0 , 2.0 , 1.0 },
406408 "ArrayOfFoo" : []mock.Foo {{Value : "c" }, {Value : "a" }, {Value : "b" }},
407409 }
408410 tests := []struct {
@@ -411,6 +413,7 @@ func TestBuiltin_sort(t *testing.T) {
411413 }{
412414 {`sort([])` , []any {}},
413415 {`sort(ArrayOfInt)` , []any {1 , 2 , 3 }},
416+ {`sort(ArrayOfFloat)` , []any {1.0 , 2.0 , 3.0 }},
414417 {`sort(ArrayOfInt, 'desc')` , []any {3 , 2 , 1 }},
415418 {`sortBy(ArrayOfFoo, 'Value')` , []any {mock.Foo {Value : "a" }, mock.Foo {Value : "b" }, mock.Foo {Value : "c" }}},
416419 {`sortBy([{id: "a"}, {id: "b"}], "id", "desc")` , []any {map [string ]any {"id" : "b" }, map [string ]any {"id" : "a" }}},
0 commit comments