Skip to content

Commit

Permalink
Add tests for support method of map.
Browse files Browse the repository at this point in the history
  • Loading branch information
szyhf authored and antonmedv committed Jan 19, 2019
1 parent dc7e436 commit 674ce63
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ type evalErrorTest struct {
err string
}

type evalParams map[string]interface{}

func (p evalParams) Max(a, b float64) float64 {
if a < b {
return b
}
return a
}

func (p evalParams) Min(a, b float64) float64 {
if a < b {
return a
}
return b
}

var evalTests = []evalTest{
{
"foo",
Expand Down Expand Up @@ -339,6 +355,16 @@ var evalTests = []evalTest{
map[string]interface{}{"foo": func(in string) string { return "hello " + in }},
"hello world",
},
{
"Max(a, b)",
evalParams{"a": 1.23, "b": 3.21},
3.21,
},
{
"Min(a, b)",
evalParams{"a": 1.23, "b": 3.21},
1.23,
},
}

var evalErrorTests = []evalErrorTest{
Expand Down

0 comments on commit 674ce63

Please sign in to comment.