Adding a test for some nuanced behaviour in binder

git-svn-id: https://google-guice.googlecode.com/svn/trunk@469 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/test/com/google/inject/BindingTest.java b/test/com/google/inject/BindingTest.java
index 807d7fc..ad5efbe 100644
--- a/test/com/google/inject/BindingTest.java
+++ b/test/com/google/inject/BindingTest.java
@@ -22,6 +22,7 @@
 
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * @author crazybob@google.com (Bob Lee)
@@ -207,4 +208,26 @@
           "Injecting into abstract types is not supported."));
     }
   }
+
+  /**
+   * This test ensures that the asEagerSingleton() scoping applies to the key,
+   * not to what the key is linked to.
+   */
+  public void testScopeIsAppliedToKeyNotTarget() {
+    Injector injector = Guice.createInjector(new AbstractModule() {
+      protected void configure() {
+        bind(Integer.class).toProvider(Counter.class).asEagerSingleton();
+        bind(Number.class).toProvider(Counter.class).asEagerSingleton();
+      }
+    });
+
+    assertNotSame(injector.getInstance(Integer.class), injector.getInstance(Number.class));
+  }
+
+  static class Counter implements Provider<Integer> {
+    static AtomicInteger next = new AtomicInteger(1);
+    public Integer get() {
+      return next.getAndIncrement();
+    }
+  }
 }
\ No newline at end of file