mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-30 19:09:34 -06:00
If we have a List, Map, Set or Ref with a non Value element type we now check the type of the params to functions that "mutate" these.
32 lines
641 B
Go
32 lines
641 B
Go
package types
|
|
|
|
import "github.com/attic-labs/noms/d"
|
|
|
|
func assertType(t TypeRef, v ...Value) {
|
|
if t.Kind() != ValueKind {
|
|
for _, v := range v {
|
|
d.Chk.True(t.Equals(v.TypeRef()))
|
|
}
|
|
}
|
|
}
|
|
|
|
func assertSetsSameType(s Set, v ...Set) {
|
|
if s.elemType().Kind() != ValueKind {
|
|
t := s.TypeRef()
|
|
for _, v := range v {
|
|
d.Chk.True(t.Equals(v.TypeRef()))
|
|
}
|
|
}
|
|
}
|
|
|
|
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.TypeRef()))
|
|
}
|
|
}
|
|
}
|