Skip to content

Commit 674ce63

Browse files
szyhfantonmedv
authored andcommitted
Add tests for support method of map.
1 parent dc7e436 commit 674ce63

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

eval_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ type evalErrorTest struct {
2121
err string
2222
}
2323

24+
type evalParams map[string]interface{}
25+
26+
func (p evalParams) Max(a, b float64) float64 {
27+
if a < b {
28+
return b
29+
}
30+
return a
31+
}
32+
33+
func (p evalParams) Min(a, b float64) float64 {
34+
if a < b {
35+
return a
36+
}
37+
return b
38+
}
39+
2440
var evalTests = []evalTest{
2541
{
2642
"foo",
@@ -339,6 +355,16 @@ var evalTests = []evalTest{
339355
map[string]interface{}{"foo": func(in string) string { return "hello " + in }},
340356
"hello world",
341357
},
358+
{
359+
"Max(a, b)",
360+
evalParams{"a": 1.23, "b": 3.21},
361+
3.21,
362+
},
363+
{
364+
"Min(a, b)",
365+
evalParams{"a": 1.23, "b": 3.21},
366+
1.23,
367+
},
342368
}
343369

344370
var evalErrorTests = []evalErrorTest{

0 commit comments

Comments
 (0)