~sircmpwn/go-bare

766d8abb118bad55f5e8535a6daa2f2e9232e985 — Drew DeVault a month ago 4373e95
parser: implement default storage for enums
2 files changed, 14 insertions(+), 2 deletions(-)

M schema/parser.go
M schema/parser_test.go
M schema/parser.go => schema/parser.go +2 -1
@@ 124,7 124,8 @@ func parseUserEnum(scanner *Scanner) (SchemaType, error) {
	case TU64:
		kind = U64
	default:
		return nil, &ErrUnexpectedToken{tok, "enum type"}
		kind = UINT
		scanner.PushBack(tok)
	}

	tok, err = scanner.Next()

M schema/parser_test.go => schema/parser_test.go +12 -1
@@ 230,9 230,14 @@ func TestParseEnumType(t *testing.T) {
			DEVELOPMENT
			JSMITH = 99
		}

		enum MyEnumUint {
			ACCOUNTING
			ADMINISTRATION
		}
	`))
	assert.NoError(t, err)
	assert.Len(t, types, 1)
	assert.Len(t, types, 2)

	ty := types[0]
	assert.IsType(t, new(UserDefinedEnum), ty)


@@ 260,4 265,10 @@ func TestParseEnumType(t *testing.T) {
	val = ude.Values()[4]
	assert.Equal(t, "JSMITH", val.Name())
	assert.Equal(t, uint(99), val.Value())

	ty = types[1]
	assert.IsType(t, new(UserDefinedEnum), ty)
	ude = ty.(*UserDefinedEnum)
	assert.Equal(t, "MyEnumUint", ude.Name())
	assert.Equal(t, UINT, ude.Kind())
}