? ${build.dir}
? ____temp_zlib_file
? rubygems
? test.bat
? toArray.patch
? zlibtest
? bin/ChangeLog
? bin/README
? bin/Rakefile
? bin/Releases
? bin/TODO
? bin/gem
? bin/gem_mirror
? bin/gem_server
? bin/gemwhich
? bin/generate_yaml_index.rb
? bin/setup.rb
? bin/sources-0.0.1.gem
? bin/update_rubygems
? lib/ruby/gems
Index: src/org/jruby/RubyHash.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/RubyHash.java,v
retrieving revision 1.31
diff -u -r1.31 RubyHash.java
--- src/org/jruby/RubyHash.java	23 Mar 2006 13:55:00 -0000	1.31
+++ src/org/jruby/RubyHash.java	23 Mar 2006 20:11:13 -0000
@@ -619,14 +619,14 @@
 
         public Object[] toArray(final Object[] arg) {
             Object[] array = arg;
-            int length = size();
-            
+            final int length = size();
+
             if(array.length < length) {
-                Class type = array.getClass().getComponentType();
+                final Class type = array.getClass().getComponentType();
                 array = (Object[]) Array.newInstance(type, length);
             }
             
-            Iterator iter = iterator();
+            final Iterator iter = iterator();
             for (int i = 0; iter.hasNext(); i++) {
                 array[i] = iter.next();
             }
Index: test/org/jruby/test/TestRubyHash.java
===================================================================
RCS file: /cvsroot/jruby/jruby/test/org/jruby/test/TestRubyHash.java,v
retrieving revision 1.4
diff -u -r1.4 TestRubyHash.java
--- test/org/jruby/test/TestRubyHash.java	26 Oct 2005 05:34:14 -0000	1.4
+++ test/org/jruby/test/TestRubyHash.java	23 Mar 2006 20:13:25 -0000
@@ -30,7 +30,13 @@
  ***** END LICENSE BLOCK *****/
 package org.jruby.test;
 
+import java.util.Map;
+import java.util.Set;
+
 import org.jruby.Ruby;
+import org.jruby.RubyFixnum;
+import org.jruby.RubyHash;
+import org.jruby.RubyObject;
 
 /**
  * @author chadfowler
@@ -186,4 +192,43 @@
 	assertEquals("[[0, \"a\"], [100, \"n\"], [200, \"d\"], [300, \"y\"]]",
 		     eval("p $h_invert.invert.sort"));
     }
+
+    /**
+     * This tests the Java functionality of the conversionset
+     */
+    public void testKeySet() throws Exception {
+        final RubyHash hash = (RubyHash)runtime.evalScript("$h = {1=>2,3=>4,5=>6}");
+        final Set keys = hash.keySet();
+        assertTrue("keys should contain key 1",keys.contains(RubyFixnum.newFixnum(runtime,1)));
+        assertTrue("keys should contain key 3",keys.contains(RubyFixnum.newFixnum(runtime,3)));
+        assertTrue("keys should contain key 5",keys.contains(RubyFixnum.newFixnum(runtime,5)));
+        final Object[] outp = keys.toArray();
+        assertTrue("toArray should not return null",null != outp);
+        assertTrue("toArray should not return empty array",0 != outp.length);
+        final Long[] outp2 = (Long[])keys.toArray(new Long[0]);
+        assertTrue("toArray should not return null",null != outp2);
+        assertTrue("toArray should not return empty array",0 != outp2.length);
+        final Long[] outp3 = (Long[])keys.toArray(new Long[keys.size()]);
+        assertTrue("toArray should not return null",null != outp3);
+        assertTrue("toArray should not return empty array",0 != outp3.length);
+    }
+    /**
+     * This tests the Java functionality of the conversionset
+     */
+    public void testEntrySet() throws Exception {
+        final RubyHash hash = (RubyHash)runtime.evalScript("$h = {1=>2,3=>4,5=>6}");
+        final Set values = hash.entrySet();
+        
+        assertTrue("entry set should be correct length",values.size() == 3);
+
+        final Object[] outp4 = values.toArray();
+        assertTrue("toArray should not return null",null != outp4);
+        assertTrue("toArray should not return empty array",0 != outp4.length);
+        final Map.Entry[] outp5 = (Map.Entry[])values.toArray(new Map.Entry[0]);
+        assertTrue("toArray should not return null",null != outp5);
+        assertTrue("toArray should not return empty array",0 != outp5.length);
+        final Map.Entry[] outp6 = (Map.Entry[])values.toArray(new Map.Entry[values.size()]);
+        assertTrue("toArray should not return null",null != outp6);
+        assertTrue("toArray should not return empty array",0 != outp6.length);
+    }
 }
