Skip to content

Commit

Permalink
Merge 3100267 into ae73793
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav committed Aug 29, 2018
2 parents ae73793 + 3100267 commit b6dfc03
Show file tree
Hide file tree
Showing 9 changed files with 381 additions and 71 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- gen/enum: `MarshalText` and `UnmarshalText` now round-trips, even if
the enum value is unrecognized.

### Fixed
- gen: Fixed a bug where `*_Values` functions for empty enums would not be
generated.

## [1.12.0] - 2018-06-25
### Added
- gen: Added `ThriftPackageImporter` to control import path
Expand Down
12 changes: 4 additions & 8 deletions gen/collision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,17 +557,13 @@ func roundTrip(t *testing.T, x thriftType, msg string) thriftType {
xType = xType.Elem()
}

gotX := reflect.New(xType)
errval := gotX.MethodByName("FromWire").
Call([]reflect.Value{reflect.ValueOf(newV)})[0].
Interface()

if !assert.Nil(t, errval, "FromWire: %v", msg) {
gotX := reflect.New(xType).Interface().(thriftType)
if err := gotX.FromWire(newV); !assert.NoError(t, err, "FromWire: %v", msg) {
return nil
}

assert.Equal(t, x, gotX.Interface(), "FromWire: %v", msg)
return gotX.Interface().(thriftType)
assert.Equal(t, x, gotX, "FromWire: %v", msg)
return gotX
}

func TestCollisionAccessors(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gen/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func enum(g Generator, spec *compile.EnumSpec) error {
<- formatDoc .Doc><enumItemName $enumName .> <$enumName> = <.Value>
<end>
)
<end>
// <$enumName>_Values returns all recognized values of <$enumName>.
func <$enumName>_Values() []<$enumName> {
Expand All @@ -88,7 +89,6 @@ func enum(g Generator, spec *compile.EnumSpec) error {
<end>
}
}
<end>
<$v := newVar "v">
<$value := newVar "value">
Expand Down
5 changes: 5 additions & 0 deletions gen/internal/tests/enums/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b6dfc03

Please sign in to comment.