Files
dolt/nomdl/codegen/test/struct_test.go
Chris Masone 9b225dce9b Introduce UnresolvedKind, so TypeRefKind isn't overloaded.
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.
2015-10-19 09:58:27 -07:00

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)
}