Open GoogleCodeExporter opened 9 years ago
I believe I already fixed the first issue
(http://code.google.com/p/gomock/source/detail?r=9aff7dfd2ebbb8d9521fd9e5852c027
8e897397b). Apart from the method name, I have a test case with exactly the
same signature as your Run method, and mockgen produces correct output for it.
I am confused by the second problem you are claiming. Your input interface is
type EventRegistry interface {
AddHandler(name string, h Handler)
DelHandler(h Handler)
Dispatch(name string, ev ...interface{})
ClearEvents(name string)
}
and the diff you reference has
-func (mr *_MockEventRegistryRecorder) AddHandler(arg0 interface{}, arg1
...interface{}) *gomock.Call {
+func (mr *_MockEventRegistryRecorder) AddHandler(arg0 interface{}, arg1
...string) *gomock.Call {
mockgen should not have produced that first line with a variadic argument,
because the AddHandler method does not have a variadic argument. Are you sure
you produced the output from that exact input?
Original comment by dsymo...@golang.org
on 13 Nov 2011 at 11:17
Ahem. Apologies, there were two slight problems with my report.
Firstly, I was using the release tagged mockgen to create the problematic mock.
I updated to tip for weekly, but I was sticking with release for the release
branch, and hadn't re-run mockgen to update mock_registry.go for weekly. If the
first problem above is fixed in tip, that's good :-)
Secondly, after I wrote this problem report, I spent the rest of the day
re-organising my code, so that link now 404s. The default github branch for
goirc is "release", which is rather old code now. The newer event code is now
at:
https://github.com/fluffle/goevent/blob/master/event/registry.go
This should match up more with the generated mock that has problems.
Original comment by a.bram...@gmail.com
on 14 Nov 2011 at 10:40
Yeah, I don't know what to do about this. The recorder methods are deliberately
all interface{} so you can pass in the true type as well as matchers. That
obviously gets in the way when it's variadic.
I don't know what we should expect for variadics there. I've successfully used
GoMock with a variadic method, and in my test code I just use
c.EXPECT.Varf("whatever %d", 7), but in that case the variadic is
...interface{} and not ...string as in your case. If the generated code used
...string then you wouldn't be able to use matchers.
Perhaps you need to write a custom matcher?
Original comment by dsymo...@golang.org
on 15 Nov 2011 at 4:57
That's a plausible solution that'll work around both this problem and the other
caused by the implicit boxing and reflect.DeepEqual. It's either that or
leaving it manually edited as ...string and thus disallowing matchers, which is
probably not wanted. Will see if I can make it generic enough to match
variadics of any type.
Original comment by a.bram...@gmail.com
on 23 Nov 2011 at 12:11
http://www.pl0rt.org/~alex/variadic.patch is a first hacky attempt.
Any chance of some instructions on how to set up for code review? I suspect
you're using codereview.appspot.com. Couldn't seem to get that to play nice
with 2 factor login.
Original comment by a.bram...@gmail.com
on 23 Nov 2011 at 12:35
It follows the same setup as the Go repo.
http://golang.org/doc/contribute.html#Code_review
Original comment by dsymo...@golang.org
on 23 Nov 2011 at 4:04
Finally got some time to fiddle again. Needed to generate an app-specific
password for the code review script, meh.
CL is up at http://codereview.appspot.com/5453052
I suspect the testing needs to be more thorough, but it uses the same kind of
pattern as in the internals of reflect.deepValueEqual to test so it *should*
cover at least variadics of basic types correctly.
Original comment by a.bram...@gmail.com
on 5 Dec 2011 at 10:35
Original issue reported on code.google.com by
a.bram...@gmail.com
on 13 Nov 2011 at 1:28