liangzai-cool / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

Add sameInstanceAs() alias for sameInstance() factory #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
OK, this is pretty minor, but I find that "is(sameInstance(obj))" reads 
kinda funny, and prefer something like "is(sameInstanceAs(obj))", which I 
have been using as a custom factory in my projects for a few months now. 
Just thought I would share and see if anyone else likes it. Another option 
might be "is(theInstance(obj))", which is shorter but still reads well.

Not that you couldn't write it about 5 seconds, but here's the code, if you 
want it:

    @Factory
    public static <T> Matcher<T> sameInstanceAs(T object) {
        return IsSame.sameInstance(object);
    }

(shortened to just "return sameInstance(object)" if put into IsSame class).

Original issue reported on code.google.com by mhack...@kanayo.com on 16 Oct 2009 at 8:36

GoogleCodeExporter commented 9 years ago
Java tag

Original comment by t.denley on 12 May 2012 at 10:49

GoogleCodeExporter commented 9 years ago
I've added a "theInstance" alias as requested.  See commit:

https://github.com/hamcrest/JavaHamcrest/commit/8f8924a9492bb318bf51b532b85dca6b
52325207

Original comment by t.denley on 20 May 2012 at 8:33