mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 18:07:51 +08:00
71cd3835bc
Qualified imports of pkg/tt outnumber unqualified (27 to 24). Improve consistency, and clarity, by changing the dot (unqualified) imports of that package symbols to qualified.
33 lines
814 B
Go
33 lines
814 B
Go
package vals
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"src.elv.sh/pkg/tt"
|
|
)
|
|
|
|
type hasKeyer struct{ key any }
|
|
|
|
func (h hasKeyer) HasKey(k any) bool { return k == h.key }
|
|
|
|
func TestHasKey(t *testing.T) {
|
|
tt.Test(t, tt.Fn("HasKey", HasKey), tt.Table{
|
|
// Map
|
|
Args(MakeMap("k", "v"), "k").Rets(true),
|
|
Args(MakeMap("k", "v"), "bad").Rets(false),
|
|
// HasKeyer
|
|
Args(hasKeyer{"valid"}, "valid").Rets(true),
|
|
Args(hasKeyer{"valid"}, "invalid").Rets(false),
|
|
// Fallback to IterateKeys
|
|
Args(keysIterator{vs("lorem")}, "lorem").Rets(true),
|
|
Args(keysIterator{vs("lorem")}, "ipsum").Rets(false),
|
|
// Fallback to Len
|
|
Args(MakeList("lorem", "ipsum"), "0").Rets(true),
|
|
Args(MakeList("lorem", "ipsum"), "0..").Rets(true),
|
|
Args(MakeList("lorem", "ipsum"), "2").Rets(false),
|
|
|
|
// Non-container
|
|
Args(1, "0").Rets(false),
|
|
})
|
|
}
|