Files
dolt/nomdl/codegen/test/struct_test.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

58 lines
1.1 KiB
Go

package test
import (
"testing"
"github.com/attic-labs/noms/Godeps/_workspace/src/github.com/stretchr/testify/assert"
"github.com/attic-labs/noms/nomdl/codegen/test/gen"
"github.com/attic-labs/noms/types"
)
func TestDef(t *testing.T) {
assert := assert.New(t)
def := gen.StructDef{"hi", true}
st := def.New()
def2 := st.Def()
st2 := def.New()
assert.Equal(def, def2)
assert.True(st.Equals(st2))
st3 := gen.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 := gen.StructDef{"hi", true}
var st types.Value
st = def.New()
st2 := st.(gen.Struct)
assert.True(st.Equals(st2))
}
func TestTypeRef(t *testing.T) {
assert := assert.New(t)
def := gen.StructDef{"hi", true}
st := def.New()
typ := st.Type()
assert.EqualValues(0, typ.Ordinal())
assert.Equal(types.UnresolvedKind, typ.Kind())
}
func TestStructChunks(t *testing.T) {
assert := assert.New(t)
st := gen.StructDef{"hi", true}.New()
cs := st.Chunks()
// One chunk for the Type
assert.Len(cs, 1)
}