mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-31 03:18:43 -06:00
The generated code for typed structs now uses a Go struct which implements Value directly. The fields in this struct uses the "user" type. (The union value still uses types.Value though.) When a typed struct is created by the decoder, it asks for a struct builder which returns a channel that the values of the fields of the struct are sent to.
32 lines
720 B
Go
32 lines
720 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()), "Invalid type. Expected: %s, found: %s", t.Describe(), v.TypeRef().Describe())
|
|
}
|
|
}
|
|
}
|
|
|
|
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()))
|
|
}
|
|
}
|
|
}
|