Files
dolt/types/assert.go
Chris Masone eda9b92870 Rename types.TypeRef to types.Type
There are probably still a lot of variable names and comments to fix,
but this updates all the Go code.

Towards #441
2015-11-09 08:26:32 -08:00

32 lines
702 B
Go

package types
import "github.com/attic-labs/noms/d"
func assertType(t Type, v ...Value) {
if t.Kind() != ValueKind {
for _, v := range v {
d.Chk.True(t.Equals(v.Type()), "Invalid type. Expected: %s, found: %s", t.Describe(), v.Type().Describe())
}
}
}
func assertSetsSameType(s Set, v ...Set) {
if s.elemType().Kind() != ValueKind {
t := s.Type()
for _, v := range v {
d.Chk.True(t.Equals(v.Type()))
}
}
}
func assertMapElemTypes(m Map, v ...Value) {
elemTypes := m.elemTypes()
keyType := elemTypes[0]
valueType := elemTypes[0]
if keyType.Kind() != ValueKind || valueType.Kind() != ValueKind {
for i, v := range v {
d.Chk.True(elemTypes[i%2].Equals(v.Type()))
}
}
}