Example #1
0
func getFieldNamesFromStruct(structDesc types.StructDesc) (fieldNames []string) {
	structDesc.IterFields(func(name string, t *types.Type) {
		d.Exp.True(types.IsPrimitiveKind(t.Kind()))
		fieldNames = append(fieldNames, name)
	})
	return
}
Example #2
0
func (suite *ParserTestSuite) TestStructParse() {
	oneLine := "struct str { a :Bool b : Blob c: Blob }"
	suite.parseNotPanics(oneLine)

	noSpace := "struct str{a:Bool}"
	suite.parseNotPanics(noSpace)

	multiLine := "\nstruct str {\na :Bool\n}"
	suite.parseNotPanics(multiLine)

	for k, v := range types.KindToString {
		if types.IsPrimitiveKind(k) {
			suite.parseNotPanics(fmt.Sprintf(structTmpl, "s", "a :"+v, ""))
		}
	}
}
Example #3
0
func isPrimitiveOrRef(v1 types.Value) bool {
	kind := v1.Type().Kind()
	return types.IsPrimitiveKind(kind) || kind == types.RefKind
}
Example #4
0
func shouldDescend(v1, v2 types.Value) bool {
	kind := v1.Type().Kind()
	return !types.IsPrimitiveKind(kind) && kind == v2.Type().Kind() && kind != types.RefKind
}