Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
your-diary opened this issue Feb 4, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@your-diary
Copy link

your-diary commented Feb 4, 2024

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":

  • The name of the function is just "Eq" (not something like DeepEq)

  • Its document just says

    Eq returns a matcher that matches on equality.

  • Its example is

    Eq(5).Matches(5) // returns true
    Eq(5).Matches(4) // returns false
@r-hang r-hang added the documentation Improvements or additions to documentation label Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants