Index: RubyModule.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/RubyModule.java,v
retrieving revision 1.54.2.1
diff -u -r1.54.2.1 RubyModule.java
--- RubyModule.java	2 Jan 2006 07:07:09 -0000	1.54.2.1
+++ RubyModule.java	23 Jan 2006 04:47:05 -0000
@@ -997,31 +997,31 @@
     /** rb_mod_le
      *
      */
-    public RubyBoolean op_le(IRubyObject obj) {
+    public IRubyObject op_le(IRubyObject obj) {
         if (!(obj instanceof RubyModule)) {
             throw getRuntime().newTypeError("compared with non class/module");
         }
-
-        for (RubyModule p = this; p != null; p = p.getSuperClass()) { 
-            if (p.getMethods() == ((RubyModule) obj).getMethods()) {
-                return getRuntime().getTrue();
-            }
+        
+        if (isKindOfModule((RubyModule)obj)) {
+            return getRuntime().getTrue();
+        } else if (((RubyModule)obj).isKindOfModule(this)) {
+            return getRuntime().getFalse();
+        } else {
+            return getRuntime().getNil();
         }
-
-        return getRuntime().getFalse();
     }
 
     /** rb_mod_lt
      *
      */
-    public RubyBoolean op_lt(IRubyObject obj) {
+    public IRubyObject op_lt(IRubyObject obj) {
     	return obj == this ? getRuntime().getFalse() : op_le(obj); 
     }
 
     /** rb_mod_ge
      *
      */
-    public RubyBoolean op_ge(IRubyObject obj) {
+    public IRubyObject op_ge(IRubyObject obj) {
         if (!(obj instanceof RubyModule)) {
             throw getRuntime().newTypeError("compared with non class/module");
         }
@@ -1032,14 +1032,14 @@
     /** rb_mod_gt
      *
      */
-    public RubyBoolean op_gt(IRubyObject obj) {
+    public IRubyObject op_gt(IRubyObject obj) {
         return this == obj ? getRuntime().getFalse() : op_ge(obj);
     }
 
     /** rb_mod_cmp
      *
      */
-    public RubyFixnum op_cmp(IRubyObject obj) {
+    public IRubyObject op_cmp(IRubyObject obj) {
         if (this == obj) {
             return getRuntime().newFixnum(0);
         }
@@ -1048,9 +1048,27 @@
             throw getRuntime().newTypeError(
                 "<=> requires Class or Module (" + getMetaClass().getName() + " given)");
         }
+        
+        RubyModule module = (RubyModule)obj;
+        
+        if (module.isKindOfModule(this)) {
+            return getRuntime().newFixnum(1);
+        } else if (this.isKindOfModule(module)) {
+            return getRuntime().newFixnum(-1);
+        } else {
+            return getRuntime().getNil();
+        }
+    }
 
-        return getRuntime().newFixnum(
-                op_le(obj).isTrue() ? -1 : 1);
+    public boolean isKindOfModule(RubyModule type) {
+        for (RubyModule p = this; p != null; p = p.getSuperClass()) { 
+            // FIXME: this equality check is totally lame; isKindOf should be enough
+            if (p.getMethods() == type.getMethods()) {
+                return true;
+            }
+        }
+        
+        return false;
     }
 
     /** rb_mod_initialize
