uber-go / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
1.81k stars 103 forks source link

The use of `reflect.DeepEqual()` inside `Eq()` matcher is not trivial but not documented. #151

Open your-diary opened 5 months ago

your-diary commented 5 months ago

After reading both of the function name (i.e. Eq()) and its doc comments (text + examples), one cannot infer the result of this simple code:

s1 := "hello"
s2 := "hello"
t.Log(&s1 == &s2)                  //=> false
t.Log(gomock.Eq(&s1).Matches(&s2)) //=> ???

Actually ??? is true because reflect.DeepEqual() is called inside Eq() matcher: source

Is this behavior guaranteed but not just documented? In other words, it this a documentation bug? Or is this an implementation bug?


After reading all of these three, there is still an ambiguity what is "equality":