-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the parser accept index list expressions (#857)
* Make the parser accept index list expressions
- Loading branch information
Showing
6 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package index_list_expr | ||
|
||
type GenericMultipleTypes[T1 any, T2 any, T3 any] interface { | ||
Func(arg1 *T1, arg2 T2) T3 | ||
} | ||
|
||
type IndexListExpr GenericMultipleTypes[int, string, bool] |
35 changes: 35 additions & 0 deletions
35
pkg/fixtures/index_list_expr/index_list_expression_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package index_list_expr_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/vektra/mockery/v2/pkg" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestParsing(t *testing.T) { | ||
parser := pkg.NewParser(nil) | ||
ctx := context.Background() | ||
require.NoError(t, parser.ParsePackages(ctx, []string{"github.com/vektra/mockery/v2/pkg/fixtures/index_list_expr"})) | ||
require.NoError(t, parser.Load(ctx)) | ||
|
||
for _, ifaceName := range []string{"GenericMultipleTypes", "IndexListExpr"} { | ||
iface, err := parser.Find(ifaceName) | ||
require.NoError(t, err) | ||
require.NotNil(t, iface) | ||
} | ||
} | ||
|
||
func TestUsage(t *testing.T) { | ||
gmt := NewMockGenericMultipleTypes[string, int, bool](t) | ||
testString := "foo" | ||
gmt.EXPECT().Func(&testString, 1).Return(false) | ||
require.Equal(t, false, gmt.Func(&testString, 1)) | ||
|
||
ile := NewMockIndexListExpr(t) | ||
testInt := 1 | ||
ile.EXPECT().Func(&testInt, "foo").Return(true) | ||
require.Equal(t, true, ile.Func(&testInt, "foo")) | ||
} |
81 changes: 81 additions & 0 deletions
81
pkg/fixtures/index_list_expr/mock_generic_multiple_types_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters