/*  Copyright (c) 2000-2006 hamcrest.org
 */
package org.hamcrest.core;

import static org.hamcrest.core.IsSame.theInstance;
import static org.hamcrest.core.IsSame.sameInstance;
import static org.hamcrest.core.IsNot.not;
import org.hamcrest.AbstractMatcherTest;
import org.hamcrest.Matcher;
import static org.hamcrest.MatcherAssert.assertThat;


public class IsSameTest extends AbstractMatcherTest {

    @Override
    protected Matcher<?> createMatcher() {
        return sameInstance("irrelevant");
    }

    public void testEvaluatesToTrueIfArgumentIsReferenceToASpecifiedObject() {
        Object o1 = new Object();
        Object o2 = new Object();

        assertThat(o1, sameInstance(o1));
        assertThat(o2, not(sameInstance(o1)));
    }

    public void testAlternativeFactoryMethodAlsoMatchesOnlyIfArgumentIsReferenceToASpecifiedObject() {
        Object o1 = new Object();
        Object o2 = new Object();
        
        assertThat(o1, theInstance(o1));
        assertThat(o2, not(theInstance(o1)));
    }

    public void testReturnsReadableDescriptionFromToString() {
        assertDescription("sameInstance(\"ARG\")", sameInstance("ARG"));
    }

    public void testReturnsReadableDescriptionFromToStringWhenInitialisedWithNull() {
        assertDescription("sameInstance(null)", sameInstance(null));
    }
}

@@ -97,127 +97,174 @@
 est.
-core.IsSame.theInstance;%0Aimport static org.hamcrest.core.IsSame.sameInstance;%0Aimport static org.hamcrest.core.IsNot.not
+AbstractMatcherTest.assertDescription;%0Aimport static org.hamcrest.AbstractMatcherTest.assertDoesNotMatch;%0Aimport static org.hamcrest.AbstractMatcherTest.assertMatches
 ;%0Aim
@@ -260,32 +260,39 @@
 Matches;%0Aimport 
+static 
 org.hamcrest.Abs
@@ -307,16 +307,31 @@
 cherTest
+.assertNullSafe
 ;%0Aimport
@@ -331,16 +331,23 @@
 %0Aimport 
+static 
 org.hamc
@@ -355,67 +355,206 @@
 est.
-Matcher;%0Aimport static org.hamcrest.MatcherAssert.assertTha
+AbstractMatcherTest.assertUnknownTypeSafe;%0Aimport static org.hamcrest.core.IsSame.sameInstance;%0Aimport static org.hamcrest.core.IsSame.theInstance;%0A%0Aimport org.hamcrest.Matcher;%0Aimport org.junit.Tes
 t;%0A%0A
@@ -561,16 +561,22 @@
 %0Apublic 
+final 
 class Is
@@ -588,136 +588,212 @@
 est 
-extends AbstractMatcherTest %7B%0A%0A    @Overr
+%7B%0A%0A    @Test public vo
 id
-e
 %0A    
-protected Matcher%3C?%3E createMatcher() %7B%0A        return sameInstance(%22irrelevant%22
+copesWithNullsAndUnknownTypes() %7B%0A        Matcher%3CString%3E matcher = sameInstance(%22irrelevant%22);%0A        %0A        assertNullSafe(matcher);%0A        assertUnknownTypeSafe(matcher
 );%0A 
@@ -794,32 +794,38 @@
 er);%0A    %7D%0A%0A    
+@Test 
 public void test
@@ -823,14 +823,14 @@
 void
- testE
+%0A    e
 valu
@@ -929,75 +929,103 @@
     
-Object o2 = new Object();%0A%0A        assertThat(o1, sameInstance(
+Matcher%3CObject%3E matcher = sameInstance(o1);%0A%0A        assertMatches(%22didn't match%22, matcher, 
 o1)
-)
 ;%0A  
@@ -1040,37 +1040,65 @@
 sert
-That(o2, not(sameInstance(o1)
+DoesNotMatch(%22matched unexpectedly%22, matcher, new Object(
 ));%0A
@@ -1100,32 +1100,38 @@
 ());%0A    %7D%0A%0A    
+@Test 
 public void test
@@ -1129,14 +1129,14 @@
 void
- testA
+%0A    a
 lter
@@ -1259,82 +1259,102 @@
     
-Object o2 = new Object();%0A        %0A        assertThat(o1, theInstance(
+Matcher%3CObject%3E matcher = theInstance(o1);%0A%0A        assertMatches(%22didn't match%22, matcher, 
 o1)
-)
 ;%0A  
@@ -1369,36 +1369,65 @@
 sert
-That(o2, not(theInstance(o1)
+DoesNotMatch(%22matched unexpectedly%22, matcher, new Object(
 ));%0A
@@ -1429,32 +1429,38 @@
 ());%0A    %7D%0A%0A    
+@Test 
 public void test
@@ -1446,38 +1446,38 @@
 Test public void
- testR
+%0A    r
 eturnsReadableDe
@@ -1586,16 +1586,22 @@
  %7D%0A%0A    
+@Test 
 public v
@@ -1607,14 +1607,14 @@
 void
- testR
+%0A    r
 etur

convert test to JUnit4