Skip to content

Commit

Permalink
Rename: s/ReturnTypeStructs/ReturnTypeStatements/g
Browse files Browse the repository at this point in the history
  • Loading branch information
moznion committed Jan 22, 2019
1 parent f275574 commit 308afd2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions generator/func_signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ func (f *FuncSignature) Parameters(funcParameters ...*FuncParameter) *FuncSignat
// AddReturnTypes adds return types of the func to `FuncSignature`. This does *not* set, just add.
//
// This method accepts a return type as `string`. If you want to use the parameter as named one,
// please consider using `AddReturnTypeStructs()` instead of this (or use this method with string parameter like: `err error`).
// please consider using `AddReturnTypeStatements()` instead of this (or use this method with string parameter like: `err error`).
//
// This method returns a *new* `FuncSignature`; it means this method acts as immutable.
func (f *FuncSignature) AddReturnTypes(returnTypes ...string) *FuncSignature {
types := make([]*FuncReturnType, len(returnTypes))
for i, typ := range returnTypes {
types[i] = NewFuncReturnType(typ)
}
return f.AddReturnTypeStructs(types...)
return f.AddReturnTypeStatements(types...)
}

// AddReturnTypeStructs sets return types of the func to `FuncSignature`. This does *not* add, just set.
// AddReturnTypeStatements sets return types of the func to `FuncSignature`. This does *not* add, just set.
// This method returns a *new* `FuncSignature`; it means this method acts as immutable.
func (f *FuncSignature) AddReturnTypeStructs(returnTypes ...*FuncReturnType) *FuncSignature {
func (f *FuncSignature) AddReturnTypeStatements(returnTypes ...*FuncReturnType) *FuncSignature {
return &FuncSignature{
funcName: f.funcName,
funcParameters: f.funcParameters,
Expand All @@ -127,20 +127,20 @@ func (f *FuncSignature) AddReturnTypeStructs(returnTypes ...*FuncReturnType) *Fu
// ReturnTypes sets return types of the func to `FuncSignature`. This does *not* add, just set.
//
// This method accepts a return type as `string`. If you want to use the parameter as named one,
// please consider using `ReturnTypeStructs()` instead of this (or use this method with string parameter like: `err error`).
// please consider using `ReturnTypeStatements()` instead of this (or use this method with string parameter like: `err error`).
//
// This method returns a *new* `FuncSignature`; it means this method acts as immutable.
func (f *FuncSignature) ReturnTypes(returnTypes ...string) *FuncSignature {
types := make([]*FuncReturnType, len(returnTypes))
for i, typ := range returnTypes {
types[i] = NewFuncReturnType(typ)
}
return f.ReturnTypeStructs(types...)
return f.ReturnTypeStatements(types...)
}

// ReturnTypeStructs sets return types of the func to `FuncSignature`. This does *not* add, just set.
// ReturnTypeStatements sets return types of the func to `FuncSignature`. This does *not* add, just set.
// This method returns a *new* `FuncSignature`; it means this method acts as immutable.
func (f *FuncSignature) ReturnTypeStructs(returnTypes ...*FuncReturnType) *FuncSignature {
func (f *FuncSignature) ReturnTypeStatements(returnTypes ...*FuncReturnType) *FuncSignature {
return &FuncSignature{
funcName: f.funcName,
funcParameters: f.funcParameters,
Expand Down
20 changes: 10 additions & 10 deletions generator/func_signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,21 +118,21 @@ func TestShouldGeneratingFuncSignatureWithReturnTypeStructs(t *testing.T) {
{
generator := NewFuncSignature("myFunc")
{
generator = generator.AddReturnTypeStructs(NewFuncReturnType("string"))
generator = generator.AddReturnTypeStatements(NewFuncReturnType("string"))
sig, err := generator.Generate(0)
assert.NoError(t, err)
assert.Equal(t, "myFunc() string", sig)
}

{
generator = generator.AddReturnTypeStructs(NewFuncReturnType("error"))
generator = generator.AddReturnTypeStatements(NewFuncReturnType("error"))
sig, err := generator.Generate(0)
assert.NoError(t, err)
assert.Equal(t, "myFunc() (string, error)", sig)
}

{
generator = generator.ReturnTypeStructs(NewFuncReturnType("error"))
generator = generator.ReturnTypeStatements(NewFuncReturnType("error"))
sig, err := generator.Generate(0)
assert.NoError(t, err)
assert.Equal(t, "myFunc() error", sig)
Expand All @@ -142,21 +142,21 @@ func TestShouldGeneratingFuncSignatureWithReturnTypeStructs(t *testing.T) {
{
generator := NewFuncSignature("myFunc")
{
generator = generator.AddReturnTypeStructs(NewFuncReturnType("string", "foo"))
generator = generator.AddReturnTypeStatements(NewFuncReturnType("string", "foo"))
sig, err := generator.Generate(0)
assert.NoError(t, err)
assert.Equal(t, "myFunc() (foo string)", sig)
}

{
generator = generator.AddReturnTypeStructs(NewFuncReturnType("error", "bar"))
generator = generator.AddReturnTypeStatements(NewFuncReturnType("error", "bar"))
sig, err := generator.Generate(0)
assert.NoError(t, err)
assert.Equal(t, "myFunc() (foo string, bar error)", sig)
}

{
generator = generator.ReturnTypeStructs(NewFuncReturnType("error", "foo"))
generator = generator.ReturnTypeStatements(NewFuncReturnType("error", "foo"))
sig, err := generator.Generate(0)
assert.NoError(t, err)
assert.Equal(t, "myFunc() (foo error)", sig)
Expand All @@ -165,8 +165,8 @@ func TestShouldGeneratingFuncSignatureWithReturnTypeStructs(t *testing.T) {

{
generator := NewFuncSignature("myFunc").
AddReturnTypeStructs(NewFuncReturnType("", "foo")).
AddReturnTypeStructs(NewFuncReturnType("string", "bar"))
AddReturnTypeStatements(NewFuncReturnType("", "foo")).
AddReturnTypeStatements(NewFuncReturnType("string", "bar"))
sig, err := generator.Generate(0)
assert.NoError(t, err)
assert.Equal(t, "myFunc() (foo, bar string)", sig)
Expand All @@ -175,8 +175,8 @@ func TestShouldGeneratingFuncSignatureWithReturnTypeStructs(t *testing.T) {

func TestShouldGeneratingFuncSignatureRaisesUnnamedRetTypeIsAfterNamedRetType(t *testing.T) {
generator := NewFuncSignature("myFunc").
AddReturnTypeStructs(NewFuncReturnType("string", "foo")).
AddReturnTypeStructs(NewFuncReturnType("error", ""))
AddReturnTypeStatements(NewFuncReturnType("string", "foo")).
AddReturnTypeStatements(NewFuncReturnType("error", ""))
_, err := generator.Generate(0)
assert.Regexp(t, regexp.MustCompile(
`^\`+strings.Split(errmsg.UnnamedReturnTypeAppearsAfterNamedReturnTypeError("").Error(), " ")[0],
Expand Down

0 comments on commit 308afd2

Please sign in to comment.