mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-19 18:19:43 -06:00
We'd wound up in a spot where serialization code used 'TypeRefKind' to mean one of two very different things...either an actual value that describes some Noms type, or a reference to a type definition that lives somewhere else. To get rid of this ambiguity, we introduce 'UnresolvedKind' to take over the latter meaning. Now, TypeRefKind means _only_ a value that describes a type. If you want to point off to a type definition elsewhere in the type package, or in another type package, use UnresolvedKind.
57 lines
1.0 KiB
Go
57 lines
1.0 KiB
Go
package test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/stretchr/testify/assert"
|
|
"github.com/attic-labs/noms/types"
|
|
)
|
|
|
|
func TestDef(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
def := StructDef{"hi", true}
|
|
st := def.New()
|
|
|
|
def2 := st.Def()
|
|
st2 := def.New()
|
|
|
|
assert.Equal(def, def2)
|
|
assert.True(st.Equals(st2))
|
|
|
|
st3 := NewStruct()
|
|
st3 = st3.SetS("hi").SetB(true)
|
|
assert.Equal("hi", st3.S())
|
|
assert.Equal(true, st3.B())
|
|
}
|
|
|
|
func TestValue(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
def := StructDef{"hi", true}
|
|
st := def.New()
|
|
val := st.NomsValue()
|
|
st2 := StructFromVal(val)
|
|
assert.True(st.Equals(st2))
|
|
}
|
|
|
|
func TestTypeRef(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
def := StructDef{"hi", true}
|
|
st := def.New()
|
|
typ := st.TypeRef()
|
|
assert.EqualValues(0, typ.Ordinal())
|
|
assert.Equal(types.UnresolvedKind, typ.Kind())
|
|
}
|
|
|
|
func TestStructChunks(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
st := StructDef{"hi", true}.New()
|
|
cs := st.Chunks()
|
|
|
|
// One chunk for the TypeRef
|
|
assert.Len(cs, 1)
|
|
}
|