mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-04 10:57:50 +08:00
6e36058d0a
- Use reflection to derive function name. - Take test cases as variadic arguments, instead of requiring them to be wrapped in a Table. - Support naming test cases. - Run test cases as subtests with t.Run.
23 lines
451 B
Go
23 lines
451 B
Go
package vals
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"src.elv.sh/pkg/tt"
|
|
)
|
|
|
|
type dissocer struct{}
|
|
|
|
func (dissocer) Dissoc(any) any { return "custom ret" }
|
|
|
|
func TestDissoc(t *testing.T) {
|
|
tt.Test(t, Dissoc,
|
|
Args(MakeMap("k1", "v1", "k2", "v2"), "k1").
|
|
Rets(eq(MakeMap("k2", "v2"))),
|
|
Args(testStructMap{"ls", 1.0}, "score-plus-ten").
|
|
Rets(eq(MakeMap("name", "ls", "score", 1.0))),
|
|
Args(dissocer{}, "x").Rets("custom ret"),
|
|
Args("", "x").Rets(nil),
|
|
)
|
|
}
|