mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
27 lines
598 B
Go
27 lines
598 B
Go
package vals
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "src.elv.sh/pkg/tt"
|
|
)
|
|
|
|
func vs(xs ...interface{}) []interface{} { return xs }
|
|
|
|
type keysIterator struct{ keys []interface{} }
|
|
|
|
func (k keysIterator) IterateKeys(f func(interface{}) bool) {
|
|
Feed(f, k.keys...)
|
|
}
|
|
|
|
type nonKeysIterator struct{}
|
|
|
|
func TestIterateKeys(t *testing.T) {
|
|
Test(t, Fn("collectKeys", collectKeys), Table{
|
|
Args(MakeMap("k1", "v1", "k2", "v2")).Rets(vs("k1", "k2"), nil),
|
|
Args(keysIterator{vs("lorem", "ipsum")}).Rets(vs("lorem", "ipsum")),
|
|
Args(nonKeysIterator{}).Rets(
|
|
Any, cannotIterateKeysOf{"!!vals.nonKeysIterator"}),
|
|
})
|
|
}
|