[macruby-changes] [3023] MacRuby/trunk/spec/frozen

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 16 15:45:05 PST 2009


Revision: 3023
          http://trac.macosforge.org/projects/ruby/changeset/3023
Author:   eloy.de.enige at gmail.com
Date:     2009-11-16 15:45:01 -0800 (Mon, 16 Nov 2009)
Log Message:
-----------
Updated RubySpec to bb54356acee1c73a63472b3ae57479da6cac48f1

Modified Paths:
--------------
    MacRuby/trunk/spec/frozen/core/array/comparison_spec.rb
    MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb
    MacRuby/trunk/spec/frozen/core/array/each_index_spec.rb
    MacRuby/trunk/spec/frozen/core/array/each_spec.rb
    MacRuby/trunk/spec/frozen/core/array/hash_spec.rb
    MacRuby/trunk/spec/frozen/core/array/pack_spec.rb
    MacRuby/trunk/spec/frozen/core/array/product_spec.rb
    MacRuby/trunk/spec/frozen/core/array/reject_spec.rb
    MacRuby/trunk/spec/frozen/core/array/reverse_each_spec.rb
    MacRuby/trunk/spec/frozen/core/array/select_spec.rb
    MacRuby/trunk/spec/frozen/core/array/shared/eql.rb
    MacRuby/trunk/spec/frozen/core/binding/eval_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/collect_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/map_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/max_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/min_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/minmax_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/shared/collect.rb
    MacRuby/trunk/spec/frozen/core/enumerable/sort_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/each_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/each_with_index_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/enum_for_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/new_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/next_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/peek_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/rewind_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/to_enum_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerator/with_index_spec.rb
    MacRuby/trunk/spec/frozen/core/exception/system_call_error_spec.rb
    MacRuby/trunk/spec/frozen/core/file/new_spec.rb
    MacRuby/trunk/spec/frozen/core/file/open_spec.rb
    MacRuby/trunk/spec/frozen/core/file/path_spec.rb
    MacRuby/trunk/spec/frozen/core/file/truncate_spec.rb
    MacRuby/trunk/spec/frozen/core/fixnum/divide_spec.rb
    MacRuby/trunk/spec/frozen/core/fixnum/right_shift_spec.rb
    MacRuby/trunk/spec/frozen/core/hash/default_proc_spec.rb
    MacRuby/trunk/spec/frozen/core/hash/hash_spec.rb
    MacRuby/trunk/spec/frozen/core/io/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/core/io/gets_spec.rb
    MacRuby/trunk/spec/frozen/core/io/inspect_spec.rb
    MacRuby/trunk/spec/frozen/core/io/output_spec.rb
    MacRuby/trunk/spec/frozen/core/io/popen_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/Integer_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/exit_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/core/kernel/method_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/public_method_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/respond_to_missing_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/shared/method.rb
    MacRuby/trunk/spec/frozen/core/kernel/taint_spec.rb
    MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb
    MacRuby/trunk/spec/frozen/core/method/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/core/module/module_function_spec.rb
    MacRuby/trunk/spec/frozen/core/proc/shared/call.rb
    MacRuby/trunk/spec/frozen/core/random/rand_spec.rb
    MacRuby/trunk/spec/frozen/core/range/each_spec.rb
    MacRuby/trunk/spec/frozen/core/range/new_spec.rb
    MacRuby/trunk/spec/frozen/core/range/step_spec.rb
    MacRuby/trunk/spec/frozen/core/string/encode_spec.rb
    MacRuby/trunk/spec/frozen/core/string/gsub_spec.rb
    MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb
    MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb
    MacRuby/trunk/spec/frozen/core/string/try_convert_spec.rb
    MacRuby/trunk/spec/frozen/core/string/upto_spec.rb
    MacRuby/trunk/spec/frozen/core/struct/hash_spec.rb
    MacRuby/trunk/spec/frozen/core/time/at_spec.rb
    MacRuby/trunk/spec/frozen/core/time/shared/now.rb
    MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb
    MacRuby/trunk/spec/frozen/language/fixtures/variables.rb
    MacRuby/trunk/spec/frozen/language/hash_spec.rb
    MacRuby/trunk/spec/frozen/language/precedence_spec.rb
    MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb
    MacRuby/trunk/spec/frozen/language/return_spec.rb
    MacRuby/trunk/spec/frozen/language/string_spec.rb
    MacRuby/trunk/spec/frozen/language/variables_spec.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/gt_spec.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/gte_spec.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/infinite_spec.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/lt_spec.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/lte_spec.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/shared/eql.rb
    MacRuby/trunk/spec/frozen/library/getoptlong/error_message_spec.rb
    MacRuby/trunk/spec/frozen/library/getoptlong/ordering_spec.rb
    MacRuby/trunk/spec/frozen/library/getoptlong/shared/get.rb
    MacRuby/trunk/spec/frozen/library/mathn/integer/prime_division_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/clone_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/column_size_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/column_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/column_vector_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/columns_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/diagonal_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/divide_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/element_reference_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/eql_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/equal_value_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/exponent_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/hash_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/inspect_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/inverse_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/minor_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/minus_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/multiply_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/new_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/row_size_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/row_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/row_vector_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/row_vectors_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/collect.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/equal_value.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/transpose.rb
    MacRuby/trunk/spec/frozen/library/matrix/square_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/tr_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/trace_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/vector/eql_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/zero_spec.rb
    MacRuby/trunk/spec/frozen/library/mutex/lock_spec.rb
    MacRuby/trunk/spec/frozen/library/mutex/try_lock_spec.rb
    MacRuby/trunk/spec/frozen/library/mutex/unlock_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/basicsocket/send_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/library/socket/ipsocket/recvfrom_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/socket/bind_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/socket/for_fd_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/socket/getnameinfo_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/tcpserver/accept_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/tcpserver/new_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/tcpsocket/shared/new.rb
    MacRuby/trunk/spec/frozen/library/tempfile/initialize_spec.rb
    MacRuby/trunk/spec/frozen/library/tempfile/path_spec.rb
    MacRuby/trunk/spec/frozen/library/tmpdir/dir/mktmpdir_spec.rb
    MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb
    MacRuby/trunk/spec/frozen/library/zlib/inflate/append_spec.rb
    MacRuby/trunk/spec/frozen/library/zlib/inflate/inflate_spec.rb
    MacRuby/trunk/spec/frozen/shared/rational/div.rb
    MacRuby/trunk/spec/frozen/tags/1.9/core/argf/bytes_tags.txt
    MacRuby/trunk/spec/frozen/tags/1.9/core/argf/chars_tags.txt
    MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_byte_tags.txt
    MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_char_tags.txt
    MacRuby/trunk/spec/frozen/upstream

Added Paths:
-----------
    MacRuby/trunk/spec/frozen/core/array/shared/enumeratorize.rb
    MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.orig
    MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.rej
    MacRuby/trunk/spec/frozen/core/enumerable/collect_concat_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/flat_map_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/shared/collect_concat.rb
    MacRuby/trunk/spec/frozen/core/file/shared/open.rb
    MacRuby/trunk/spec/frozen/core/io/try_convert_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/comparison_spec.rb
    MacRuby/trunk/spec/frozen/core/string/encode_bang_spec.rb
    MacRuby/trunk/spec/frozen/core/string/shared/encode.rb
    MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.orig
    MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.rej
    MacRuby/trunk/spec/frozen/library/delegate/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/library/delegate/frozen_spec.rb
    MacRuby/trunk/spec/frozen/library/delegate/method_spec.rb
    MacRuby/trunk/spec/frozen/library/delegate/send_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/constructor_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/trace.rb
    MacRuby/trunk/spec/frozen/library/matrix/spec_helper.rb

Removed Paths:
-------------
    MacRuby/trunk/spec/frozen/fixtures/matrix.rb
    MacRuby/trunk/spec/frozen/library/date/neww_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/init_rows_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/initialize_spec.rb
    MacRuby/trunk/spec/frozen/tags/1.9/core/argf/lineno_tags.txt

Modified: MacRuby/trunk/spec/frozen/core/array/comparison_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/comparison_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/comparison_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -92,4 +92,10 @@
     obj.should_not_receive(:to_ary)
     ([5, 6, 7] <=> obj).should == 0
   end
+
+  ruby_bug "redmine:2276", "1.9.1" do
+    it "returns nil when the argument is not array-like" do
+      ([] <=> false).should be_nil
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/enumeratorize'
 
 describe "Array#delete_if" do
   before do
@@ -16,11 +17,7 @@
     @a.delete_if{ true }.equal?(@a).should be_true
   end
 
-  ruby_version_is "" ... "1.8.7" do
-    it "raises a LocalJumpError if no block given" do
-      lambda { @a.delete_if }.should raise_error(LocalJumpError)
-    end
-  end
+  it_behaves_like :enumeratorize, :delete_if
 
   ruby_version_is '1.8.7' do
     it "returns an Enumerator if no block given, and the enumerator can modify the original array" do

Modified: MacRuby/trunk/spec/frozen/core/array/each_index_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/each_index_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/each_index_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/enumeratorize'
 
 # Modifying a collection while the contents are being iterated
 # gives undefined behavior. See
@@ -21,15 +22,5 @@
     a.each_index { |i| }.should equal(a)
   end
 
-  ruby_version_is '' ... '1.8.7' do
-    it 'raises a LocalJumpError if no block given' do
-      lambda{ [1,2].each_index }.should raise_error(LocalJumpError)
-    end
-  end
-
-  ruby_version_is '1.8.7' do
-    it 'returns an Enumerator if no block given' do
-      [1,2].each_index.should be_kind_of(enumerator_class)
-    end
-  end
+  it_behaves_like :enumeratorize, :each_index
 end

Modified: MacRuby/trunk/spec/frozen/core/array/each_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/each_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/each_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/enumeratorize'
 
 # Modifying a collection while the contents are being iterated
 # gives undefined behavior. See
@@ -25,15 +26,5 @@
     b.should == [2, nil, 4]
   end
 
-  ruby_version_is '' ... '1.8.7' do
-    it 'raises a LocalJumpError if no block given' do
-      lambda{ [1,2].each }.should raise_error(LocalJumpError)
-    end
-  end
-
-  ruby_version_is '1.8.7' do
-    it 'returns an Enumerator if no block given' do
-      [1,2].each.should be_kind_of(enumerator_class)
-    end
-  end
+  it_behaves_like :enumeratorize, :each
 end

Modified: MacRuby/trunk/spec/frozen/core/array/hash_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/hash_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/hash_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -22,16 +22,21 @@
   end
 
   ruby_bug "redmine #1852", "1.9.1" do
-    it "returns the same hash for recursive arrays" do
+    it "returns the same hash for equal recursive arrays" do
       rec = []; rec << rec
       rec.hash.should == [rec].hash
       rec.hash.should == [[rec]].hash
+      # This is because rec.eql?([[rec]])
+      # Remember that if two objects are eql?
+      # then the need to have the same hash
+      # Check the Array#eql? specs!
     end
 
-    it "returns the same hash for recursive arrays through hashes" do
+    it "returns the same hash for equal recursive arrays through hashes" do
       h = {} ; rec = [h] ; h[:x] = rec
       rec.hash.should == [h].hash
       rec.hash.should == [{:x => rec}].hash
+      # Like above, this is because rec.eql?([{:x => rec}])
     end
   end
 

Modified: MacRuby/trunk/spec/frozen/core/array/pack_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/pack_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/pack_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1470,9 +1470,15 @@
   end
   platform_is :wordsize => 64 do
     # TODO: Is there anything other LLP64 platform which ruby can run on?
-    platform_is :os => :mswin do 
-      big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'l!'    }
-      little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'l!' }
+    platform_is :os => :mswin do
+      not_compliant_on :jruby do
+        big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'l!'    }
+        little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'l!' }
+      end
+      deviates_on :jruby do
+        big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'l!'    }
+        little_endian { it_behaves_like "Array#pack with integer format (64bit, little endian)", 'l!' }
+      end
     end
     platform_is_not :os => :mswin do
       big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'l!'    }
@@ -1487,9 +1493,15 @@
   end
   platform_is :wordsize => 64 do
     # TODO: Is there anything other LLP64 platform which ruby can run on?
-    platform_is :os => :mswin do 
-      big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'l_'    }
-      little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'l_' }
+    platform_is :os => :mswin do
+      not_compliant_on :jruby do
+        big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'l_'    }
+        little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'l_' }
+      end
+      deviates_on :jruby do
+        big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'l_'    }
+        little_endian { it_behaves_like "Array#pack with integer format (64bit, little endian)", 'l_' }
+      end
     end
     platform_is_not :os => :mswin do
       big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'l_'    }
@@ -1506,9 +1518,17 @@
   end
   platform_is :wordsize => 64 do
     # TODO: Is there anything other LLP64 platform which ruby can run on?
-    platform_is :os => :mswin do 
-      big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'L!'    }
-      little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'L!' }
+    platform_is :os => :mswin do
+      not_compliant_on :jruby do
+        # I'm not sure that this is sensible behavior for MRI,
+        # being 64bit but treating long as 32 bit, and only on Windows.
+        big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'L!'    }
+        little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'L!' }
+      end
+      deviates_on :jruby do
+        big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'L!'    }
+        little_endian { it_behaves_like "Array#pack with integer format (64bit, little endian)", 'L!' }
+      end
     end
     platform_is_not :os => :mswin do
       big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'L!'    }
@@ -1523,9 +1543,15 @@
   end
   platform_is :wordsize => 64 do
     # TODO: Is there anything other LLP64 platform which ruby can run on?
-    platform_is :os => :mswin do 
-      big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'L_'    }
-      little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'L_' }
+    platform_is :os => :mswin do
+      not_compliant_on :jruby do
+        big_endian    { it_behaves_like "Array#pack with integer format (32bit, big endian)", 'L_'    }
+        little_endian { it_behaves_like "Array#pack with integer format (32bit, little endian)", 'L_' }
+      end
+      deviates_on :jruby do
+        big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'L_'    }
+        little_endian { it_behaves_like "Array#pack with integer format (64bit, little endian)", 'L_' }
+      end
     end
     platform_is_not :os => :mswin do
       big_endian    { it_behaves_like "Array#pack with integer format (64bit, big endian)", 'L_'    }

Modified: MacRuby/trunk/spec/frozen/core/array/product_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/product_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/product_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,7 +2,7 @@
 require File.dirname(__FILE__) + '/fixtures/classes'
 
 describe "Array#product" do
-  ruby_version_is "1.9" do
+  ruby_version_is "1.8.7" do
     it "returns converted arguments using :to_ary" do
       lambda{ [1].product(2..3) }.should raise_error(TypeError)
       ar = ArraySpecs::ArrayConvertable.new(2,3)
@@ -18,5 +18,9 @@
     it "has no required argument" do
       [1,2].product.should == [[1],[2]]
     end
+
+    it "returns an empty array when the argument is an empty array" do
+      [1, 2].product([]).should == []
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/array/reject_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/reject_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/reject_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/enumeratorize'
 
 describe "Array#reject" do
   it "returns a new array without elements for which block is true" do
@@ -34,17 +35,7 @@
     end
   end
   
-  ruby_version_is '' ... '1.8.7' do
-    it 'raises a LocalJumpError if no block given' do
-      lambda{ [1,2].reject }.should raise_error(LocalJumpError)
-    end
-  end
-  ruby_version_is '1.8.7' do
-    it 'returns an Enumerator if no block given' do
-      [1,2].reject.should be_kind_of(enumerator_class)
-    end
-  end
-  
+  it_behaves_like :enumeratorize, :reject 
 end
 
 describe "Array#reject!" do
@@ -105,15 +96,5 @@
     end
   end
   
-  ruby_version_is '' ... '1.8.7' do
-    it 'raises a LocalJumpError if no block given' do
-      lambda{ [1,2].reject! }.should raise_error(LocalJumpError)
-    end
-  end
-  ruby_version_is '1.8.7' do
-    it 'returns an Enumerator if no block given' do
-      [1,2].reject!.should be_kind_of(enumerator_class)
-    end
-  end
-  
+  it_behaves_like :enumeratorize, :reject!
 end

Modified: MacRuby/trunk/spec/frozen/core/array/reverse_each_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/reverse_each_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/reverse_each_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/enumeratorize'
 
 # Modifying a collection while the contents are being iterated
 # gives undefined behavior. See
@@ -32,15 +33,5 @@
     ScratchPad.recorded.should == [array, array, array, array, array, 3.0, 'two', 1]
   end
 
-  ruby_version_is '' ... '1.8.7' do
-    it 'raises a LocalJumpError if no block given' do
-      lambda{ [1,2].reverse_each }.should raise_error(LocalJumpError)
-    end
-  end
-
-  ruby_version_is '1.8.7' do
-    it 'returns an Enumerator if no block given' do
-      [1,2].reverse_each.should be_kind_of(enumerator_class)
-    end
-  end
+  it_behaves_like :enumeratorize, :reverse_each
 end

Modified: MacRuby/trunk/spec/frozen/core/array/select_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/select_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/select_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,7 +1,10 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/enumeratorize'
 
 describe "Array#select" do
+  it_behaves_like :enumeratorize, :select
+
   it "returns a new array of elements for which block is true" do
     [1, 3, 4, 5, 6, 9].select { |i| i % ((i + 1) / 2) == 0}.should == [1, 4, 6]
   end
@@ -19,5 +22,4 @@
     array.select { true }.should == [1, 'two', 3.0, array, array, array, array, array]
     array.select { false }.should == []
   end
-
 end

Added: MacRuby/trunk/spec/frozen/core/array/shared/enumeratorize.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/shared/enumeratorize.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/array/shared/enumeratorize.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,12 @@
+describe :enumeratorize, :shared => true do
+  ruby_version_is '' ... '1.8.7' do
+    it 'raises a LocalJumpError if no block given' do
+      lambda{ [1,2].send(@method) }.should raise_error(LocalJumpError)
+    end
+  end
+  ruby_version_is '1.8.7' do
+    it 'returns an Enumerator if no block given' do
+      [1,2].send(@method).should be_kind_of(enumerator_class)
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/core/array/shared/eql.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/shared/eql.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/array/shared/eql.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -32,6 +32,10 @@
       a       .send(@method,    [[a]]  ).should be_true
       [a]     .send(@method,    a      ).should be_true
       [[a]]   .send(@method,    a      ).should be_true
+      # These may be surprising, but no difference can be
+      # found between these arrays, so they are ==.
+      # There is no "path" that will lead to a difference
+      # (contrary to other examples below)
 
       a2 = ArraySpecs.empty_recursive_array
       a       .send(@method,    a2     ).should be_true
@@ -45,10 +49,10 @@
       back   .send(@method,  a  ).should be_true
 
       x = []; x << x << x
-      x       .send(@method,    a                ).should be_false
-      x       .send(@method,    [a, a]           ).should be_false
-      x       .send(@method,    [x, a]           ).should be_false
-      [x, a]  .send(@method,    [a, x]           ).should be_false
+      x       .send(@method,    a                ).should be_false  # since x.size != a.size
+      x       .send(@method,    [a, a]           ).should be_false  # since x[0].size != [a, a][0].size
+      x       .send(@method,    [x, a]           ).should be_false  # since x[1].size != [x, a][1].size
+      [x, a]  .send(@method,    [a, x]           ).should be_false  # etc...
       x       .send(@method,    [x, x]           ).should be_true
       x       .send(@method,    [[x, x], [x, x]] ).should be_true
 
@@ -63,7 +67,7 @@
       forest .send(@method,     [tree2, branch, :bird, a, forest2]).should be_true
 
       diffforest = [branch2, tree2, :bird, a2]; diffforest << forest2
-      forest .send(@method,     diffforest      ).should be_false
+      forest .send(@method,     diffforest      ).should be_false # since forest[0].size == 1 != 3 == diffforest[0]
       forest .send(@method,     [nil]           ).should be_false
       forest .send(@method,     [forest]        ).should be_false
     end

Modified: MacRuby/trunk/spec/frozen/core/binding/eval_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/binding/eval_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/binding/eval_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -9,8 +9,7 @@
       bind2 = obj.dup.get_binding
       { "@secret += square(3)" => 10,
         "a" => true,
-        "class Inside ; end" => nil,
-        "Inside.name" => "BindingSpecs::Demo::Inside"
+        "class Inside ; end ; Inside.name" => "BindingSpecs::Demo::Inside"
       }.each do |test, result|
         r1 = bind1.eval(test)
         r2 = Kernel.eval(test, bind2)

Added: MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.orig
===================================================================
--- MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.orig	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.orig	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,110 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/common'
+
+describe "Dir.chdir" do
+  before(:each) do
+    @original = Dir.pwd
+  end
+
+  after(:each) do
+    Dir.chdir(@original)
+  end
+
+  it "defaults to $HOME with no arguments" do
+    if ENV['HOME']
+    Dir.chdir(ENV['HOME'])
+    home = DirSpecs.pwd
+
+    Dir.chdir
+    DirSpecs.pwd.should == home
+    end
+  end
+
+  it "changes to the specified directory" do
+    Dir.chdir DirSpecs.mock_dir
+    DirSpecs.pwd.should == DirSpecs.mock_dir
+  end
+
+  it "returns 0 when successfully changing directory" do
+    Dir.chdir(@original).should == 0
+  end
+
+  it "calls #to_str on the argument if it's not a String" do
+    obj = mock('path')
+    obj.should_receive(:to_str).and_return(Dir.pwd)
+    Dir.chdir(obj)
+  end
+
+  ruby_version_is "1.9" do
+    it "calls #to_path on the argument if it's not a String" do
+      obj = mock('path')
+      obj.should_receive(:to_path).and_return(Dir.pwd)
+      Dir.chdir(obj)
+    end
+
+    it "prefers #to_str over #to_path" do
+      obj = Class.new do
+        def to_path; DirSpecs.mock_dir; end
+        def to_str;  Dir.pwd; end
+      end
+      Dir.chdir(obj.new)
+      Dir.pwd.should == @original
+    end
+  end
+
+  it "returns the value of the block when a block is given" do
+    Dir.chdir(@original) { :block_value }.should == :block_value
+  end
+
+  it "defaults to the home directory when given a block but no argument" do
+    # Windows will return a path with forward slashes for ENV["HOME"] so we have
+    # to compare the route representations returned by Dir.chdir.
+    current_dir = ""
+    Dir.chdir { current_dir = Dir.pwd }
+
+    Dir.chdir(ENV['HOME'])
+    current_dir.should == Dir.pwd
+  end
+
+  it "changes to the specified directory for the duration of the block" do
+    ar = Dir.chdir(DirSpecs.mock_dir) { |dir| [dir, DirSpecs.pwd] }
+    ar.should == [DirSpecs.mock_dir, DirSpecs.mock_dir]
+
+    DirSpecs.pwd.should == @original
+  end
+
+  it "raises a SystemCallError if the directory does not exist" do
+    lambda { Dir.chdir DirSpecs.nonexistent }.should raise_error(SystemCallError)
+    lambda { Dir.chdir(DirSpecs.nonexistent) { } }.should raise_error(SystemCallError)
+  end
+
+  it "raises a SystemCallError if the original directory no longer exists" do
+    dir1 = tmp('/testdir1')
+    dir2 = tmp('/testdir2')
+    File.exist?(dir1).should == false
+    File.exist?(dir2).should == false
+    Dir.mkdir dir1
+    Dir.mkdir dir2
+    begin
+      lambda {
+        Dir.chdir dir1 do
+          Dir.chdir(dir2) { Dir.unlink dir1 }
+        end
+      }.should raise_error(SystemCallError)
+    ensure
+      Dir.unlink dir1 if File.exist?(dir1)
+      Dir.unlink dir2 if File.exist?(dir2)
+    end
+  end
+
+  it "always returns to the original directory when given a block" do
+    begin
+      Dir.chdir(DirSpecs.mock_dir) do
+        raise StandardError, "something bad happened"
+      end
+    rescue StandardError
+    end
+
+    DirSpecs.pwd.should == @original
+  end
+end

Added: MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.rej
===================================================================
--- MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.rej	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb.rej	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,56 @@
+***************
+*** 20,30 ****
+      end
+    end
+  
+-   it "changes to the specified directory" do
+-     Dir.chdir DirSpecs.mock_dir
+-     Dir.pwd.should == DirSpecs.mock_dir
+    end
+- 
+    it "returns 0 when successfully changing directory" do
+      Dir.chdir(@original).should == 0
+    end
+--- 20,33 ----
+      end
+    end
+  
++   # MRI fails this when /var path has symlinks, as on OS X
++   quarantine! do
++     it "changes to the specified directory" do
++       Dir.chdir DirSpecs.mock_dir
++       Dir.pwd.should == DirSpecs.mock_dir
++     end
+    end
++   
+    it "returns 0 when successfully changing directory" do
+      Dir.chdir(@original).should == 0
+    end
+***************
+*** 66,76 ****
+      current_dir.should == Dir.pwd
+    end
+  
+-   it "changes to the specified directory for the duration of the block" do
+-     ar = Dir.chdir(DirSpecs.mock_dir) { |dir| [dir, Dir.pwd] }
+-     ar.should == [DirSpecs.mock_dir, DirSpecs.mock_dir]
+  
+-     Dir.pwd.should == @original
+    end
+  
+    it "raises a SystemCallError if the directory does not exist" do
+--- 69,82 ----
+      current_dir.should == Dir.pwd
+    end
+  
++   # MRI fails this when /var path has symlinks, as on OS X
++   quarantine! do
++     it "changes to the specified directory for the duration of the block" do
++       ar = Dir.chdir(DirSpecs.mock_dir) { |dir| [dir, Dir.pwd] }
++       ar.should == [DirSpecs.mock_dir, DirSpecs.mock_dir]
+  
++       Dir.pwd.should == @original
++     end
+    end
+  
+    it "raises a SystemCallError if the directory does not exist" do

Added: MacRuby/trunk/spec/frozen/core/enumerable/collect_concat_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/collect_concat_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/enumerable/collect_concat_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/collect_concat'
+
+ruby_version_is "1.9.2" do
+  describe "Enumerable#collect_concat" do   
+    it_behaves_like(:enumerable_collect_concat , :collect_concat) 
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/core/enumerable/collect_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/collect_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerable/collect_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -5,7 +5,3 @@
 describe "Enumerable#collect" do   
   it_behaves_like(:enumerable_collect , :collect)
 end
-
-describe "Enumerable#collect with implicit to_proc [each(&obj) form]" do    
-  it_behaves_like(:enumerable_collect_to_proc , :collect)
-end

Added: MacRuby/trunk/spec/frozen/core/enumerable/flat_map_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/flat_map_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/enumerable/flat_map_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/shared/collect_concat'
+
+ruby_version_is "1.9.2" do
+  describe "Enumerable#flat_map" do   
+    it_behaves_like(:enumerable_collect_concat , :flat_map) 
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/core/enumerable/map_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/map_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerable/map_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -5,7 +5,3 @@
 describe "Enumerable#map" do   
   it_behaves_like(:enumerable_collect , :map) 
 end
-
-describe "Enumerable#map with implicit to_proc [each(&obj) form]" do    
-  it_behaves_like(:enumerable_collect_to_proc , :map) 
-end

Modified: MacRuby/trunk/spec/frozen/core/enumerable/max_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/max_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerable/max_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -33,18 +33,33 @@
     @e_ints.max.should == 1010101010
   end
 
-  it "return an error when introduce the wrong kind or number of parameters " do
-    # error cases
-    EnumerableSpecs::EachDefiner.new().max.should == nil
-    lambda {
-      EnumerableSpecs::EachDefiner.new(Object.new, Object.new).max
-    }.should raise_error(NoMethodError)
-    lambda {
+  it "returns nil for an empty Enumerable " do
+    EnumerableSpecs::EachDefiner.new.max.should == nil
+  end
+
+  ruby_version_is ""..."1.9" do
+    it "raises a NoMethodError for elements without #<=>" do
+      lambda do
+        EnumerableSpecs::EachDefiner.new(Object.new, Object.new).max
+      end.should raise_error(NoMethodError)
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "raises a NoMethodError for elements without #<=>" do
+      lambda do
+        EnumerableSpecs::EachDefiner.new(BasicObject.new, BasicObject.new).max
+      end.should raise_error(NoMethodError)
+    end
+  end
+
+  it "raises an ArgumentError for incomparable elements" do
+    lambda do
       EnumerableSpecs::EachDefiner.new(11,"22").max
-    }.should raise_error(ArgumentError)
-    lambda {
+    end.should raise_error(ArgumentError)
+    lambda do
       EnumerableSpecs::EachDefiner.new(11,12,22,33).max{|a, b| nil}
-    }.should raise_error(ArgumentError)
+    end.should raise_error(ArgumentError)
   end
 
   it "return the maximum element (with block" do

Modified: MacRuby/trunk/spec/frozen/core/enumerable/min_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/min_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerable/min_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -33,17 +33,33 @@
     @e_ints.min.should == 22
   end
 
-  it "return nil when error" do
-    EnumerableSpecs::EachDefiner.new().min.should == nil
-    lambda {
-      EnumerableSpecs::EachDefiner.new(Object.new, Object.new).min
-    }.should raise_error(NoMethodError)
-    lambda {
+  it "returns nil for an empty Enumerable " do
+    EnumerableSpecs::EachDefiner.new.min.should be_nil
+  end
+
+  ruby_version_is ""..."1.9" do
+    it "raises a NoMethodError for elements without #<=>" do
+      lambda do
+        EnumerableSpecs::EachDefiner.new(Object.new, Object.new).min
+      end.should raise_error(NoMethodError)
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "raises a NoMethodError for elements without #<=>" do
+      lambda do
+        EnumerableSpecs::EachDefiner.new(BasicObject.new, BasicObject.new).min
+      end.should raise_error(NoMethodError)
+    end
+  end
+
+  it "raises an ArgumentError for incomparable elements" do
+    lambda do
       EnumerableSpecs::EachDefiner.new(11,"22").min
-    }.should raise_error(ArgumentError)
-    lambda {
+    end.should raise_error(ArgumentError)
+    lambda do
       EnumerableSpecs::EachDefiner.new(11,12,22,33).min{|a, b| nil}
-    }.should raise_error(ArgumentError)
+    end.should raise_error(ArgumentError)
   end
 
   it "return the minimun when using a block rule" do

Modified: MacRuby/trunk/spec/frozen/core/enumerable/minmax_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/minmax_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerable/minmax_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -14,19 +14,35 @@
       @strs.minmax.should == ["1010", "60" ]
     end
 
-    it "return nil when error" do
+    it "returns [nil, nil] for an empty Enumerable" do
       EnumerableSpecs::Empty.new.minmax.should == [nil, nil]
-      lambda {
-        EnumerableSpecs::Numerous.new(Object.new, Object.new).minmax
-      }.should raise_error(NoMethodError)
-      lambda {
+    end
+
+    it "raises an ArgumentError when elements are incomparable" do
+      lambda do
         EnumerableSpecs::Numerous.new(11,"22").minmax
-      }.should raise_error(ArgumentError)
-      lambda {
+      end.should raise_error(ArgumentError)
+      lambda do
         EnumerableSpecs::Numerous.new(11,12,22,33).minmax{|a, b| nil}
-      }.should raise_error(ArgumentError)
+      end.should raise_error(ArgumentError)
     end
 
+    ruby_version_is ""..."1.9" do
+      it "raises a NoMethodError for elements without #<=>" do
+        lambda do
+          EnumerableSpecs::Numerous.new(Object.new, Object.new).minmax
+        end.should raise_error(NoMethodError)
+      end
+    end
+
+    ruby_version_is "1.9" do
+      it "raises a NoMethodError for elements without #<=>" do
+        lambda do
+          EnumerableSpecs::Numerous.new(BasicObject.new, BasicObject.new).minmax
+        end.should raise_error(NoMethodError)
+      end
+    end
+
     it "return the minimun when using a block rule" do
       @enum.minmax {|a,b| b <=> a }.should == [10, 4]
       @strs.minmax {|a,b| a.length <=> b.length }.should == ["2", "55555"]

Modified: MacRuby/trunk/spec/frozen/core/enumerable/shared/collect.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/shared/collect.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerable/shared/collect.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +1,5 @@
 describe :enumerable_collect, :shared => true do
-  it "collect should return a new array with the results of passing each element to block" do
+  it "returns a new array with the results of passing each element to block" do
     entries = [0, 1, 3, 4, 5, 6]
     numerous = EnumerableSpecs::Numerous.new(*entries)
     numerous.send(@method) { |i| i % 2 }.should == [0, 1, 1, 0, 1, 0]
@@ -34,31 +34,3 @@
     end
   end
 end
-
-describe :enumerable_collect_to_proc, :shared => true do    
-  ruby_version_is "1.8.7" do
-    it "calls obj.to_proc" do 
-      EnumerableSpecs::Numerous.new.send(@method, &:succ).should == [3, 6, 4, 7, 2, 5]
-    end 
-
-    it "does not call obj.to_proc if obj is a lambda" do
-      f = lambda{ |x| x + 1 }
-      class << f
-        def to_proc
-          lambda{ |x| 42 }
-        end
-      end
-       EnumerableSpecs::Numerous.new.send(@method, &f).should == [3, 6, 4, 7, 2, 5]
-    end
-
-    it "does not call obj.to_proc if obj is a Proc" do
-      myproc = Class.new Proc do
-        def to_proc
-          lambda{ |x| 42 }
-        end
-      end
-      inc = myproc.new{ |x| x + 1 }
-      EnumerableSpecs::Numerous.new.send(@method, &inc).should == [3, 6, 4, 7, 2, 5]
-    end
-  end
-end

Added: MacRuby/trunk/spec/frozen/core/enumerable/shared/collect_concat.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/shared/collect_concat.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/enumerable/shared/collect_concat.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,27 @@
+describe :enumerable_collect_concat, :shared => true do
+  it "returns a new array with the results of passing each element to block, flattened one level" do
+    numerous = EnumerableSpecs::Numerous.new(1, [2, 3], [4, [5, 6]], {:foo => :bar})
+    numerous.send(@method){ |i| i }.should == [1, 2, 3, 4, [5, 6], {:foo => :bar}]
+  end 
+
+  it "skips elements that are empty Arrays" do
+    numerous = EnumerableSpecs::Numerous.new(1, [], 2)
+    numerous.send(@method){ |i| i }.should == [1, 2]
+  end 
+
+  it "calls to_ary but not to_a" do
+    obj = mock('array-like')
+    obj.should_receive(:to_ary).and_return([:foo])
+    obj2 = mock('has a to_a')
+    obj2.should_not_receive(:to_a)
+    
+    numerous = EnumerableSpecs::Numerous.new(obj, obj2)
+    numerous.send(@method){ |i| i }.should == [:foo, obj2]
+  end 
+
+  it "returns an enumerator when no block given" do
+    enum = EnumerableSpecs::Numerous.new(1, 2).send(@method)
+    enum.should be_kind_of(enumerator_class)
+    enum.each{ |i| [i] * i }.should == [1, 2, 2]
+  end
+end

Modified: MacRuby/trunk/spec/frozen/core/enumerable/sort_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/sort_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerable/sort_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -13,12 +13,22 @@
     EnumerableSpecs::Numerous.new(2,0,1,3,4).sort { |n, m| -(n <=> m) }.should == [4,3,2,1,0]
   end
 
-  it "sort should throw a NoMethodError if elements do not define <=>" do
-    lambda {
-      EnumerableSpecs::Numerous.new(Object.new, Object.new, Object.new).sort
-    }.should raise_error(NoMethodError)
+  ruby_version_is ""..."1.9" do
+    it "raises a NoMethodError if elements do not define <=>" do
+      lambda {
+        EnumerableSpecs::Numerous.new(Object.new, Object.new, Object.new).sort
+      }.should raise_error(NoMethodError)
+    end
   end
 
+  ruby_version_is "1.9" do
+    it "raises a NoMethodError if elements do not define <=>" do
+      lambda do
+        EnumerableSpecs::Numerous.new(BasicObject.new, BasicObject.new, BasicObject.new).sort
+      end.should raise_error(NoMethodError)
+    end
+  end
+
   it "sorts enumerables that contain nils" do
     arr = EnumerableSpecs::Numerous.new(nil, true, nil, false, nil, true, nil, false, nil)
     arr.sort { |a, b|

Modified: MacRuby/trunk/spec/frozen/core/enumerator/each_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/each_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/each_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/../../shared/enumerator/each'
 
-ruby_version_is "1.9" do
+ruby_version_is "1.8.7" do
   describe "Enumerator#each" do
     it_behaves_like(:enum_each, :each)
   end

Modified: MacRuby/trunk/spec/frozen/core/enumerator/each_with_index_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/each_with_index_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/each_with_index_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do
+ruby_version_is "1.8.7" do
   require File.dirname(__FILE__) + '/../../shared/enumerator/with_index'
 
   describe "Enumerator#each_with_index" do

Modified: MacRuby/trunk/spec/frozen/core/enumerator/enum_for_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/enum_for_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/enum_for_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do
+ruby_version_is "1.8.7" do
   require File.dirname(__FILE__) + '/../../shared/enumerator/enum_for'
   
   describe "#enum_for" do

Modified: MacRuby/trunk/spec/frozen/core/enumerator/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/new_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/new_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,24 +1,26 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do
+ruby_version_is "1.8.7" do
   require File.dirname(__FILE__) + '/../../shared/enumerator/new'
 
   describe "Enumerator.new" do
     it_behaves_like(:enum_new, :new)
 
-    it "accepts a block" do
-      enum = enumerator_class.new do |yielder|
-        yielder.yield 3
-        yielder.yield 2
-        yielder.yield 1
+    ruby_version_is "1.9" do
+      it "accepts a block" do
+        enum = enumerator_class.new do |yielder|
+          yielder.yield 3
+          yielder.yield 2
+          yielder.yield 1
+        end
+        enum.should be_kind_of(enumerator_class)
+        enum.to_a.should == [3,2,1]
       end
-      enum.should be_kind_of(enumerator_class)
-      enum.to_a.should == [3,2,1]
-    end
 
-    it "ignores block if arg given" do
-      enum = enumerator_class.new([1,2,3]){|y| y.yield 4}
-      enum.to_a.should == [1,2,3]
+      it "ignores block if arg given" do
+        enum = enumerator_class.new([1,2,3]){|y| y.yield 4}
+        enum.to_a.should == [1,2,3]
+      end
     end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/enumerator/next_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/next_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/next_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do  
+# TODO: enable for 1.8.7 as well
+ruby_version_is "1.9" do
   require File.dirname(__FILE__) + '/../../shared/enumerator/next'
   
   describe "Enumerator#next" do

Modified: MacRuby/trunk/spec/frozen/core/enumerator/peek_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/peek_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/peek_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do  
+ruby_version_is "1.9" do
   describe "Enumerator#peek" do
     before(:each) do
       @e = (1..5).to_a.to_enum

Modified: MacRuby/trunk/spec/frozen/core/enumerator/rewind_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/rewind_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/rewind_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,22 +1,24 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do  
+ruby_version_is "1.8.7" do
   require File.dirname(__FILE__) + '/../../shared/enumerator/rewind'
 
   describe "Enumerator#rewind" do
     it_behaves_like(:enum_rewind, :rewind)
 
-    it "calls the enclosed object's rewind method if one exists" do
-      obj = mock('rewinder')
-      enum = enumerator_class.new(obj, :enum) 
-      obj.should_receive(:rewind)
-      enum.rewind
-    end
+    ruby_version_is "1.9" do
+      it "calls the enclosed object's rewind method if one exists" do
+        obj = mock('rewinder')
+        enum = enumerator_class.new(obj, :enum)
+        obj.should_receive(:rewind)
+        enum.rewind
+      end
 
-    it "does nothing if the object doesn't have a #rewind method" do
-      obj = mock('rewinder')
-      enum = enumerator_class.new(obj) 
-      lambda { enum.rewind.should == enum }.should_not raise_error
+      it "does nothing if the object doesn't have a #rewind method" do
+        obj = mock('rewinder')
+        enum = enumerator_class.new(obj)
+        lambda { enum.rewind.should == enum }.should_not raise_error
+      end
     end
-  end    
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/enumerator/to_enum_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/to_enum_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/to_enum_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do
+ruby_version_is "1.8.7" do
   require File.dirname(__FILE__) + '/../../shared/enumerator/enum_for'
 
   describe "#to_enum" do

Modified: MacRuby/trunk/spec/frozen/core/enumerator/with_index_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerator/with_index_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/enumerator/with_index_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,31 +1,68 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
-ruby_version_is "1.9" do
+ruby_version_is "1.8.7" do
   require File.dirname(__FILE__) + '/../../shared/enumerator/with_index'
 
   describe "Enumerator#with_index" do
     it_behaves_like(:enum_with_index, :with_index)
 
-    it "accepts an optional argument when given a block" do
-      lambda do
-        @enum.with_index(1) { |f| f}
-      end.should_not raise_error(ArgumentError)
-    end
+    ruby_version_is "1.9" do
+      it "accepts an optional argument when given a block" do
+        lambda do
+          @enum.with_index(1) { |f| f}
+        end.should_not raise_error(ArgumentError)
+      end
 
-    it "accepts an optional argument when not given a block" do
-      lambda do
-        @enum.with_index(1)
-      end.should_not raise_error(ArgumentError)
-    end
+      it "accepts an optional argument when not given a block" do
+        lambda do
+          @enum.with_index(1)
+        end.should_not raise_error(ArgumentError)
+      end
 
-    it "numbers indices from the given index when given an offset but no block" do
-      @enum.with_index(1).to_a.should == [[1,1],[2,2],[3,3],[4,4]]
-    end
+      it "numbers indices from the given index when given an offset but no block" do
+        @enum.with_index(1).to_a.should == [[1,1], [2,2], [3,3], [4,4]]
+      end
 
-    it "numbers indices from the given index when given an offset and block" do
-      acc = []
-      @enum.with_index(1) {|e,i| acc << [e,i] }
-      acc.should == [[1,1],[2,2],[3,3],[4,4]]
+      it "numbers indices from the given index when given an offset and block" do
+        acc = []
+        @enum.with_index(1) {|e,i| acc << [e,i] }
+        acc.should == [[1,1], [2,2], [3,3], [4,4]]
+      end
+
+      it "raises a TypeError when the argument cannot be converted to numeric" do
+        lambda do
+          @enum.with_index('1') {|*i| i}
+        end.should raise_error(TypeError)
+      end
+
+      it "converts non-numeric arguments to Integer via #to_int" do
+        (o = mock('1')).should_receive(:to_int).and_return(1)
+        @enum.with_index(o).to_a.should == [[1,1], [2,2], [3,3], [4,4]]
+      end
+
+      it "coerces the given numeric argument to an Integer" do
+        @enum.with_index(1.678).to_a.should == [[1,1], [2,2], [3,3], [4,4]]
+
+        res = []
+        @enum.with_index(1.001) { |*x| res << x}
+        res.should == [[1,1], [2,2], [3,3], [4,4]]
+      end
+
+      it "treats nil argument as no argument" do
+        @enum.with_index(nil).to_a.should == [[1,0], [2,1], [3,2], [4,3]]
+
+        res = []
+        @enum.with_index(nil) { |*x| res << x}
+        res.should == [[1,0], [2,1], [3,2], [4,3]]
+      end
+
+      it "accepts negative argument" do
+        @enum.with_index(-1).to_a.should == [[1,-1], [2,0], [3,1], [4,2]]
+
+        res = []
+        @enum.with_index(-1) { |*x| res << x}
+        res.should == [[1,-1], [2,0], [3,1], [4,2]]
+      end
     end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/exception/system_call_error_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/exception/system_call_error_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/exception/system_call_error_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -14,6 +14,15 @@
     SystemCallError.new(42).errno.should == 42
     SystemCallError.new(2**24).errno.should == 2**24
   end
+
+  it "constructs the appropriate Errno class" do
+    # EINVAL should be more or less mortable across the platforms,
+    # so let's use it then.
+    SystemCallError.new(22).should be_kind_of(SystemCallError)
+    SystemCallError.new(22).should be_an_instance_of(Errno::EINVAL)
+
+    SystemCallError.new(2**28).should be_an_instance_of(SystemCallError)
+  end
 end
 
 describe "SystemCallError#errno" do

Modified: MacRuby/trunk/spec/frozen/core/file/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/new_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/file/new_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/open'
 
 describe "File.new" do
   before :each do
@@ -154,4 +155,6 @@
       lambda { File.new(@fh.fileno, @flags) }.should raise_error(Errno::EINVAL)
     end
   end
+  
+  it_behaves_like :open_directory, :new
 end

Modified: MacRuby/trunk/spec/frozen/core/file/open_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/open_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/file/open_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/open'
 
 describe "File.open" do
   before :all do
@@ -153,8 +154,9 @@
   end
 
   it "opens the file when call with fd" do
-    @fh = File.open(@file)
-    @fh = File.open(@fh.fileno)
+    # store in an ivar so it doesn't GC before we go to close it in 'after'
+    @fh_orig = File.open(@file)
+    @fh = File.open(@fh_orig.fileno)
     @fh.should be_kind_of(File)
     File.exist?(@file).should == true
   end
@@ -542,4 +544,6 @@
   it "raises an ArgumentError if passed an invalid string for mode" do
     lambda { File.open(@file, 'fake') }.should raise_error(ArgumentError)
   end
+  
+  it_behaves_like :open_directory, :open
 end

Modified: MacRuby/trunk/spec/frozen/core/file/path_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/path_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/file/path_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -11,9 +11,12 @@
     File.delete(@file2) if File.exist?(@file2)
   end
 
-  it "returns the pathname used to create file as a string" do
-    File.open(@file1,'w'){|file| file.path.should == "testfile"}
-    File.open(@file2, 'w'){|file| file.path.should == tmp("../tmp/xxx")}
+  # MRI fails this when /var path has symlinks, as on OS X
+  quarantine! do
+    it "returns the pathname used to create file as a string" do
+      File.open(@file1,'w'){|file| file.path.should == "testfile"}
+      File.open(@file2, 'w'){|file| file.path.should == tmp("../tmp/xxx")}
+    end
   end
 end
 

Added: MacRuby/trunk/spec/frozen/core/file/shared/open.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/shared/open.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/file/shared/open.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../../dir/fixtures/common'
+
+describe :open_directory, :shared => true do
+  it "opens directories" do
+    lambda { File.send(@method, DirSpecs.mock_dir) }.should_not raise_error
+    File.directory?(DirSpecs.mock_dir).should == true
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/core/file/truncate_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/truncate_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/file/truncate_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -94,7 +94,7 @@
 
   platform_is_not :windows do
     it "truncates an absolute pathname file" do
-      absolute_pathname_file = "/tmp/#{@name}"
+      absolute_pathname_file = tmp("#{@name}")
       File.open(absolute_pathname_file,"w") { |f| f.write("1234567890") }
       File.truncate(absolute_pathname_file, 5)
       File.size(absolute_pathname_file).should == 5

Modified: MacRuby/trunk/spec/frozen/core/fixnum/divide_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/fixnum/divide_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/fixnum/divide_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -5,6 +5,10 @@
     (2 / 2).should == 1
     (3 / 2).should == 1
   end
+
+  it "supports dividing negative numbers" do
+    (-1 / 10).should == -1
+  end
   
   it "raises a ZeroDivisionError if the given argument is zero and not a Float" do
     lambda { 1 / 0 }.should raise_error(ZeroDivisionError)

Modified: MacRuby/trunk/spec/frozen/core/fixnum/right_shift_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/fixnum/right_shift_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/fixnum/right_shift_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -43,5 +43,11 @@
     (-3 >> obj).should == -1
   end
 
+  it "wraps to 0 when shifting all bits off" do
+    # test for both Fixnum size boundaries
+    (5 >> 32).should == 0
+    (5 >> 64).should == 0
+  end
 
+
 end

Modified: MacRuby/trunk/spec/frozen/core/hash/default_proc_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/hash/default_proc_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/hash/default_proc_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -41,5 +41,22 @@
       lambda{new_hash.default_proc = nil}.should raise_error(TypeError)
       lambda{new_hash.default_proc = 42}.should raise_error(TypeError)
     end
+
+    it "raises a TypeError if passed a lambda with an arity other than 2" do
+      h = new_hash
+      lambda do
+        h.default_proc = lambda {|a| }
+      end.should raise_error(TypeError)
+      lambda do
+        h.default_proc = lambda {|a,b,c| }
+      end.should raise_error(TypeError)
+    end
+
+    it "accepts a lambda with an arity of 2" do
+      h = new_hash
+      lambda do
+        h.default_proc = lambda {|a,b| }
+      end.should_not raise_error(TypeError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/hash/hash_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/hash/hash_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/hash/hash_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -27,12 +27,17 @@
       h = {} ; h[:x] = h
       h.hash.should == {:x => h}.hash
       h.hash.should == {:x => {:x => h}}.hash
+      # This is because h.eql?(:x => h)
+      # Remember that if two objects are eql?
+      # then the need to have the same hash.
+      # Check the Hash#eql? specs!
     end
 
     it "returns the same hash for recursive hashes through arrays" do
       h = {} ; rec = [h] ; h[:x] = rec
       h.hash.should == {:x => rec}.hash
       h.hash.should == {:x => [h]}.hash
+      # Like above, because h.eql?(:x => [h])
     end
   end
 

Modified: MacRuby/trunk/spec/frozen/core/io/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/fixtures/classes.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/io/fixtures/classes.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -32,4 +32,9 @@
     }
   end
 
+  class NotConvertable
+    def to_io
+      raise TypeError
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/io/gets_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/gets_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/io/gets_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -174,6 +174,7 @@
     f.fileno.should == g.fileno
     lambda { g.gets }.should raise_error(IOError)
     g.close
+    lambda { f.close }.should raise_error(Errno::EBADF)
     File.unlink(tmp("gets_specs"))
   end
 

Modified: MacRuby/trunk/spec/frozen/core/io/inspect_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/inspect_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/io/inspect_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -7,13 +7,16 @@
   end
 
   after :each do
-    @file.close
+    @file.close if !@file.closed?
     File.unlink(tmp("inspect_spec"))
   end
 
   it "returns a string describing a stream" do
     # don't hardcode the tmp path 
     @file.inspect.should =~ /#<File.*inspect_spec>/
-    IO.new(@file.to_i).inspect.should =~ /<IO:[\w\s?\d]+>/
+    io = IO.new(@file.to_i)
+    io.inspect.should =~ /<IO:[\w\s?\d]+>/
+    io.close
+    lambda { @file.close }.should raise_error(Errno::EBADF)
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/io/output_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/output_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/io/output_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -18,4 +18,10 @@
     io = IOSpecs.closed_file
     lambda { io << "test" }.should raise_error(IOError)
   end
+
+  it "returns self" do
+    lambda {
+      ($stderr << "to_stderr").should == $stderr
+    }.should output(nil, "to_stderr")
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/io/popen_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/popen_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/io/popen_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -32,6 +32,7 @@
             lambda { io.read.should }.should \
               raise_error(IOError, 'not opened for reading')
           end
+          system 'sync' # sync to flush writes for File.read below
 
           File.read(tmp_file).should == 'bar'
 

Added: MacRuby/trunk/spec/frozen/core/io/try_convert_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/try_convert_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/io/try_convert_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,36 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "IO.try_convert" do
+  ruby_version_is "1.9" do
+    it "returns self for IO objects" do
+      fd_1 = IO.new(1)
+      IO.try_convert(fd_1).should equal(fd_1)
+    end
+    
+    it "converts using :to_io" do
+      io = File.new(__FILE__)
+      obj = mock('ioish')
+      obj.should_receive(:to_io).and_return(io)
+      IO.try_convert(obj).should equal(io)
+    end
+    
+    it "returns nil when the argument doesn't respond to :to_io" do
+      IO.try_convert(-1).should be_nil
+    end
+    
+    it "should not rescue errors" do
+      lambda{
+        IO.try_convert(IOSpecs::NotConvertible.new)
+      }.should raise_error
+    end
+    
+    it "checks the result of the conversion" do
+      obj = mock('middle child')
+      obj.should_receive(:to_io).and_return(:confused)
+      lambda{
+        IO.try_convert(obj)
+      }.should raise_error(TypeError)
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/core/kernel/Integer_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/Integer_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/Integer_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -493,6 +493,10 @@
         lambda { Integer("0#{d}1", base) }.should raise_error(ArgumentError)
       end
     end
+
+    it "raises an ArgumentError if a base is given for a non-String value" do
+      lambda { Integer(98, 15) }.should raise_error(ArgumentError)
+    end
   end
 end
 

Added: MacRuby/trunk/spec/frozen/core/kernel/comparison_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/comparison_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/kernel/comparison_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,33 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+  describe "Kernel#<=>" do
+    it "returns 0 if self" do
+      obj = Object.new
+      obj.<=>(obj).should == 0
+    end
+
+    it "returns 0 if self is == to the argument" do
+      obj = mock('has ==')
+      obj.should_receive(:==).and_return(true)
+      obj.<=>(Object.new).should == 0
+    end
+
+    it "returns nil if self is eql? but not == to the argument" do
+      obj = mock('has eql?')
+      obj.should_not_receive(:eql?)
+      obj.<=>(Object.new).should be_nil
+    end
+
+    it "returns nil if self.==(arg) returns nil" do
+      obj = mock('wrong ==')
+      obj.should_receive(:==).and_return(nil)
+      obj.<=>(Object.new).should be_nil
+    end
+
+    it "returns nil if self is not == to the argument" do
+      obj = Object.new
+      obj.<=>(3.14).should be_nil
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,15 +1,8 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/fixtures/classes'
 
-class A
-  eval "class B; end"
-  def c
-    eval "class C; end"
-  end
-end
+EvalSpecs::A.new.c
 
-A.new.c
-
 describe "Kernel#eval" do
   it "is a private method" do
     Kernel.should have_private_instance_method(:eval)
@@ -24,13 +17,53 @@
   end
 
   it "evaluates within the scope of the eval" do
-    A::B.name.should == "A::B"
+    EvalSpecs::A::B.name.should == "EvalSpecs::A::B"
   end
 
   it "evaluates such that consts are scoped to the class of the eval" do
-    A::C.name.should == "A::C"
+    EvalSpecs::A::C.name.should == "EvalSpecs::A::C"
   end
 
+  it "finds a local in an enclosing scope" do
+    a = 1
+    eval("a").should == 1
+  end
+
+  it "updates a local in an enclosing scope" do
+    a = 1
+    eval("a = 2").should == 2
+    a.should == 2
+  end
+
+  it "creates an eval-scope local" do
+    eval("eval_only_local = 1; eval_only_local").should == 1
+    lambda { eval_only_local }.should raise_error(NameError)
+  end
+
+  it "updates a local in a surrounding block scope" do
+    EvalSpecs.new.f do
+      a = 1
+      eval("a = 2").should == 2
+      a.should == 2
+    end
+  end
+
+  it "updates a local in a scope above a surrounding block scope" do
+    a = 1
+    EvalSpecs.new.f do
+      eval("a = 2").should == 2
+      a.should == 2
+    end
+    a.should == 2
+  end
+
+  it "updates a local in a scope above when modified in a nested block scope" do
+    a = 1
+    es = EvalSpecs.new
+    eval("es.f { es.f { a = 2 } }").should == 2
+    a.should == 2
+  end
+
   ruby_version_is ""..."1.9" do
     it "accepts a Proc object as a binding" do
       x = 1

Modified: MacRuby/trunk/spec/frozen/core/kernel/exit_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/exit_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/exit_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -13,9 +13,75 @@
   end
 end
 
+describe "Kernel.exit" do
+  before :each do
+    ScratchPad.clear
+  end
 
-describe "Kernel.exit" do
-  it "needs to be reviewed for spec completeness"
+  it "raises a SystemExit with status 0" do
+    begin
+      exit
+      ScratchPad.record :no_exit
+    rescue SystemExit => e
+      e.status.should == 0
+    end
+    ScratchPad.recorded.should be_nil
+  end
+
+  it "raises a SystemExit with the specified status" do
+    [-2**16, -2**8, -8, -1, 0, 1 , 8, 2**8, 2**16].each { |value|
+      begin
+        exit(value)
+        ScratchPad.record :no_exit
+      rescue SystemExit => e
+        e.status.should == value
+      end
+      ScratchPad.recorded.should be_nil
+    }
+  end
+
+  it "raises a SystemExit with the specified boolean status" do
+    { true => 0, false => 1 }.each { |value, status|
+      begin
+        exit(value)
+        ScratchPad.record :no_exit
+      rescue SystemExit => e
+        e.status.should == status
+      end
+      ScratchPad.recorded.should be_nil
+    }
+  end
+
+  it "tries to convert the passed argument to an Integer using #to_int" do
+    obj = mock('5')
+    obj.should_receive(:to_int).and_return(5)
+    begin
+        exit(obj)
+        ScratchPad.record :no_exit
+      rescue SystemExit => e
+        e.status.should == 5
+      end
+      ScratchPad.recorded.should be_nil
+  end
+
+  it "converts the passed Float argument to an Integer" do
+    { -2.2 => -2, -0.1 => 0, 5.5 => 5, 827.999 => 827 }.each { |value, status|
+      begin
+        exit(value)
+        ScratchPad.record :no_exit
+      rescue SystemExit => e
+        e.status.should == status
+      end
+      ScratchPad.recorded.should be_nil
+    }
+  end
+
+  it "raises TypeError if can't convert the argument to an Integer" do
+    lambda { exit(Object.new) }.should raise_error(TypeError)
+    lambda { exit('0') }.should raise_error(TypeError)
+    lambda { exit([0]) }.should raise_error(TypeError)
+    lambda { exit(nil) }.should raise_error(TypeError)
+  end
 end
 
 describe "Kernel.exit!" do

Modified: MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -227,8 +227,40 @@
   class Grandchild < Child
     undef_method :parent_mixin_method
   end
+
+  class RespondViaMissing
+    def respond_to_missing?(method, priv=false)
+      case method
+        when :handled_publicly
+          true
+        when :handled_privately
+          priv
+        when :not_handled
+          false
+        else
+          raise "Typo in method name"
+      end
+    end
+
+    def method_missing(method, *args)
+      "Done #{method}(#{args})"
+    end
+  end
 end
 
+class EvalSpecs
+  class A
+    eval "class B; end"
+    def c
+      eval "class C; end"
+    end
+  end
+
+  def f
+    yield
+  end
+end
+
 # for Kernel#sleep to have Channel in it's specs
 # TODO: switch directly to queue for both Kernel#sleep and Thread specs?
 unless defined? Channel

Modified: MacRuby/trunk/spec/frozen/core/kernel/method_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/method_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/method_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -20,4 +20,13 @@
     @obj.send(:protected_method).should == :protected_method
     @obj.method(:protected_method).should be_an_instance_of(Method)
   end
+
+  ruby_version_is "1.9.2" do
+    it "can be called even if we only repond_to_missing? method, true" do
+      m = KernelSpecs::RespondViaMissing.new.method(:handled_privately)
+      m.should be_an_instance_of(Method)
+      m.call(1, 2, 3).should == "Done handled_privately([1, 2, 3])"
+    end
+  end
+
 end

Modified: MacRuby/trunk/spec/frozen/core/kernel/public_method_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/public_method_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/public_method_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -23,5 +23,15 @@
         @obj.public_method(:protected_method)
        end.should raise_error(NameError)
     end
+
+    ruby_version_is "1.9.2" do
+      it "raises a NameError if we only repond_to_missing? method, true" do
+        obj = KernelSpecs::RespondViaMissing.new
+        lambda do
+          obj.public_method(:handled_privately)
+        end.should raise_error(NameError)
+      end
+    end
+
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/kernel/respond_to_missing_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/respond_to_missing_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/respond_to_missing_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -7,10 +7,6 @@
       @a = KernelSpecs::A.new  
     end
 
-    it "returns false by default" do
-      Object.new.respond_to_missing?.should be_false
-    end
-
     it "is not called when #respond_to? would return true" do
       obj = mock('object')
       obj.stub!(:glark)
@@ -18,9 +14,15 @@
       obj.respond_to?(:glark).should be_true
     end
 
-    it "is called when #respond_to? would return false" do
+    it "is called with a 2nd argument of false when #respond_to? is" do
       obj = mock('object')
-      obj.should_receive(:respond_to_missing?).with(:undefined_method)
+      obj.should_receive(:respond_to_missing?).with(:undefined_method, false)
+      obj.respond_to?(:undefined_method, false)
+    end
+
+    it "is called a 2nd argument of false when #respond_to? is called with only 1 argument" do
+      obj = mock('object')
+      obj.should_receive(:respond_to_missing?).with(:undefined_method, false)
       obj.respond_to?(:undefined_method)
     end
 
@@ -30,24 +32,24 @@
       obj.respond_to?(:undefined_method, true)
     end
 
+    it "is called when #respond_to? would return false" do
+      obj = mock('object')
+      obj.should_receive(:respond_to_missing?).with(:undefined_method, false)
+      obj.respond_to?(:undefined_method)
+    end
+
     it "causes #respond_to? to return true if called and not returning false" do
       obj = mock('object')
-      obj.should_receive(:respond_to_missing?).with(:undefined_method).and_return(:glark)
+      obj.should_receive(:respond_to_missing?).with(:undefined_method, false).and_return(:glark)
       obj.respond_to?(:undefined_method).should be_true
     end
 
     it "causes #respond_to? to return false if called and returning false" do
       obj = mock('object')
-      obj.should_receive(:respond_to_missing?).with(:undefined_method).and_return(false)
+      obj.should_receive(:respond_to_missing?).with(:undefined_method, false).and_return(false)
       obj.respond_to?(:undefined_method).should be_false
     end
 
-    it "is not called with false as a second argument when #respond_to? is" do
-      obj = mock('object')
-      obj.should_receive(:respond_to_missing?).with(:undefined_method)
-      obj.respond_to?(:undefined_method, false)
-    end
-
     it "isn't called when obj responds to the given public method" do    
       @a.should_not_receive(:respond_to_missing?)
       @a.respond_to?(:pub_method).should be_true
@@ -69,7 +71,7 @@
     end
     
     it "is called when obj responds to the given private method, include_private = false" do    
-      @a.should_receive(:respond_to_missing?).with(:private_method)
+      @a.should_receive(:respond_to_missing?).with(:private_method, false)
       @a.respond_to?(:private_method)
     end 
 
@@ -79,7 +81,7 @@
     end
 
     it "is called for missing class methods" do
-      @a.class.should_receive(:respond_to_missing?).with(:oOoOoO)
+      @a.class.should_receive(:respond_to_missing?).with(:oOoOoO, false)
       @a.class.respond_to?(:oOoOoO)
     end
   end

Modified: MacRuby/trunk/spec/frozen/core/kernel/shared/method.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/shared/method.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/shared/method.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,14 +3,31 @@
 describe :kernel_method, :shared => true do
   it "returns a method object for a valid method" do
     class KernelSpecs::Foo; def bar; 'done'; end; end
-    KernelSpecs::Foo.new.send(@method, :bar).class.should == Method
+    m = KernelSpecs::Foo.new.send(@method, :bar)
+    m.should be_an_instance_of Method
+    m.call.should == 'done'
   end
 
   it "returns a method object for a valid singleton method" do
-    class KernelSpecs::Foo; def self.bar; 'done'; end; end
-    KernelSpecs::Foo.send(@method, :bar).class.should == Method
+    class KernelSpecs::Foo; def self.bar; 'class done'; end; end
+    m = KernelSpecs::Foo.send(@method, :bar)
+    m.should be_an_instance_of Method
+    m.call.should == 'class done'
   end
 
+  ruby_version_is "1.9.2" do
+    it "returns a method object if we repond_to_missing? method" do
+      class KernelSpecs::Foo;
+        def respond_to_missing?(method, priv=false)
+          method == :we_handle_this
+        end
+      end
+      m = KernelSpecs::RespondViaMissing.new.method(:handled_publicly)
+      m.should be_an_instance_of Method
+      m.call(42).should == "Done handled_publicly([42])"
+    end
+  end
+
   it "raises a NameError for an invalid method name" do
     class KernelSpecs::Foo; def bar; 'done'; end; end
     lambda {
@@ -23,8 +40,7 @@
     lambda { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
   end
 
-  # This may be a bug; see http://redmine.ruby-lang.org/issues/show/1151
-  ruby_version_is "" ... "1.9" do
+  ruby_bug "redmine:1151", "1.8.7" do
     it "changes the method called for super on a target aliased method" do
       c1 = Class.new do
         def a; 'a'; end
@@ -37,7 +53,7 @@
 
       c2.new.a.should == 'a'
       c2.new.b.should == 'a'
-      c2.new.send(@method, :b).call.should == 'b'
+      c2.new.send(@method, :b).call.should == 'a'
     end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/kernel/taint_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/taint_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/kernel/taint_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -7,7 +7,7 @@
   end
 
   it "has no effect on immediate values" do
-    inmediate_values = [a = nil, b = true, c = false, d = 1, e = "a string"]
-    inmediate_values.each{ |v| v.tainted?.should == false}
+    imediate_values = [nil, true, false, 1, :sym]
+    imediate_values.each{ |v| v.taint; v.tainted?.should be_false}
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -301,16 +301,13 @@
   end
   
   it "raises EOFError on loading an empty file" do
-    temp_file = tmp("marshal.rubinius.tmp.#{Process.pid}")
+    temp_file = tmp("marshal.rubyspec.tmp.#{Process.pid}")
     file = File.new(temp_file, "w+")
     begin
-      # TODO: This should be in an ensure block, but because of a bug in
-      # Rubinius that can't be done yet.
-      File.unlink(temp_file)
-
       lambda { Marshal.load(file) }.should raise_error(EOFError)
     ensure
       file.close
+      File.unlink(temp_file)
     end
   end
 

Modified: MacRuby/trunk/spec/frozen/core/method/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/method/fixtures/classes.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/method/fixtures/classes.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -31,7 +31,7 @@
       true
     end
 
-    def respond_to_missing? method
+    def respond_to_missing? method, bool
       [:handled_via_method_missing, :also_handled].include? method
     end
 

Modified: MacRuby/trunk/spec/frozen/core/module/module_function_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/module_function_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/module/module_function_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -99,6 +99,13 @@
     o.should_receive(:to_str).and_return(123)
     lambda { Module.new { module_function(o) } }.should raise_error(TypeError)
   end
+
+  it "can make accessible private methods" do # JRUBY-4214
+    m = Module.new do
+      module_function :require
+    end
+    m.respond_to?(:require).should be_true 
+  end
 end
 
 describe "Module#module_function as a toggle (no arguments) in a Module body" do

Modified: MacRuby/trunk/spec/frozen/core/proc/shared/call.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/proc/shared/call.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/proc/shared/call.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -18,6 +18,12 @@
     proc { |*args| args }.send(@method, 1, 2, 3, 4).should == [1, 2, 3, 4]
     proc { |_, *args| args }.send(@method, 1, 2, 3).should == [2, 3]
   end
+
+  it "is being able to receive block arguments" do
+    Proc.new {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
+    lambda {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
+    proc {|&b| b.send(@method)}.send(@method) {1 + 1}.should == 2
+  end
   
   ruby_version_is ""..."1.9" do
     it "sets self's single parameter to an Array of all given values" do

Modified: MacRuby/trunk/spec/frozen/core/random/rand_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/random/rand_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/random/rand_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -93,7 +93,7 @@
 
   describe "Random#rand with Bignum" do
     it "returns a Bignum" do
-      Random.new.rand(bignum_value).should be_an_instance_of(Bignum)
+      Random.new(1).rand(bignum_value).should be_an_instance_of(Bignum)
     end
 
     it "returns a Bignum greater than or equal to 0" do

Modified: MacRuby/trunk/spec/frozen/core/range/each_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/range/each_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/range/each_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -35,7 +35,7 @@
     lambda { (0.5..2.4).each { |i| i } }.should raise_error(TypeError)
 
     b = mock('x')
-    (a = mock('1')).should_receive(:method_missing).with(:<=>, b).and_return(1)
+    (a = mock('1')).should_receive(:<=>).with(b).and_return(1)
 
     lambda { (a..b).each { |i| i } }.should raise_error(TypeError)
   end

Modified: MacRuby/trunk/spec/frozen/core/range/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/range/new_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/range/new_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -28,7 +28,7 @@
     lambda { Range.new(mock('x'), mock('y')) }.should raise_error(ArgumentError)
     
     b = mock('x')
-    (a = mock('nil')).should_receive(:method_missing).with(:<=>, b).and_return(nil)
+    (a = mock('nil')).should_receive(:<=>).with(b).and_return(nil)
     lambda { Range.new(a, b) }.should raise_error(ArgumentError)
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/range/step_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/range/step_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/range/step_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -27,8 +27,9 @@
 
   it "raises a TypeError if the first element does not respond to #succ" do
     b = mock('x')
-    (a = mock('1')).should_receive(:method_missing).with(:<=>, b).and_return(1)
-
+    (a = mock('1')).should_receive(:<=>).with(b).and_return(1)
+    a.should_not respond_to?(:succ)
+        
     lambda { (a..b).step(1) { |i| i } }.should raise_error(TypeError)
   end
 

Added: MacRuby/trunk/spec/frozen/core/string/encode_bang_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/encode_bang_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/string/encode_bang_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,43 @@
+# coding: utf-8
+require File.dirname(__FILE__) + '/shared/encode'
+
+ruby_version_is "1.9" do
+  describe "String#encode!" do
+    it_behaves_like :encode_string, :encode!
+
+    it "raises a RuntimeError when called on a frozen String" do
+      lambda do
+        "foo".freeze.encode!(Encoding::ANSI_X3_4_1968)
+      end.should raise_error(RuntimeError)
+    end
+
+    # http://redmine.ruby-lang.org/issues/show/1836
+    it "raises a RuntimeError when called on a frozen String when it's a no-op" do
+      lambda do
+        "foo".freeze.encode!("foo".encoding)
+      end.should raise_error(RuntimeError)
+    end
+
+    it "returns self when called with only a target encoding" do
+      str = "strung"
+      str.encode!(Encoding::BINARY).should == str.force_encoding(Encoding::BINARY)
+    end
+
+    it "returns self when called with only a target encoding" do
+      str = "strung"
+      str.encode!(Encoding::BINARY,Encoding::ASCII).should == str.force_encoding(Encoding::BINARY)
+    end
+
+    it "returns self even when no changes are made" do
+      str = "strung"
+      str.encode!(Encoding::UTF_8).should == str
+    end
+
+    it "tags the String with the given encoding" do
+      str = "ürst"
+      str.encoding.should == Encoding::UTF_8
+      str.encode!(Encoding::UTF_16LE)
+      str.encoding.should == Encoding::UTF_16LE
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/core/string/encode_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/encode_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/string/encode_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,229 +1,10 @@
 # coding: utf-8
-ruby_version_is "1.9" do
-  describe "String#encode!" do
+require File.dirname(__FILE__) + '/shared/encode'
 
-    it "transcodes to the default internal encoding with no argument" do
-      begin
-        old_default_internal = Encoding.default_internal
-        Encoding.default_internal = Encoding::EUC_JP
-        str = "問か".force_encoding('utf-8')
-        str.encoding.should_not == Encoding.default_internal
-        str.encode!
-        str.encoding.should == Encoding.default_internal
-      ensure
-        Encoding.default_internal = old_default_internal
-      end
-    end
-
-    it "accepts a target encoding name as a String for an argument" do
-      str = "Füll"
-      lambda do
-        str.encode!('binary')
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target encoding as an Encoding for an argument" do
-      str = "Füll"
-      lambda do
-        str.encode!(Encoding::BINARY)
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target and source encoding given as Encoding objects" do
-      str = "Füll"
-      lambda do
-        str.encode!(Encoding::ASCII, Encoding::BINARY)
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target and source encoding given as Strings" do
-      str = "Füll"
-      lambda do
-        str.encode!('ascii', 'binary')
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target encoding given as an Encoding, and a source encoding given as a String" do
-      str = "Füll"
-      lambda do
-        str.encode!(Encoding::ASCII, 'binary')
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target encoding given as a String, and a source encoding given as an Encoding" do
-      str = "Füll"
-      lambda do
-        str.encode!('ascii', Encoding::BINARY)
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts an options hash as the final argument" do
-      lambda do
-        "yes".encode!('ascii', Encoding::BINARY, {:xml => :text})
-      end.should_not raise_error(ArgumentError)
-
-      lambda do
-        "yes".encode!(Encoding::BINARY, {:xml => :text})
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "returns self when called with only a target encoding" do
-      str = "strung"
-      str.encode!(Encoding::BINARY).should == str.force_encoding(Encoding::BINARY)
-    end
-
-    it "returns self when called with only a target encoding" do
-      str = "strung"
-      str.encode!(Encoding::BINARY,Encoding::ASCII).should == str.force_encoding(Encoding::BINARY)
-    end
-
-    it "returns self even when no changes are made" do
-      str = "strung"
-      str.encode!(Encoding::UTF_8).should == str
-    end
-
-    it "tags the String with the given encoding" do
-      str = "ürst"
-      str.encoding.should == Encoding::UTF_8
-      str.encode!(Encoding::UTF_16LE)
-      str.encoding.should == Encoding::UTF_16LE
-    end
-
-    it "transcodes self to the given encoding" do
-      str = "\u3042".force_encoding('UTF-8')
-      str.encode!(Encoding::EUC_JP)
-      str.should == "\xA4\xA2".force_encoding('EUC-JP')
-    end
-   
-    it "can convert between encodings where a multi-stage conversion path is needed" do
-      str = "big?".force_encoding(Encoding::US_ASCII)
-      str.encode!(Encoding::Big5, Encoding::US_ASCII)
-      str.encoding.should == Encoding::Big5
-    end
-
-    it "raises an Encoding::InvalidByteSequenceError for invalid byte sequences" do
-      lambda do
-        "\xa4".force_encoding(Encoding::EUC_JP).encode!('iso-8859-1')
-      end.should raise_error(Encoding::InvalidByteSequenceError)
-    end
-
-    it "raises UndefinedConversionError if the String contains characters invalid for the target     encoding" do
-      str = "\u{6543}"
-      lambda do
-        str.encode!(Encoding.find('macCyrillic'))
-      end.should raise_error(Encoding::UndefinedConversionError)
-    end
-    
-    it "raises Encoding::ConverterNotFoundError for invalid target encodings" do
-      lambda do
-        "\u{9878}".encode!('xyz')
-      end.should raise_error(Encoding::ConverterNotFoundError)
-    end
-
-    it "raises a RuntimeError when called on a frozen String" do
-      lambda do
-        "foo".freeze.encode!(Encoding::ANSI_X3_4_1968) 
-      end.should raise_error(RuntimeError)
-    end
-
-    # http://redmine.ruby-lang.org/issues/show/1836
-    it "raises a RuntimeError when called on a frozen String when it's a no-op" do
-      lambda do
-        "foo".freeze.encode!("foo".encoding) 
-      end.should raise_error(RuntimeError)
-    end
-    
-    it "replaces invalid characters" do
-      str = "\222\xA1x"
-      str.encode!("iso-2022-jp", "stateless-iso-2022-jp", :invalid => :replace)
-      str.should == "?x".force_encoding("iso-2022-jp")
-    end
-
-    it "replaces undefined characters" do
-      str = "abc\u{fffd}def"
-      str.encode!("EUC-JP", "UTF-8", {:undef => :replace, :replace => ""})
-      str.should == "abcdef"
-    end
-
-    it "replaces xml characters" do
-      str = '<xml>bed & breakfast</xml>'
-      str.encode!('UTF-8', {:xml => :text})
-      str.should == "&lt;xml&gt;bed &amp; breakfast&lt;/xml&gt;"
-    end
-
-    it "replaces xml characters and quotes the result" do
-      str = '<xml>bed & breakfast</xml>'
-      str.encode!('UTF-8', {:xml => :attr})
-      str.should == "\"&lt;xml&gt;bed &amp; breakfast&lt;/xml&gt;\""
-    end
-  end
-
+ruby_version_is "1.9" do
   describe "String#encode" do
-
-    it "transcodes to the default internal encoding with no argument" do
-      begin
-        old_default_internal = Encoding.default_internal
-        Encoding.default_internal = Encoding::EUC_JP
-        str = "問か".force_encoding('utf-8')
-        str.encoding.should_not == Encoding.default_internal
-        str.encode.encoding.should == Encoding.default_internal
-      ensure
-        Encoding.default_internal = old_default_internal
-      end
-    end
-
-    it "accepts a target encoding name as a String for an argument" do
-      str = "Füll"
-      lambda do
-        str.encode('binary')
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target encoding as an Encoding for an argument" do
-      str = "Füll"
-      lambda do
-        str.encode(Encoding::BINARY)
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target and source encoding given as Encoding objects" do
-      str = "Füll"
-      lambda do
-        str.encode(Encoding::ASCII, Encoding::BINARY)
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target and source encoding given as Strings" do
-      str = "Füll"
-      lambda do
-        str.encode('ascii', 'binary')
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target encoding given as an Encoding, and a source encoding given as a String" do
-      str = "Füll"
-      lambda do
-        str.encode(Encoding::ASCII, 'binary')
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts a target encoding given as a String, and a source encoding given as an Encoding" do
-      str = "Füll"
-      lambda do
-        str.encode('ascii', Encoding::BINARY)
-      end.should_not raise_error(ArgumentError)
-    end
-
-    it "accepts an options hash as the final argument" do
-      lambda do
-        "yes".encode('ascii', Encoding::BINARY, {:xml => :text})
-      end.should_not raise_error(ArgumentError)
-
-      lambda do
-        "yes".encode(Encoding::BINARY, {:xml => :text})
-      end.should_not raise_error(ArgumentError)
-    end
-
+    it_behaves_like :encode_string, :encode
+    
     it "returns a copy of self when called with only a target encoding" do
       str = "strung".force_encoding(Encoding::UTF_8)
       copy = str.encode('ascii')
@@ -237,13 +18,13 @@
       copy.object_id.should_not == str.object_id
       str.encoding.should == Encoding::UTF_8
     end
-
+    
     it "returns a copy of self even when no changes are made" do
       str = "strung".force_encoding('ASCII')
       str.encode(Encoding::UTF_8).object_id.should_not == str.object_id
       str.encoding.should == Encoding::US_ASCII
     end
-
+    
     it "returns a String with the given encoding" do
       str = "ürst"
       str.encoding.should == Encoding::UTF_8
@@ -251,50 +32,5 @@
       copy.encoding.should == Encoding::UTF_16LE
       str.encoding.should == Encoding::UTF_8
     end
-
-    it "transcodes self to the given encoding" do
-      str = "\u3042".force_encoding('UTF-8')
-      str.encode(Encoding::EUC_JP).should == "\xA4\xA2".force_encoding('EUC-JP')
-    end
-   
-    it "can convert between encodings where a multi-stage conversion path is needed" do
-      str = "big?".force_encoding(Encoding::US_ASCII)
-      str.encode(Encoding::Big5, Encoding::US_ASCII).encoding.should == Encoding::Big5
-    end
-
-    it "raises an Encoding::InvalidByteSequenceError for invalid byte sequences" do
-      lambda do
-        "\xa4".force_encoding(Encoding::EUC_JP).encode('iso-8859-1')
-      end.should raise_error(Encoding::InvalidByteSequenceError)
-    end
-
-    it "raises UndefinedConversionError if the String contains characters invalid for the target     encoding" do
-      str = "\u{6543}"
-      lambda do
-        str.encode(Encoding.find('macCyrillic'))
-      end.should raise_error(Encoding::UndefinedConversionError)
-    end
-    
-    it "raises Encoding::ConverterNotFoundError for invalid target encodings" do
-      lambda do
-        "\u{9878}".encode('xyz')
-      end.should raise_error(Encoding::ConverterNotFoundError)
-    end
-    
-    it "replaces invalid characters" do
-      "\222\xA1x".encode("iso-2022-jp", "stateless-iso-2022-jp", :invalid => :replace).should == "?x".force_encoding("iso-2022-jp")
-    end
-    
-    it "replaces undefined characters" do
-      "abc\u{fffd}def".encode("EUC-JP", "UTF-8", {:undef => :replace, :replace => ""}).should == "abcdef"
-    end
-
-    it "replaces xml characters" do
-      '<xml>bed & breakfast</xml>'.encode('UTF-8', {:xml => :text}).should == "&lt;xml&gt;bed &amp; breakfast&lt;/xml&gt;"
-    end
-    
-    it "replaces xml characters and quotes the result" do
-      '<xml>bed & breakfast</xml>'.encode('UTF-8', {:xml => :attr}).should == "\"&lt;xml&gt;bed &amp; breakfast&lt;/xml&gt;\""
-    end
   end
-end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/core/string/gsub_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/gsub_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/string/gsub_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -274,7 +274,7 @@
 
     it "raises a TypeError if the hash has a default proc" do
       hsh = new_hash
-      hsh.default_proc = lambda { 'lamb' }
+      hsh.default_proc = lambda { |k,v| 'lamb' }
       lambda do
         "food!".gsub(/./, hsh)
       end.should_not raise_error(TypeError)

Modified: MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -15,7 +15,7 @@
     end
 
     it "returns a string with nonprinting, non-ASCII characters replaced by \\u notation for Unicode strings" do
-      (127..150).map{|o| o.chr('utf-8')}.to_a.join('').inspect.should == "\"\\u007F\\u0080\\u0081\\u0082\\u0083\\u0084\u0085\\u0086\\u0087\\u0088\\u0089\\u008A\\u008B\\u008C\\u008D\\u008E\\u008F\\u0090\\u0091\\u0092\\u0093\\u0094\\u0095\\u0096\""
+      (127..150).map{|o| o.chr('utf-8')}.to_a.join('').inspect.should == "\"\\u007F\\u0080\\u0081\\u0082\\u0083\\u0084\\u0085\\u0086\\u0087\\u0088\\u0089\\u008A\\u008B\\u008C\\u008D\\u008E\\u008F\\u0090\\u0091\\u0092\\u0093\\u0094\\u0095\\u0096\""
     end
   end
 

Modified: MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -440,21 +440,11 @@
     end
     
     ruby_version_is "1.9" do
-      platform_is :darwin do
-        it "pads with zeros using %E with Inf, -Inf, and NaN" do
-          ("%010E" % -1e1020).should == "-000000Inf"
-          ("%010E" % 1e1020).should == "0000000Inf"
-          ("%010E" % (0.0/0)).should == "0000000NaN"
-        end
+      it "pads with spaces for %E with Inf, -Inf, and NaN" do
+        ("%010E" % -1e1020).should == "      -Inf"
+        ("%010E" % 1e1020).should == "       Inf"
+        ("%010E" % (0.0/0)).should == "       NaN"
       end
-
-      platform_is_not :darwin do
-        it "pads with spaces for %E with Inf, -Inf, and NaN" do
-          ("%010E" % -1e1020).should == "      -Inf"
-          ("%010E" % 1e1020).should == "       Inf"
-          ("%010E" % (0.0/0)).should == "       NaN"
-        end
-      end
     end
   end
 

Added: MacRuby/trunk/spec/frozen/core/string/shared/encode.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/shared/encode.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/string/shared/encode.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,112 @@
+# coding: utf-8
+describe :encode_string, :shared => true do
+  it "transcodes to the default internal encoding with no argument" do
+    begin
+      old_default_internal = Encoding.default_internal
+      Encoding.default_internal = Encoding::EUC_JP
+      str = "問か".force_encoding('utf-8')
+      str.encoding.should_not == Encoding.default_internal
+      str.encode.encoding.should == Encoding.default_internal
+    ensure
+      Encoding.default_internal = old_default_internal
+    end
+  end
+
+  it "accepts a target encoding name as a String for an argument" do
+    str = "Füll"
+    lambda do
+      str.send(@method, 'binary')
+    end.should_not raise_error(ArgumentError)
+  end
+
+  it "accepts a target encoding as an Encoding for an argument" do
+    str = "Füll"
+    lambda do
+      str.send(@method, Encoding::BINARY)
+    end.should_not raise_error(ArgumentError)
+  end
+
+  it "accepts a target and source encoding given as Encoding objects" do
+    str = "Füll"
+    lambda do
+      str.send(@method, Encoding::ASCII, Encoding::BINARY)
+    end.should_not raise_error(ArgumentError)
+  end
+
+  it "accepts a target and source encoding given as Strings" do
+    str = "Füll"
+    lambda do
+      str.send(@method, 'ascii', 'binary')
+    end.should_not raise_error(ArgumentError)
+  end
+
+  it "accepts a target encoding given as an Encoding, and a source encoding given as a String" do
+    str = "Füll"
+    lambda do
+      str.send(@method, Encoding::ASCII, 'binary')
+    end.should_not raise_error(ArgumentError)
+  end
+
+  it "accepts a target encoding given as a String, and a source encoding given as an Encoding" do
+    str = "Füll"
+    lambda do
+      str.send(@method, 'ascii', Encoding::BINARY)
+    end.should_not raise_error(ArgumentError)
+  end
+
+  it "accepts an options hash as the final argument" do
+    lambda do
+      "yes".send(@method, 'ascii', Encoding::BINARY, {:xml => :text})
+    end.should_not raise_error(ArgumentError)
+
+    lambda do
+      "yes".send(@method, Encoding::BINARY, {:xml => :text})
+    end.should_not raise_error(ArgumentError)
+  end
+
+  it "transcodes self to the given encoding" do
+    str = "\u3042".force_encoding('UTF-8')
+    str.send(@method, Encoding::EUC_JP).should == "\xA4\xA2".force_encoding('EUC-JP')
+  end
+ 
+  it "can convert between encodings where a multi-stage conversion path is needed" do
+    str = "big?".force_encoding(Encoding::US_ASCII)
+    str.send(@method, Encoding::Big5, Encoding::US_ASCII).encoding.should == Encoding::Big5
+  end
+
+  it "raises an Encoding::InvalidByteSequenceError for invalid byte sequences" do
+    lambda do
+      "\xa4".force_encoding(Encoding::EUC_JP).send(@method, 'iso-8859-1')
+    end.should raise_error(Encoding::InvalidByteSequenceError)
+  end
+
+  it "raises UndefinedConversionError if the String contains characters invalid for the target     encoding" do
+    str = "\u{6543}"
+    lambda do
+      str.send(@method, Encoding.find('macCyrillic'))
+    end.should raise_error(Encoding::UndefinedConversionError)
+  end
+  
+  it "raises Encoding::ConverterNotFoundError for invalid target encodings" do
+    lambda do
+      "\u{9878}".send(@method, 'xyz')
+    end.should raise_error(Encoding::ConverterNotFoundError)
+  end
+
+  it "replaces invalid characters" do
+    str = "\xa4"
+    str.send(@method, "ISO-8859-1", "UTF-8", :invalid => :replace).should == "?"
+  end
+  
+  it "replaces undefined characters" do
+    "abc\u{fffd}def".send(@method, "EUC-JP", "UTF-8", {:undef => :replace, :replace => ""}).should == "abcdef"
+  end
+
+  it "replaces xml characters" do
+    '<xml>bed & breakfast</xml>'.send(@method, 'UTF-8', {:xml => :text}).should == "&lt;xml&gt;bed &amp; breakfast&lt;/xml&gt;"
+  end
+  
+  it "replaces xml characters and quotes the result" do
+    '<xml>bed & breakfast</xml>'.send(@method, 'UTF-8', {:xml => :attr}).should == "\"&lt;xml&gt;bed &amp; breakfast&lt;/xml&gt;\""
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/core/string/try_convert_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/try_convert_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/string/try_convert_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -15,7 +15,7 @@
       String.try_convert(obj).should equal(str)
     end
     
-    it "returns nil when there is no :to_ary" do
+    it "returns nil when there is no :to_str" do
       String.try_convert(-1).should be_nil
     end
     
@@ -33,4 +33,4 @@
       }.should raise_error(TypeError)
     end
   end
-end
\ No newline at end of file
+end

Modified: MacRuby/trunk/spec/frozen/core/string/upto_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/upto_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/string/upto_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -14,13 +14,23 @@
     a.should == ["abc"]
   end
 
-  # This is weird but MRI behaves like that
-  it "calls block with self even if self is less than stop but stop length is less than self length" do
-    a = []
-    "25".upto("5") { |s| a << s }
-    a.should == ["25"]
+  # This is weird (in 1.8), but MRI behaves like that
+  ruby_version_is '' ... '1.9' do
+    it "calls block with self even if self is less than stop but stop length is less than self length" do
+	   a = []
+	   "25".upto("5") { |s| a << s }
+	   a.should == ["25"]
+    end
   end
 
+  ruby_version_is '1.9' do
+    it "doesn't call block with self even if self is less than stop but stop length is less than self length" do
+      a = []
+      "25".upto("5") { |s| a << s }
+      a.should == []
+    end
+  end
+
   it "doesn't call block if stop is less than self and stop length is less than self length" do
     a = []
     "25".upto("1") { |s| a << s }

Modified: MacRuby/trunk/spec/frozen/core/struct/hash_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/struct/hash_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/struct/hash_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -24,6 +24,9 @@
       car[:make] = car
       similar_car[:make] = car
       car.hash.should == similar_car.hash
+      # This is because car.eql?(similar_car).
+      # Objects that are eql? must return the same hash.
+      # See the Struct#eql? specs
     end
   end
 

Added: MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.orig
===================================================================
--- MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.orig	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.orig	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,131 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+require File.dirname(__FILE__) + '/../../shared/kernel/raise'
+
+describe "Thread#raise" do
+  it "ignores dead threads" do
+    t = Thread.new { :dead }
+    Thread.pass while t.alive?
+    lambda {t.raise("Kill the thread")}.should_not raise_error
+    lambda {t.value}.should_not raise_error
+  end
+end
+
+describe "Thread#raise on a sleeping thread" do
+  before :each do
+    ScratchPad.clear
+    @thr = ThreadSpecs.sleeping_thread
+    Thread.pass while @thr.status and @thr.status != "sleep"
+  end
+
+  after :each do
+    @thr.kill
+  end
+
+  it "raises a RuntimeError if no exception class is given" do
+    @thr.raise
+    Thread.pass while @thr.status
+    ScratchPad.recorded.should be_kind_of(RuntimeError)
+  end
+
+  it "raises the given exception" do
+    @thr.raise Exception
+    Thread.pass while @thr.status
+    ScratchPad.recorded.class.should == Exception
+  end
+
+  it "raises the given exception with the given message" do
+    @thr.raise Exception, "get to work"
+    Thread.pass while @thr.status
+    ScratchPad.recorded.class.should == Exception
+    ScratchPad.recorded.message.should == "get to work"
+  end
+
+  it "can go unhandled" do
+    t = Thread.new do
+      sleep
+    end
+
+    t.raise
+    lambda {t.value}.should raise_error(RuntimeError)
+  end
+
+  ruby_version_is "" ... "1.9" do
+    it "re-raises active exception" do
+      t = Thread.new do
+        begin
+          1/0
+        rescue ZeroDivisionError
+          sleep 3
+        end
+      end
+  
+      Thread.pass while t.status and t.status != "sleep"
+      t.raise
+      lambda {t.value}.should raise_error(ZeroDivisionError)
+      t.kill
+    end
+  end
+end
+
+describe "Thread#raise on a running thread" do
+  before :each do
+    ScratchPad.clear
+    @thr = ThreadSpecs.running_thread
+    Thread.pass while @thr.status and @thr.status != "run"
+  end
+  
+  after :each do
+    @thr.kill
+  end
+
+  it "raises a RuntimeError if no exception class is given" do
+    @thr.raise
+    Thread.pass while @thr.status
+    ScratchPad.recorded.should be_kind_of(RuntimeError)
+  end
+
+  it "raises the given exception" do
+    @thr.raise Exception
+    Thread.pass while @thr.status
+    ScratchPad.recorded.class.should == Exception
+  end
+
+  it "raises the given exception with the given message" do
+    @thr.raise Exception, "get to work"
+    Thread.pass while @thr.status
+    ScratchPad.recorded.class.should == Exception
+    ScratchPad.recorded.message.should == "get to work"
+  end
+
+  it "can go unhandled" do
+    t = Thread.new do
+      loop {}
+    end
+
+    t.raise
+    lambda {t.value}.should raise_error(RuntimeError)
+  end
+
+  ruby_version_is "" ... "1.9" do
+    it "re-raises active exception" do
+      raised = false
+      t = Thread.new do
+        begin
+          1/0
+        rescue ZeroDivisionError
+          raised = true
+          loop { }
+        end
+      end
+  
+      Thread.pass until raised || !t.alive?
+      t.raise
+      lambda {t.value}.should raise_error(ZeroDivisionError)
+    end
+  end
+end
+
+describe "Thread#raise on same thread" do
+  it_behaves_like :kernel_raise, :raise, Thread.current
+end

Added: MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.rej
===================================================================
--- MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.rej	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/thread/raise_spec.rb.rej	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,92 @@
+***************
+*** 50,68 ****
+      lambda {t.value}.should raise_error(RuntimeError)
+    end
+  
+-   it "re-raises active exception" do
+-     t = Thread.new do
+        begin
+-         1/0
+-       rescue ZeroDivisionError
+-         sleep 3
+        end
+      end
+- 
+-     Thread.pass while t.status and t.status != "sleep"
+-     t.raise
+-     lambda {t.value}.should raise_error(ZeroDivisionError)
+-     t.kill
+    end
+  end
+  
+--- 50,73 ----
+      lambda {t.value}.should raise_error(RuntimeError)
+    end
+  
++   ruby_version_is "1.9" do
++     it "raises a RuntimeError when called with no arguments" do
++       t = Thread.new do
++         begin
++           1/0
++         rescue ZeroDivisionError
++           sleep 3
++         end
++       end
+        begin
++         raise RangeError
++       rescue
++         Thread.pass while t.status and t.status != "sleep"
++         t.raise
+        end
++       lambda {t.value}.should raise_error(RuntimeError)
++       t.kill
+      end
+    end
+  end
+  
+***************
+*** 105,111 ****
+      lambda {t.value}.should raise_error(RuntimeError)
+    end
+  
+-   it "re-raises active exception" do
+      raised = false
+      t = Thread.new do
+        begin
+--- 110,116 ----
+      lambda {t.value}.should raise_error(RuntimeError)
+    end
+  
++   it "raise the given argument even when there is an active exception" do
+      raised = false
+      t = Thread.new do
+        begin
+***************
+*** 115,125 ****
+          loop { }
+        end
+      end
+- 
+-     Thread.pass until raised || !t.alive?
+-     t.raise
+-     lambda {t.value}.should raise_error(ZeroDivisionError)
+    end
+  end
+  
+  describe "Thread#raise on same thread" do
+--- 120,134 ----
+          loop { }
+        end
+      end
++     begin
++       raise "Create an active exception for the current thread too"
++     rescue
++       Thread.pass until raised || !t.alive?
++       t.raise RangeError
++       lambda {t.value}.should raise_error(RangeError)
++     end
+    end
++ 
+  end
+  
+  describe "Thread#raise on same thread" do

Modified: MacRuby/trunk/spec/frozen/core/time/at_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/time/at_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/time/at_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,17 +2,19 @@
 require File.dirname(__FILE__) + '/fixtures/methods'
 
 describe "Time.at" do
-  ruby_version_is ""..."1.9" do
-    it "converts to time object" do
-      # the #chomp calls are necessary because of RSpec
-      Time.at(1184027924).inspect.chomp.should == localtime_18(1184027924).chomp
+  platform_is_not :windows do
+    ruby_version_is ""..."1.9" do
+      it "converts to time object" do
+        # the #chomp calls are necessary because of RSpec
+        Time.at(1184027924).inspect.chomp.should == localtime_18(1184027924).chomp
+      end
     end
-  end
-  
-  ruby_version_is "1.9" do
-    it "converts to time object" do
-      # the #chomp calls are necessary because of RSpec
-      Time.at(1184027924).inspect.chomp.should == localtime_19(1184027924).chomp
+
+    ruby_version_is "1.9" do
+      it "converts to time object" do
+        # the #chomp calls are necessary because of RSpec
+        Time.at(1184027924).inspect.chomp.should == localtime_19(1184027924).chomp
+      end
     end
   end
 

Modified: MacRuby/trunk/spec/frozen/core/time/shared/now.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/time/shared/now.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/core/time/shared/now.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,7 +1,9 @@
 describe :time_now, :shared => true do
-  it "creates a time based on the current system time" do
-    unless `which date` == ""
-      Time.__send__(@method).to_i.should.be_close(`date +%s`.to_i,1)
+  platform_is_not :windows do
+    it "creates a time based on the current system time" do
+      unless `which date` == ""
+        Time.__send__(@method).to_i.should.be_close(`date +%s`.to_i,1)
+      end
     end
   end
 end

Deleted: MacRuby/trunk/spec/frozen/fixtures/matrix.rb
===================================================================
--- MacRuby/trunk/spec/frozen/fixtures/matrix.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/fixtures/matrix.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +0,0 @@
-class TrivialField < Numeric
-  def eql?(rhs)
-    rhs.kind_of? TrivialField
-  end
-end

Modified: MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -306,3 +306,21 @@
     end
   end
 end
+
+describe "Instantiating an eigenclass" do
+  it "raises a TypeError when new is called" do
+    x = Object.new
+    x_eigenclass = class << x; self; end
+    lambda do
+      x_eigenclass.new
+    end.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError when allocate is called" do
+    x = Object.new
+    x_eigenclass = class << x; self; end
+    lambda do
+      x_eigenclass.allocate
+    end.should raise_error(TypeError)
+  end
+end

Modified: MacRuby/trunk/spec/frozen/language/fixtures/variables.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/fixtures/variables.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/fixtures/variables.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -42,4 +42,15 @@
   def self.reverse_foo(a, b)
     return b, a
   end
+
+  class ArrayLike
+    def initialize(array)
+      @array = array
+    end
+
+    def to_a
+      @array
+    end
+  end
+
 end

Modified: MacRuby/trunk/spec/frozen/language/hash_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/hash_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/hash_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -38,4 +38,10 @@
     h.keys.first.frozen?.should == true
     key.should == "oof"
   end
+
+  it "checks duplicated keys on initialization" do
+    h = {:foo => :bar, :foo => :foo}
+    h.keys.size.should == 1
+    h.should == {:foo => :foo}
+  end
 end

Modified: MacRuby/trunk/spec/frozen/language/precedence_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/precedence_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/precedence_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -428,19 +428,19 @@
   end
 
   it "= %= /= -= += |= &= >>= <<= *= &&= ||= **= have higher precedence than defined? operator" do
-    (defined? a =   10).should_not == nil
-    (defined? a %=  10).should_not == nil
-    (defined? a /=  10).should_not == nil
-    (defined? a -=  10).should_not == nil
-    (defined? a +=  10).should_not == nil
-    (defined? a |=  10).should_not == nil
-    (defined? a &=  10).should_not == nil
-    (defined? a >>= 10).should_not == nil
-    (defined? a <<= 10).should_not == nil
-    (defined? a *=  10).should_not == nil
-    (defined? a &&= 10).should_not == nil
-    (defined? a ||= 10).should_not == nil
-    (defined? a **= 10).should_not == nil
+    (defined? a =   10).should == "assignment"
+    (defined? a %=  10).should == "assignment"
+    (defined? a /=  10).should == "assignment"
+    (defined? a -=  10).should == "assignment"
+    (defined? a +=  10).should == "assignment"
+    (defined? a |=  10).should == "assignment"
+    (defined? a &=  10).should == "assignment"
+    (defined? a >>= 10).should == "assignment"
+    (defined? a <<= 10).should == "assignment"
+    (defined? a *=  10).should == "assignment"
+    (defined? a &&= 10).should == "assignment"
+    (defined? a ||= 10).should == "assignment"
+    (defined? a **= 10).should == "assignment"
   end
 
   # XXX: figure out how to test it

Modified: MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -13,17 +13,51 @@
         match.to_a.should == ["\303\251"]
       end
       
+      it 'supports /e (EUC encoding) with interpolation' do
+        match = /#{/./}/e.match("\303\251")
+        match.to_a.should == ["\303\251"]
+      end
+      
+      it 'supports /e (EUC encoding) with interpolation and /o' do
+        match = /#{/./}/e.match("\303\251")
+        match.to_a.should == ["\303\251"]
+      end
+      
       it 'supports /n (Normal encoding)' do
         /./n.match("\303\251").to_a.should == ["\303"]
       end
       
+      it 'supports /n (Normal encoding) with interpolation' do
+        /#{/./}/n.match("\303\251").to_a.should == ["\303"]
+      end
+      
+      it 'supports /n (Normal encoding) with interpolation and /o' do
+        /#{/./}/no.match("\303\251").to_a.should == ["\303"]
+      end
+      
       it 'supports /s (SJIS encoding)' do
         /./s.match("\303\251").to_a.should == ["\303"]
       end
       
+      it 'supports /s (SJIS encoding) with interpolation' do
+        /#{/./}/s.match("\303\251").to_a.should == ["\303"]
+      end
+      
+      it 'supports /s (SJIS encoding) with interpolation and /o' do
+        /#{/./}/so.match("\303\251").to_a.should == ["\303"]
+      end
+      
       it 'supports /u (UTF8 encoding)' do
         /./u.match("\303\251").to_a.should == ["\303\251"]
       end
+
+      it 'supports /u (UTF8 encoding) with interpolation' do
+        /#{/./}/u.match("\303\251").to_a.should == ["\303\251"]
+      end
+
+      it 'supports /u (UTF8 encoding) with interpolation and /o' do
+        /#{/./}/uo.match("\303\251").to_a.should == ["\303\251"]
+      end
       
       it 'selects last of multiple encoding specifiers' do
         /foo/ensuensuens.should == /foo/s
@@ -37,19 +71,55 @@
       match.to_a.should == ["\303\251".force_encoding(Encoding::EUC_JP)]
     end
     
+    it 'supports /e (EUC encoding) with interpolation' do
+      match = /#{/./}/e.match("\303\251".force_encoding(Encoding::EUC_JP))
+      match.to_a.should == ["\303\251".force_encoding(Encoding::EUC_JP)]
+    end
+    
+    it 'supports /e (EUC encoding) with interpolation /o' do
+      match = /#{/./}/e.match("\303\251".force_encoding(Encoding::EUC_JP))
+      match.to_a.should == ["\303\251".force_encoding(Encoding::EUC_JP)]
+    end
+    
     it 'supports /n (No encoding)' do
       /./n.match("\303\251").to_a.should == ["\303"]
     end
     
+    it 'supports /n (No encoding) with interpolation' do
+      /#{/./}/n.match("\303\251").to_a.should == ["\303"]
+    end
+    
+    it 'supports /n (No encoding) with interpolation /o' do
+      /#{/./}/n.match("\303\251").to_a.should == ["\303"]
+    end
+    
     it 'supports /s (Windows_31J encoding)' do
       match = /./s.match("\303\251".force_encoding(Encoding::Windows_31J))
       match.to_a.should == ["\303".force_encoding(Encoding::Windows_31J)]
     end
     
+    it 'supports /s (Windows_31J encoding) with interpolation' do
+      match = /#{/./}/s.match("\303\251".force_encoding(Encoding::Windows_31J))
+      match.to_a.should == ["\303".force_encoding(Encoding::Windows_31J)]
+    end
+    
+    it 'supports /s (Windows_31J encoding) with interpolation and /o' do
+      match = /#{/./}/s.match("\303\251".force_encoding(Encoding::Windows_31J))
+      match.to_a.should == ["\303".force_encoding(Encoding::Windows_31J)]
+    end
+    
     it 'supports /u (UTF8 encoding)' do
       /./u.match("\303\251".force_encoding('utf-8')).to_a.should == ["\u{e9}"]
     end
     
+    it 'supports /u (UTF8 encoding) with interpolation' do
+      /#{/./}/u.match("\303\251".force_encoding('utf-8')).to_a.should == ["\u{e9}"]
+    end
+    
+    it 'supports /u (UTF8 encoding) with interpolation and /o' do
+      /#{/./}/u.match("\303\251".force_encoding('utf-8')).to_a.should == ["\u{e9}"]
+    end
+    
     # Fails on 1.9; reported as bug #2052
     it 'selects last of multiple encoding specifiers' do
       /foo/ensuensuens.should == /foo/s

Modified: MacRuby/trunk/spec/frozen/language/return_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/return_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/return_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -201,6 +201,17 @@
       f().should == :outer_ensure
       ScratchPad.recorded.should == [:inner_begin, :inner_ensure, :outer_ensure]
     end
+
+    it "executes the ensure clause when begin/ensure are inside a lambda" do
+      lambda do
+        begin
+          return
+        ensure
+          ScratchPad.recorded << :ensure
+        end
+      end.call
+      ScratchPad.recorded.should == [:ensure]
+    end
   end
 
   describe "within a block" do
@@ -241,6 +252,7 @@
       ReturnSpecs::NestedBlocks.new.enclosing_method.should == :return_value
       ScratchPad.recorded.should == :before_return
     end
+
   end
 
   describe "within two blocks" do

Modified: MacRuby/trunk/spec/frozen/language/string_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/string_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/string_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -70,7 +70,7 @@
     %/hey #{@ip}/.should == "hey xxx"
     %,hey #{@ip},.should == "hey xxx"
     %.hey #{@ip}..should == "hey xxx"
-    
+
     # surprised? huh
     %'hey #{@ip}'.should == "hey xxx"
     %\hey #{@ip}\.should == "hey xxx"
@@ -92,7 +92,7 @@
   # (backspace), \a (bell), \e (escape), \s (whitespace), \nnn (octal),
   # \xnn (hexadecimal), \cx (control x), \C-x (control x), \M-x (meta x),
   # \M-\C-x (meta control x)
-  
+
   it "backslashes follow the same rules as interpolation" do
     "\t\n\r\f\b\a\e\s\075\x62\cx".should == "\t\n\r\f\b\a\e =b\030"
     '\t\n\r\f\b\a\e =b\030'.should == "\\t\\n\\r\\f\\b\\a\\e =b\\030"
@@ -104,7 +104,7 @@
 HERE
     s.should == "foo barxxx\n"
   end
-  
+
   it 'allow HEREDOC with <<"identifier", interpolated' do
     s = <<"HERE"
 foo bar#{@ip}
@@ -118,7 +118,7 @@
 HERE
     s.should == 'foo bar#{@ip}' + "\n"
   end
-  
+
   it "allow HEREDOC with <<-identifier, allowing to indent identifier, interpolated" do
     s = <<-HERE
     foo bar#{@ip}
@@ -126,7 +126,7 @@
 
     s.should == "    foo barxxx\n"
   end
-  
+
   it 'allow HEREDOC with <<-"identifier", allowing to indent identifier, interpolated' do
     s = <<-"HERE"
     foo bar#{@ip}
@@ -134,7 +134,7 @@
 
     s.should == "    foo barxxx\n"
   end
-  
+
   it "allow HEREDOC with <<-'identifier', allowing to indent identifier, no interpolation" do
     s = <<-'HERE'
     foo bar#{@ip}
@@ -143,7 +143,21 @@
     s.should == '    foo bar#{@ip}' + "\n"
   end
 
+  it "interpolates the return value of Object#to_s" do
+    obj = mock('to_s')
+    obj.stub!(:to_s).and_return('42')
 
+    "#{obj}".should == '42'
+  end
+
+  it "interpolates the return value of Object#inspect, without ivars, if Object#to_s does not return a String instance" do
+    obj = mock('to_s')
+    obj.stub!(:to_s).and_return(42)
+    s = "#{obj}"[0..-2]
+
+    s.should == obj.inspect[0, s.size]
+  end
+
   ruby_version_is '1.9' do
     it "are produced from character shortcuts" do
       ?z.should == 'z'

Modified: MacRuby/trunk/spec/frozen/language/variables_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/variables_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/language/variables_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -152,6 +152,10 @@
     a,b,*c = *[*[1,2]]; [a,b,c].should == [1, 2, []]
   end
 
+  it "calls to_a on the given argument when using a splat" do
+    a,b = *VariablesSpecs::ArrayLike.new([1,2]); [a,b].should == [1,2]
+  end
+
   it "supports the {|r,| } form of block assignment" do
     f = lambda {|r,| r.should == []}
     f.call([], *[])

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/gt_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/gt_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/gt_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -24,7 +24,7 @@
 
     @values = [@mixed, @pos_int, @neg_int, @pos_frac, @neg_frac,
       -2**32, -2**31, -2**30, -2**16, -2**8, -100, -10, -1,
-      @zero , 1, 2, 10, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
+      @zero , 1, 2, 10, 10.5, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
 
     @infinity = BigDecimal("Infinity")
     @infinity_neg = BigDecimal("-Infinity")
@@ -64,28 +64,24 @@
     (@infinity_neg > @infinity).should == false
   end
 
-  it "properly handles NaN values" do
-    @values += [@infinity, @infinity_neg, @nan]
-    @values << nil
-    @values << Object.new
-    @values.each { |val|
-      (@nan > val).should == nil
-    }
-
-    lambda { 10 > @nan }.should raise_error(ArgumentError)
-    (10.5 > @nan).should == false
-
-    (@infinity > @nan).should == nil
-    (@infinity_neg > @nan).should == nil
-    (@zero > @nan).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "properly handles NaN values" do
+      @values += [@infinity, @infinity_neg, @nan]
+      @values.each { |val|
+        (@nan > val).should == false
+        (val > @nan).should == false
+      }
+    end
   end
 
-  it "returns nil if the argument is nil" do
-    (@zero > nil).should == nil
-    (@infinity > nil).should == nil
-    (@infinity_neg > nil).should == nil
-    (@mixed > nil).should == nil
-    (@pos_int > nil).should == nil
-    (@neg_frac > nil).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
+      lambda {@zero         > nil }.should raise_error(ArgumentError)
+      lambda {@infinity     > nil }.should raise_error(ArgumentError)
+      lambda {@infinity_neg > nil }.should raise_error(ArgumentError)
+      lambda {@mixed        > nil }.should raise_error(ArgumentError)
+      lambda {@pos_int      > nil }.should raise_error(ArgumentError)
+      lambda {@neg_frac     > nil }.should raise_error(ArgumentError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/gte_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/gte_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/gte_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -24,7 +24,7 @@
 
     @values = [@mixed, @pos_int, @neg_int, @pos_frac, @neg_frac,
       -2**32, -2**31, -2**30, -2**16, -2**8, -100, -10, -1,
-      @zero , 1, 2, 10, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
+      @zero , 1, 2, 10, 10.5, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
 
     @infinity = BigDecimal("Infinity")
     @infinity_neg = BigDecimal("-Infinity")
@@ -68,28 +68,24 @@
     (@infinity_neg >= @infinity).should == false
   end
 
-  it "properly handles NaN values" do
-    @values += [@infinity, @infinity_neg, @nan]
-    @values << nil
-    @values << Object.new
-    @values.each { |val|
-      (@nan >= val).should == nil
-    }
-
-    lambda { 10 >= @nan }.should raise_error(ArgumentError)
-    (10.5 >= @nan).should == false
-
-    (@infinity >= @nan).should == nil
-    (@infinity_neg >= @nan).should == nil
-    (@zero >= @nan).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "properly handles NaN values" do
+      @values += [@infinity, @infinity_neg, @nan]
+      @values.each { |val|
+        (@nan >= val).should == false
+        (val >= @nan).should == false
+      }
+    end
   end
 
-  it "returns nil if the argument is nil" do
-    (@zero >= nil).should == nil
-    (@infinity >= nil).should == nil
-    (@infinity_neg >= nil).should == nil
-    (@mixed >= nil).should == nil
-    (@pos_int >= nil).should == nil
-    (@neg_frac >= nil).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "returns nil if the argument is nil" do
+      lambda {@zero         >= nil }.should raise_error(ArgumentError)
+      lambda {@infinity     >= nil }.should raise_error(ArgumentError)
+      lambda {@infinity_neg >= nil }.should raise_error(ArgumentError)
+      lambda {@mixed        >= nil }.should raise_error(ArgumentError)
+      lambda {@pos_int      >= nil }.should raise_error(ArgumentError)
+      lambda {@neg_frac     >= nil }.should raise_error(ArgumentError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/infinite_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/infinite_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/infinite_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -4,17 +4,14 @@
 describe "BigDecimal#infinite?" do
 
   it "returns 1 if self is Infinity" do
-    # documentation says returns true.
     BigDecimal("Infinity").infinite?.should == 1
   end
   
   it "returns -1 if self is -Infinity" do
-    # This is how MRI behaves.
     BigDecimal("-Infinity").infinite?.should == -1
   end
 
   it "returns not true otherwise" do
-    # If nil or false is not really specified in documentation.
     e2_plus = BigDecimal("2E40001")
     e3_minus = BigDecimal("3E-20001")
     really_small_zero = BigDecimal("0E-200000000")

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/lt_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/lt_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/lt_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -24,7 +24,7 @@
 
     @values = [@mixed, @pos_int, @neg_int, @pos_frac, @neg_frac,
       -2**32, -2**31, -2**30, -2**16, -2**8, -100, -10, -1,
-      @zero , 1, 2, 10, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
+      @zero , 1, 2, 10, 10.5, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
 
     @infinity = BigDecimal("Infinity")
     @infinity_neg = BigDecimal("-Infinity")
@@ -62,28 +62,24 @@
     (@infinity_neg < @infinity).should == true
   end
 
-  it "properly handles NaN values" do
-    @values += [@infinity, @infinity_neg, @nan]
-    @values << nil
-    @values << Object.new
-    @values.each { |val|
-      (@nan < val).should == nil
-    }
-
-    lambda { 10 < @nan }.should raise_error(ArgumentError)
-    (10.5 < @nan).should == false
-
-    (@infinity < @nan).should == nil
-    (@infinity_neg < @nan).should == nil
-    (@zero < @nan).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "properly handles NaN values" do
+      @values += [@infinity, @infinity_neg, @nan]
+      @values.each { |val|
+        (@nan < val).should == false
+        (val < @nan).should == false
+      }
+    end
   end
 
-  it "returns nil if the argument is nil" do
-    (@zero < nil).should == nil
-    (@infinity < nil).should == nil
-    (@infinity_neg < nil).should == nil
-    (@mixed < nil).should == nil
-    (@pos_int < nil).should == nil
-    (@neg_frac < nil).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
+      lambda {@zero         < nil }.should raise_error(ArgumentError)
+      lambda {@infinity     < nil }.should raise_error(ArgumentError)
+      lambda {@infinity_neg < nil }.should raise_error(ArgumentError)
+      lambda {@mixed        < nil }.should raise_error(ArgumentError)
+      lambda {@pos_int      < nil }.should raise_error(ArgumentError)
+      lambda {@neg_frac     < nil }.should raise_error(ArgumentError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/lte_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/lte_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/lte_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -24,7 +24,7 @@
 
     @values = [@mixed, @pos_int, @neg_int, @pos_frac, @neg_frac,
       -2**32, -2**31, -2**30, -2**16, -2**8, -100, -10, -1,
-      @zero , 1, 2, 10, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
+      @zero , 1, 2, 10, 10.5, 2**8, 2**16, 2**32, @int_mock, @zero_pos, @zero_neg]
 
     @infinity = BigDecimal("Infinity")
     @infinity_neg = BigDecimal("-Infinity")
@@ -68,28 +68,24 @@
     (@infinity_neg <= @infinity).should == true
   end
 
-  it "properly handles NaN values" do
-    @values += [@infinity, @infinity_neg, @nan]
-    @values << nil
-    @values << Object.new
-    @values.each { |val|
-      (@nan <= val).should == nil
-    }
-
-    lambda { 10 <= @nan }.should raise_error(ArgumentError)
-    (10.5 <= @nan).should == false
-
-    (@infinity <= @nan).should == nil
-    (@infinity_neg <= @nan).should == nil
-    (@zero <= @nan).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "properly handles NaN values" do
+      @values += [@infinity, @infinity_neg, @nan]
+      @values.each { |val|
+        (@nan <= val).should == false
+        (val <= @nan).should == false
+      }
+    end
   end
 
-  it "returns nil if the argument is nil" do
-    (@zero <= nil).should == nil
-    (@infinity <= nil).should == nil
-    (@infinity_neg <= nil).should == nil
-    (@mixed <= nil).should == nil
-    (@pos_int <= nil).should == nil
-    (@neg_frac <= nil).should == nil
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
+      lambda {@zero         <= nil }.should raise_error(ArgumentError)
+      lambda {@infinity     <= nil }.should raise_error(ArgumentError)
+      lambda {@infinity_neg <= nil }.should raise_error(ArgumentError)
+      lambda {@mixed        <= nil }.should raise_error(ArgumentError)
+      lambda {@pos_int      <= nil }.should raise_error(ArgumentError)
+      lambda {@neg_frac     <= nil }.should raise_error(ArgumentError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/shared/eql.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/shared/eql.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/shared/eql.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -12,7 +12,7 @@
     @infinity_minus = BigDecimal("-Infinity")
   end
 
-  it "test for equality" do
+  it "tests for equality" do
     @bg6543_21.send(@method, @bg6543_21).should == true
     @a.send(@method, @a).should == true
     @a.send(@method, @b).should == false
@@ -20,14 +20,16 @@
     @bigint.send(@method, 1000).should == true
   end
 
-  it "NaN is never equal to any number" do
-    @nan.send(@method, @nan).should_not == true
-    @a.send(@method, @nan).should_not == true
-    @nan.send(@method, @a).should_not == true
-    @nan.send(@method, @infinity).should_not == true
-    @nan.send(@method, @infinity_minus).should_not == true
-    @infinity.send(@method, @nan).should_not == true
-    @infinity_minus.send(@method, @nan).should_not == true
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "NaN is never equal to any number" do
+      @nan.send(@method, @nan).should == false
+      @a.send(@method, @nan).should == false
+      @nan.send(@method, @a).should == false
+      @nan.send(@method, @infinity).should == false
+      @nan.send(@method, @infinity_minus).should == false
+      @infinity.send(@method, @nan).should == false
+      @infinity_minus.send(@method, @nan).should == false
+    end
   end
 
   it "returns true for infinity values with the same sign" do
@@ -40,16 +42,24 @@
     BigDecimal("-Infinity").send(@method, @infinity_minus).should == true
   end
 
-  it "does not return true for infinity values with different signs" do
-    @infinity.send(@method, @infinity_minus).should_not == true
-    @infinity_minus.send(@method, @infinity).should_not == true
+  it "returns false for infinity values with different signs" do
+    @infinity.send(@method, @infinity_minus).should == false
+    @infinity_minus.send(@method, @infinity).should == false
   end
 
-  it "does not return true when ininite value compared to finite one" do
-    @infinity.send(@method, @a).should_not == true
-    @infinity_minus.send(@method, @a).should_not == true
+  it "returns false when infinite value compared to finite one" do
+    @infinity.send(@method, @a).should == false
+    @infinity_minus.send(@method, @a).should == false
 
-    @a.send(@method, @infinity).should_not == true
-    @a.send(@method, @infinity_minus).should_not == true
+    @a.send(@method, @infinity).should == false
+    @a.send(@method, @infinity_minus).should == false
   end
+
+  ruby_bug "redmine:2349", "1.8.7" do
+    it "returns false when compared objects that can not be coerced into BigDecimal" do
+      @infinity.send(@method, nil).should == false
+      @bigint.send(@method, nil).should == false
+      @nan.send(@method, nil).should == false
+    end
+  end
 end

Deleted: MacRuby/trunk/spec/frozen/library/date/neww_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/date/neww_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/date/neww_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,13 +0,0 @@
-require 'date' 
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/shared/commercial'
-
-ruby_version_is "" ... "1.9" do
-
-  describe "Date#neww" do
-  
-    it_behaves_like(:date_commercial, :neww)
-  
-  end
-
-end

Added: MacRuby/trunk/spec/frozen/library/delegate/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/delegate/fixtures/classes.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/delegate/fixtures/classes.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,24 @@
+module DelegateSpecs
+  class Simple
+    def pub
+      :foo
+    end
+    
+    def respond_to_missing?(method, priv=false)
+      method == :pub_too ||
+        (priv && method == :priv_too)
+    end
+    
+    def method_missing(method, *args)
+      super unless respond_to_missing?(method, true)
+      method
+    end
+
+    def priv(arg=nil)
+      yield arg if block_given?
+      [:priv, arg]
+    end
+    private :priv
+    
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/delegate/frozen_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/delegate/frozen_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/delegate/frozen_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,49 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'delegate'
+
+describe "SimpleDelegator when frozen" do
+  before :each do
+    @array = [42, :hello]
+    @delegate = SimpleDelegator.new(@array)
+    @delegate.freeze
+  end
+
+  it "is still readable" do
+    @delegate.should == [42, :hello]
+    @delegate.include?("bar").should be_false
+  end
+
+  it "is frozen" do
+    @delegate.frozen?.should be_true
+  end
+
+  ruby_bug "redmine:2221", "1.8.7" do
+    it "is not writeable" do
+      lambda{ @delegate[0] += 2 }.should raise_error( RuntimeError )
+    end
+
+    it "creates a frozen clone" do
+      @delegate.clone.frozen?.should be_true
+    end
+  end
+
+  it "creates an unfrozen dup" do
+    @delegate.dup.frozen?.should be_false
+  end
+
+  ruby_version_is "" ... "1.9" do
+    it "causes mutative calls to raise TypeError" do
+      lambda{ @delegate.__setobj__("hola!") }.should raise_error( TypeError )
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "causes mutative calls to raise RuntimeError" do
+      lambda{ @delegate.__setobj__("hola!") }.should raise_error( RuntimeError )
+    end
+  end
+
+  it "returns false if only the delegated object is frozen" do
+    SimpleDelegator.new([1,2,3].freeze).frozen?.should be_false
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/delegate/method_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/delegate/method_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/delegate/method_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,38 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + "/fixtures/classes"
+require 'delegate'
+
+describe "SimpleDelegator#method" do
+  before :each do
+    @simple = DelegateSpecs::Simple.new
+    @delegate = SimpleDelegator.new(@simple)
+  end
+
+  it "returns a method object for a valid method" do
+    m = @delegate.method(:pub)
+    m.should be_an_instance_of(Method)
+    m.call.should == :foo
+  end
+
+  it "raises a NameError for an invalid method name" do
+    lambda {
+      @delegate.method(:invalid_and_silly_method_name)
+    }.should raise_error(NameError)
+  end
+
+  ruby_version_is "1.9" do
+    it "returns a method that respond_to_missing?" do
+      m = @delegate.method(:pub_too)
+      m.should be_an_instance_of(Method)
+      m.call.should == :pub_too
+    end
+  end
+
+  it "raises a NameError if method is no longer valid because object has changed" do
+    m = @delegate.method(:pub)
+    @delegate.__setobj__([1,2,3])
+    lambda {
+      m.call
+    }.should raise_error(NameError)
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/delegate/send_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/delegate/send_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/delegate/send_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + "/fixtures/classes"
+require 'delegate'
+
+describe "SimpleDelegator.new" do
+  before :each do
+    @simple = DelegateSpecs::Simple.new
+    @delegate = SimpleDelegator.new(@simple)
+  end
+
+  it "forwards public method calls" do
+    @delegate.pub.should == :foo
+  end
+
+  it "doesn't forward private method calls" do
+    lambda{ @delegate.priv }.should raise_error( NoMethodError )
+  end
+
+  ruby_bug "redmine:2206", "1.8.7" do
+    it "forwards private method calls made via send or __send__" do
+      @delegate.send(:priv, 42).should == [:priv, 42]
+      @delegate.__send__(:priv, 42).should == [:priv, 42]
+      lambda{ @delegate.__send__(:priv, 42){@delegate.priv} }.should raise_error( NoMethodError )
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/getoptlong/error_message_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/getoptlong/error_message_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/getoptlong/error_message_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -19,14 +19,14 @@
 
   it "returns the error message of the last error that occurred" do
     begin
-      $stderr = IOStub.new
       ARGV = []
 
       opts = GetoptLong.new
+      opts.quiet = true
       opts.get
       opts.ordering = GetoptLong::PERMUTE
     rescue ArgumentError
       opts.error_message.should == "argument error"
     end
   end
-end
\ No newline at end of file
+end

Modified: MacRuby/trunk/spec/frozen/library/getoptlong/ordering_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/getoptlong/ordering_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/getoptlong/ordering_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -4,13 +4,12 @@
 describe "GetoptLong#ordering=" do
   it "raises an ArgumentError if called after processing has started" do
     begin
-      s = $stderr
-      $stderr = IOStub.new
       old_argv = ARGV
       ARGV = [ "--size", "10k", "--verbose" ]
       
       opts = GetoptLong.new([ '--size', GetoptLong::REQUIRED_ARGUMENT ],
         [ '--verbose', GetoptLong::NO_ARGUMENT ])
+      opts.quiet = true
       opts.get
       
       lambda {
@@ -18,7 +17,6 @@
       }.should raise_error(ArgumentError)
     ensure
       ARGV = old_argv
-      $stderr = s
     end
   end
 
@@ -42,4 +40,4 @@
       ENV['POSIXLY_CORRECT'] = old_env_value
     end
   end
-end
\ No newline at end of file
+end

Modified: MacRuby/trunk/spec/frozen/library/getoptlong/shared/get.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/getoptlong/shared/get.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/getoptlong/shared/get.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -6,6 +6,7 @@
       [ '--query', '-q',            GetoptLong::NO_ARGUMENT ],
       [ '--check', '--valid', '-c', GetoptLong::NO_ARGUMENT ]
     )
+    @opts.quiet = true # silence using $deferr
   end
 
   it "returns the next option name and its argument as an Array" do
@@ -63,15 +64,12 @@
 
   it "raises a if an argument was required, but none given" do
     begin
-      s = $stderr
-      $stderr = IOStub.new
       old_argv = ARGV
       ARGV = [ "--size" ]
 
       lambda { @opts.send(@method) }.should raise_error(GetoptLong::MissingArgument)
     ensure
       ARGV = old_argv
-      $stderr = s
     end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/mathn/integer/prime_division_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/mathn/integer/prime_division_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/mathn/integer/prime_division_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,11 +2,18 @@
 require 'mathn'
 
 describe "Integer#prime_division" do
-  it "Performs a prime factorization of an integer" do
+  it "Performs a prime factorization of a positive integer" do
     100.prime_division.should == [[2, 2], [5, 2]]
-    -26.prime_division.should == [[2, 1]]
   end
 
+  # Proper handling of negative integers has been added to MRI trunk
+  # in revision 24091. Prior to that, all versions of MRI returned nonsense.
+  ruby_bug "trunk at 24091", "1.9.1" do
+    it "Performs a prime factorization of a negative integer" do
+      -26.prime_division.should == [[-1, 1], [2, 1], [13, 1]]
+    end
+  end
+
   it "raises a ZeroDivisionError when is called on zero" do
     lambda { 0.prime_division }.should raise_error(ZeroDivisionError)
   end

Modified: MacRuby/trunk/spec/frozen/library/matrix/clone_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/clone_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/clone_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -20,19 +20,4 @@
     @a = Matrix[[1, 2], [3, 4], [5, 6]]
   end
   
-quarantine! do # The test fails on MRI 1.8.6 pl 111, pl 114, MRI 1.8.7, JRuby
-  it "returns a copy of the matrix, but with all the references different" do
-    b = @a.clone
-    b.class.should == Matrix
-    b.should == @a
-    b.should_not === @a
-    0.upto(@a.row_size - 1) do |i|
-      0.upto(@a.column_size - 1) do |j|
-        b[i, j].should == @a[i, j]
-        b[i, j].should_not === @a[i, j]
-      end
-    end
-  end
 end
-
-end

Modified: MacRuby/trunk/spec/frozen/library/matrix/column_size_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/column_size_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/column_size_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,15 +2,14 @@
 require 'matrix'
 
 describe "Matrix#column_size" do
-  it "returns the number of elements in the first column" do
-    Matrix[ [1,2] ].column_size.should == 2
-    Matrix[ [1,2,3],[1,2] ].column_size.should == 3
+  it "returns the number of columns" do
+    Matrix[ [1,2], [3,4] ].column_size.should == 2
   end
 
-  it "raises an exception on an empty Matrix" do
-    # Note that MRI raises NoMethodError because #size is called
-    # on nil. This appears to be more of an "oops" rather than
-    # an aspect of the interface. We don't spec the exception class.
-    lambda{ Matrix[].column_size }.should raise_error
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns 0 for empty matrices" do
+      Matrix[ [], [] ].column_size.should == 0
+      Matrix[ ].column_size.should == 0
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/column_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/column_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/column_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,16 +3,35 @@
 
 describe "Matrix#column" do
   before :all do
-    @data =  [[1,2],[1,2]]
+    @m =  Matrix[[1,2,3], [2,3,4]]
   end
 
   it "returns a Vector when called without a block" do
-    Matrix[ *@data ].column(1).should == Vector[2,2]
+    @m.column(1).should == Vector[2,3]
   end
 
   it "yields each element in the column to the block" do
-    Matrix[ *@data ].column(1) do |n|
-      n.should == 2
+    a = []
+    @m.column(1) {|n| a << n }
+    a.should == [2,3]
+  end
+  
+  it "counts backwards for negative argument" do
+    @m.column(-1).should == Vector[3, 4]
+  end
+
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns self when called with a block" do
+      @m.column(0) { |x| x }.should equal(@m)
     end
+
+    it "returns nil when out of bounds" do
+      @m.column(3).should == nil
+    end
+
+    it "never yields when out of bounds" do
+      lambda { @m.column(3){ raise } }.should_not raise_error
+      lambda { @m.column(-4){ raise } }.should_not raise_error
+    end
   end
-end
\ No newline at end of file
+end

Modified: MacRuby/trunk/spec/frozen/library/matrix/column_vector_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/column_vector_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/column_vector_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -9,22 +9,12 @@
     m.should == Matrix[ [4],[5],[6] ]
   end
 
-  it "returns an empty Matrix when called with an empty Array" do
-    m = Matrix.column_vector([])
-    m.should be_an_instance_of(Matrix)
-    m.should == Matrix[]
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns an empty Matrix when called with an empty Array" do
+      m = Matrix.column_vector([])
+      m.should be_an_instance_of(Matrix)
+      m.row_size.should == 0
+      m.column_size.should == 1
+    end
   end
-
-  it "returns a single column Matrix when called with a Fixnum" do
-    m = Matrix.column_vector(4)
-    m.should be_an_instance_of(Matrix)
-    m.should == Matrix[ [4] ]
-  end
-  
-  it "returns a single column Matrix when called with a Float" do  
-    m = Matrix.column_vector(0.98887)
-    m.should be_an_instance_of(Matrix)
-    m.should == Matrix[ [0.98887] ]
-  end
-
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/columns_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/columns_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/columns_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -14,10 +14,24 @@
     @m.column(1).to_a.should == @b
   end
 
-  it "raises an exception on an empty Matrix" do
-    # Note that MRI raises NoMethodError because #size is called
-    # on nil. This appears to be more of an "oops" rather than
-    # an aspect of the interface. We don't spec the exception class.
-    lambda{ Matrix.columns([]) }.should raise_error
+  it "accepts Vectors as argument columns" do
+    m = Matrix.columns([Vector[*@a], Vector[*@b]])
+    m.should == @m
+    m.column(0).to_a.should == @a
+    m.column(1).to_a.should == @b
   end
-end
+
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "handles empty matrices" do
+      e = Matrix.columns([])
+      e.row_size.should == 0
+      e.column_size.should == 0
+      e.should == Matrix[]
+    
+      v = Matrix.columns([[],[],[]])
+      v.row_size.should == 0
+      v.column_size.should == 3
+      v.should == Matrix[[], [], []].transpose
+    end
+  end
+end
\ No newline at end of file

Deleted: MacRuby/trunk/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/compare_by_row_vectors_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,19 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'matrix'
-
-describe "Matrix#compare_by_row_vectors" do
-
-  before(:all) do
-    @elements = [ [1,2], [3,4] ]
-    @m = Matrix[ *@elements ]
-   end
-
-  it "returns true if the two matrices contain equal elements" do
-    @m.compare_by_row_vectors(@elements).should be_true
-  end
-
-  it "returns false if the two matrices don't contain equal elements" do
-    @m.compare_by_row_vectors(@elements.reverse).should be_false
-  end
-
-end

Added: MacRuby/trunk/spec/frozen/library/matrix/constructor_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/constructor_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/constructor_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,61 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require 'matrix'
+
+describe "Matrix.[]" do
+
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "requires arrays as parameters" do
+      lambda { Matrix[5] }.should raise_error(TypeError)
+      lambda { Matrix[nil] }.should raise_error(TypeError)
+      lambda { Matrix[1..2] }.should raise_error(TypeError)
+      lambda { Matrix[[1, 2], 3] }.should raise_error(TypeError)
+    end
+
+    it "creates an empty Matrix with no arguments" do
+      m = Matrix[]
+      m.column_size.should == 0
+      m.row_size.should == 0
+    end
+
+    it "raises for non-rectangular matrices" do
+      lambda{ Matrix[ [0], [0,1] ] }.should \
+        raise_error(Matrix::ErrDimensionMismatch)
+      lambda{ Matrix[ [0,1], [0,1,2], [0,1] ]}.should \
+        raise_error(Matrix::ErrDimensionMismatch)
+    end
+
+    it "accepts vector arguments" do
+      a = Matrix[Vector[1, 2], Vector[3, 4]]
+      a.should be_an_instance_of(Matrix)
+      a.should == Matrix[ [1, 2], [3, 4] ]
+    end
+
+    it "tries to calls :to_ary on arguments" do
+      array = mock('ary')
+      array.should_receive(:to_ary).and_return([1,2])
+      Matrix[array, [3,4] ].should == Matrix[ [1,2], [3,4] ]
+    end
+
+  end
+
+  it "returns a Matrix object" do
+    Matrix[ [1] ].should be_an_instance_of(Matrix)
+  end
+
+  it "can create an nxn Matrix" do
+    m = Matrix[ [20,30], [40.5, 9] ]
+    m.row_size.should == 2
+    m.column_size.should == 2
+    m.column(0).should == Vector[20, 40.5]
+    m.column(1).should == Vector[30, 9]
+    m.row(0).should == Vector[20, 30]
+    m.row(1).should == Vector[40.5, 9]
+  end
+
+  it "can create a 0xn Matrix" do
+    m = Matrix[ [], [], [] ]
+    m.row_size.should == 3
+    m.column_size.should == 0
+  end
+
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/library/matrix/diagonal_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/diagonal_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/diagonal_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -9,6 +9,11 @@
   it "returns an object of type Matrix" do
     @m.class.should == Matrix
   end
+
+  it "returns a square Matrix of the right size" do
+    @m.column_size.should == 5
+    @m.row_size.should == 5
+  end
   
   it "sets the diagonal to the arguments" do
     (0..4).each do |i|

Modified: MacRuby/trunk/spec/frozen/library/matrix/divide_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/divide_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/divide_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/spec_helper'
 require 'matrix'
 
 describe "Matrix#/" do
@@ -8,10 +9,9 @@
     @c = Matrix[ [1.2, 2.4], [3.6, 4.8] ]
   end
 
-  conflicts_with :Prime do
+  ruby_bug "?", "1.9" do
     it "returns the result of dividing self by another Matrix" do
-      (@a / @b).should == Matrix[ [-2, 0], [-4, 0] ]
-      ((@a / @b) / @b).should == Matrix[ [0,0], [0,0] ]
+      (@a / @b).should be_close_to_matrix([[2.5, -1.5], [1.5, -0.5]])
     end
   end
 

Modified: MacRuby/trunk/spec/frozen/library/matrix/element_reference_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/element_reference_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/element_reference_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,27 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require 'matrix'
 
-describe "Matrix.[]" do
-  # Matrix.[] is really a constructor, not an element reference function...
-
-  before(:each) do
-    @a = [1, 2, 3]
-    @b = [4, 5, 6]
-    @c = [7, 8, 9]
-    @m = Matrix[@a, @b, @c]
-  end
-  
-  it "returns an object of type Matrix" do
-    @m.class.should == Matrix
-  end
-  
-  it "makes each argument into a row" do
-    @m.row(0).to_a.should == @a
-    @m.row(1).to_a.should == @b
-    @m.row(2).to_a.should == @c
-  end
-end
-
 describe "Matrix#[]" do
 
   before(:all) do
@@ -36,14 +15,11 @@
     end
   end
 
-  # FIXME: Update this guard when the bug is fixed.
-  ruby_bug "#1518", "1.9.1.129" do
-    # A NoMethodError is raised when the _first_ index is out of bounds,
-    # (http://redmine.ruby-lang.org/issues/show/1518); otherwise nil is
-    # returned.
+  ruby_bug "#1518", "1.8.7" do
     it "returns nil for an invalid index pair" do
       @m[8,1].should be_nil
       @m[1,8].should be_nil
     end
   end
+
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/eql_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/eql_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/eql_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,5 +3,11 @@
 require 'matrix'
 
 describe "Matrix#eql?" do
-  it_behaves_like(:equal, :eql)
-end
+  it_behaves_like(:equal, :eql?)
+
+  ruby_bug("[ruby-dev:36298]", "1.8.7") do
+    it "returns false if some elements are == but not eql?" do
+      Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false
+    end
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/library/matrix/equal_value_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/equal_value_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/equal_value_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,5 +3,9 @@
 require 'matrix'
 
 describe "Matrix#==" do
-  it_behaves_like(:equal, :equal_value)
+  it_behaves_like(:equal, :==)
+
+  it "returns true if some elements are == but not eql?" do
+    Matrix[[1, 2],[3, 4]].should == Matrix[[1, 2],[3, 4.0]]
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/exponent_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/exponent_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/exponent_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,13 +3,41 @@
 
 describe "Matrix#**" do
 
-  it "multiples the Matrix by itself _n_ times" do
-    (Matrix[ [7,6], [3,9] ] ** 2).should == Matrix[ [67, 96], [48,99] ]
+  describe "given an integer _n_" do
+    it "multiples the Matrix by itself _n_ times" do
+      m = Matrix[ [7,6], [3,9] ]
+      (m ** 1).should == m
+      (m ** 2).should == Matrix[ [67, 96], [48,99] ]
+      (m ** 2).should == m * m
+      (m ** 3).should == m * m * m
+      (m ** 4).should == m * m * m * m
+      (m ** 5).should == m * m * m * m * m
+    end
+
+    it "raises a ErrDimensionMismatch for non square matrices" do
+      m = Matrix[ [1, 1], [1, 2], [2, 3]]
+      lambda { m ** 3 }.should raise_error(Matrix::ErrDimensionMismatch)
+      lambda { m ** 0 }.should raise_error(Matrix::ErrDimensionMismatch)
+    end
+
+    describe "that is <= 0" do
+      it "returns the inverse of **(-n)" do
+        m = Matrix[ [1, 1], [1, 2] ]
+        (m ** -2).should == Matrix[ [5, -3], [-3, 2]]
+        (m ** -4).should == (m.inverse ** 4)
+      end
+
+      it "raises a ErrDimensionMismatch for irregular matrices" do
+        m = Matrix[ [1, 1], [1, 1] ]
+        lambda { m ** -2 }.should raise_error(Matrix::ErrNotRegular)
+        lambda { m ** 0 }.should raise_error(Matrix::ErrNotRegular)
+      end
+    end
   end
-  
+
   it "raises a ErrOperationNotDefined exception for powers that aren't Integers" do
-    lambda {Matrix[ [1,2], [8,2] ] ** 2.5}.should 
+    lambda {Matrix[ [1,2], [8,2] ] ** 2.5}.should \
       raise_error(Matrix::ErrOperationNotDefined)
-  end  
+  end
 
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/hash_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/hash_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/hash_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,10 +1,6 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require 'matrix'
 
-# Note: Matrix just computes a bitwise OR of the element's .hash values, so
-# their position in the matrix isn't taken into account. This means that
-# matrices with the same elements in different positions will generate the
-# same .hash code...
 describe "Matrix#hash" do
   
   it "returns a Fixnum" do

Deleted: MacRuby/trunk/spec/frozen/library/matrix/init_rows_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/init_rows_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/init_rows_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'matrix'
-
-describe "Matrix#init_rows" do
-  it "needs to be reviewed for spec completeness"
-end

Deleted: MacRuby/trunk/spec/frozen/library/matrix/initialize_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/initialize_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/initialize_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,12 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'matrix'
-
-describe "Matrix#initialize" do
-  it "is private" do
-    Matrix[].private_methods.should include("initialize")
-  end
-
-  it "returns an instance of Matrix" do
-    Matrix[].should be_kind_of(Matrix)
-  end
-end

Modified: MacRuby/trunk/spec/frozen/library/matrix/inspect_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/inspect_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/inspect_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -7,4 +7,16 @@
     Matrix[ [1,2], [2,1] ].inspect.should == "Matrix[[1, 2], [2, 1]]"
   end
 
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns 'Matrix.empty(...)' for empty matrices" do
+      Matrix[ [], [], [] ].inspect.should == "Matrix.empty(3, 0)"
+      Matrix.columns([ [], [], [] ]).inspect.should == "Matrix.empty(0, 3)"
+    end
+  end
+
+  it "calls inspect on its contents" do
+    obj = mock("some_value")
+    obj.should_receive(:inspect).and_return("some_value")
+    Matrix[ [1, 2], [3, obj] ].inspect.should == "Matrix[[1, 2], [3, some_value]]"
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/inverse_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/inverse_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/inverse_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,3 +1,4 @@
+
 require File.dirname(__FILE__) + '/../../spec_helper'
 require File.dirname(__FILE__) + '/shared/inverse'
 require 'matrix'

Modified: MacRuby/trunk/spec/frozen/library/matrix/minor_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/minor_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/minor_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,49 +1,82 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 require 'matrix'
 
-describe "Matrix#minor with start_row, nrows, start_col, ncols" do
-  
+describe "Matrix#minor" do
   before(:each) do
     @matrix = Matrix[ [1,2], [3,4], [5,6] ]
-  end  
-  
-  it "returns the given portion of the Matrix" do
-    @matrix.minor(0,1,0,2).should == Matrix[ [1, 2] ]
-    @matrix.minor(1,2,1,1).should == Matrix[ [4], [6] ]
   end
- 
-  it "returns an empty Matrix unless nrows and ncols are greater than 0" do
-    @matrix.minor(0,0,0,0).should == Matrix[]
-    @matrix.minor(1,0,1,0).should == Matrix[]
-    @matrix.minor(1,0,1,1).should == Matrix[]
-    @matrix.minor(1,1,1,0).should == Matrix[[]] # FIXME: Inconsistent
+
+  describe "with start_row, nrows, start_col, ncols" do
+    it "returns the given portion of the Matrix" do
+      @matrix.minor(0,1,0,2).should == Matrix[ [1, 2] ]
+      @matrix.minor(1,2,1,1).should == Matrix[ [4], [6] ]
+    end
+
+    ruby_bug "redmine:1532", "1.8.7" do
+      it "returns an empty Matrix unless nrows and ncols are greater than 0" do
+        @matrix.minor(0,0,0,0).should == Matrix[]
+        @matrix.minor(1,0,1,0).should == Matrix[]
+        @matrix.minor(1,0,1,1).should == Matrix.columns([])
+        @matrix.minor(1,1,1,0).should == Matrix[[]]
+      end
+
+      it "returns nil for out-of-bounds start_row/col" do
+        r = @matrix.row_size + 1
+        c = @matrix.column_size + 1
+        @matrix.minor(r,0,0,10).should == nil
+        @matrix.minor(0,10,c,9).should == nil
+        @matrix.minor(-r,0,0,10).should == nil
+        @matrix.minor(0,10,-c,9).should == nil
+      end
+
+      it "returns nil for negative nrows or ncols" do
+        @matrix.minor(0,1,0,-1).should == nil
+        @matrix.minor(0,-1,0,1).should == nil
+      end
+
+      it "start counting backwards for start_row or start_col below zero" do
+        @matrix.minor(0, 1, -1, 1).should == @matrix.minor(0, 1, 1, 1)
+        @matrix.minor(-1, 1, 0, 1).should == @matrix.minor(2, 1, 0, 1)
+      end
+    end
+
+    it "returns empty matrices for extreme start_row/col" do
+      @matrix.minor(3,10,1,10).should == Matrix.columns([[]])
+      @matrix.minor(1,10,2,10).should == Matrix[[], []]
+      @matrix.minor(3,0,0,10).should == Matrix[]
+    end
+
+    it "ignores big nrows or ncols" do
+      @matrix.minor(0,1,0,20).should == Matrix[ [1, 2] ]
+      @matrix.minor(1,20,1,1).should == Matrix[ [4], [6] ]
+    end
   end
 
-  # This actually raises a NoMethodError: "(undefined method `call' for
-  #  Matrix[]:Matrix)", but we don't spec for this as it is yet another 
-  #  bug in Matrix.
-  it "raises for out-of-bounds arguments" do
-    @matrix.minor(3,0,0,0).should raise_error
-    @matrix.minor(0,0,0,9).should raise_error
-    lambda{@matrix.minor(9,9,9,9)}.should raise_error
-  end  
+  describe "with col_range, row_range" do
+    it "returns the given portion of the Matrix" do
+      @matrix.minor(0..0, 0..1).should == Matrix[ [1, 2] ]
+      @matrix.minor(1..2, 1..2).should == Matrix[ [4], [6] ]
+      @matrix.minor(1...3, 1...3).should == Matrix[ [4], [6] ]
+    end
 
-end
+    ruby_bug "redmine:1532", "1.8.7" do
+      it "returns nil if col_range or row_range is out of range" do
+        r = @matrix.row_size + 1
+        c = @matrix.column_size + 1
+        @matrix.minor(r..6, c..6).should == nil
+        @matrix.minor(0..1, c..6).should == nil
+        @matrix.minor(r..6, 0..1).should == nil
+        @matrix.minor(-r..6, -c..6).should == nil
+        @matrix.minor(0..1, -c..6).should == nil
+        @matrix.minor(-r..6, 0..1).should == nil
+      end
 
-describe "Matrix#minor with col_range, row_range" do
-  
-  before(:each) do
-    @matrix = Matrix[ [1,2], [3,4], [5,6] ]
-  end  
-  
-  it "returns the given portion of the Matrix" do
-    @matrix.minor(0..0,0..1).should == Matrix[ [1, 2] ]
-    @matrix.minor(1..2,1..2).should == Matrix[ [4], [6] ]
-    @matrix.minor(0...3,0...3).should == @matrix
+      it "start counting backwards for col_range or row_range below zero" do
+        @matrix.minor(0..1, -2..-1).should == @matrix.minor(0..1, 0..1)
+        @matrix.minor(0..1, -2..1).should == @matrix.minor(0..1, 0..1)
+        @matrix.minor(-2..-1, 0..1).should == @matrix.minor(1..2, 0..1)
+        @matrix.minor(-2..2, 0..1).should == @matrix.minor(1..2, 0..1)
+      end
+    end
   end
- 
-  it "returns an empty Matrix if col_range or row_range don't select any elements" do
-    @matrix.minor(3..6,3..6).should == Matrix[]
-  end
-
-end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/library/matrix/minus_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/minus_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/minus_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -20,9 +20,9 @@
   end
 
   it "raises a ExceptionForMatrix::ErrOperationNotDefined if other is a Numeric Type" do
-    lambda { @a - 2            }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
-    lambda { @a - 1.2          }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
-    lambda { @a - bignum_value }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
+    lambda { @a - 2            }.should raise_error(Matrix::ErrOperationNotDefined)
+    lambda { @a - 1.2          }.should raise_error(Matrix::ErrOperationNotDefined)
+    lambda { @a - bignum_value }.should raise_error(Matrix::ErrOperationNotDefined)
   end
 
   it "raises an exception if other is not a Matrix" do

Modified: MacRuby/trunk/spec/frozen/library/matrix/multiply_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/multiply_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/multiply_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -33,4 +33,22 @@
   it "raises a Matrix::ErrDimensionMismatch if the matrices are different sizes" do
     lambda { @a * Matrix[ [1] ] }.should raise_error(Matrix::ErrDimensionMismatch)
   end
+  
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns a zero matrix if (nx0) * (0xn)" do
+      (Matrix[[],[],[]] * Matrix.columns([[],[],[]])).should == Matrix.zero(3)
+    end
+
+    it "returns an empty matrix if (0xn) * (nx0)" do
+      (Matrix.columns([[],[],[]]) * Matrix[[],[],[]]).should == Matrix[]
+    end
+
+    it "returns a mx0 matrix if (mxn) * (nx0)" do
+      (Matrix[[1,2],[3,4],[5,6]] * Matrix[[],[]]).should == Matrix[[],[],[]]
+    end
+  
+    it "returns a 0xm matrix if (0xm) * (mxn)" do
+      (Matrix.columns([[], [], []]) * Matrix[[1,2],[3,4],[5,6]]).should == Matrix.columns([[],[]])
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/new_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/new_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,8 +3,8 @@
 
 describe "Matrix#new" do
   
-  it "returns a Matrix" do
-    lambda { Matrix.new }.should raise_error
+  it "is not accessible" do
+    lambda { Matrix.new }.should raise_error(NoMethodError)
   end
   
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -7,13 +7,6 @@
   # from writing a complete specification here. 
   it "needs to be reviewed for spec completeness"
 
-  it "returns false if the Matrix is ragged" do
-    Matrix[ [1,2], [3], [2,1] ].regular?.should be_false
-  end
-
-  # On Ruby 1.9.1 the below tests cause hangs, presumably due to bug #1020.
-  # They pass in 1.8.7. When #1020 is fixed, we can determine whether it was
-  # the cause of this failure...
   ruby_bug "#1020", "1.9.1.129" do
     it "returns false unless rank(A) != n" do
       m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]

Modified: MacRuby/trunk/spec/frozen/library/matrix/row_size_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/row_size_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/row_size_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,12 +2,12 @@
 require 'matrix'
 
 describe "Matrix#row_size" do
-  it "returns the number of elements in a row" do
-    data =  [[1,2], [3, 4]]
-    Matrix[ *data ].row_size.should == 2
+  it "returns the number rows" do
+    Matrix[ [1,2], [3, 4], [5, 6] ].row_size.should == 3
   end
 
-  it "returns 0 for an empty Matrix" do
-    Matrix[].row_size.should == 0
+  it "returns the number rows even for some empty matrices" do
+    Matrix[ [], [], [] ].row_size.should == 3
   end
+
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/row_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/row_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/row_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,15 +3,36 @@
 
 describe "Matrix#row" do
   before :all do
-    @data = [ [1, 2], [1, 2] ]
+    @m = Matrix[ [1, 2], [2, 3], [3, 4] ]
   end
 
   it "returns a Vector when called without a block" do
-    Matrix[ *@data ].row(0).should == Vector[1,2]
+    @m.row(0).should == Vector[1,2]
   end
 
-  # Seems like a bad idea...
-  it "returns an Array when called with a block" do
-    Matrix[ *@data ].row(0) { |x| x }.should == [1, 2]
+  it "yields the elements of the row when called with a block" do
+    a = []
+    @m.row(0) {|x| a << x}
+    a.should == [1,2]
   end
+
+  it "counts backwards for negative argument" do
+    @m.row(-1).should == Vector[3, 4]
+  end
+
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns self when called with a block" do
+      @m.row(0) { |x| x }.should equal(@m)
+    end
+
+    it "returns nil when out of bounds" do
+      @m.row(3).should == nil
+      @m.row(-4).should == nil
+    end
+
+    it "never yields when out of bounds" do
+      lambda { @m.row(3){ raise } }.should_not raise_error
+      lambda { @m.row(-4){ raise } }.should_not raise_error
+    end
+  end
 end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/library/matrix/row_vector_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/row_vector_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/row_vector_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -11,12 +11,8 @@
     Matrix.row_vector([1,2]).should == Matrix[ [1,2] ]
   end  
  
-  it "returns an empty Matrix when called with an empty Array" do
+  it "returns a 1x0 matrix when called with an empty Array" do
     Matrix.row_vector([]).should == Matrix[ [] ]
   end
 
-  it "returns a single-element Matrix when called with a Fixnum" do
-    Matrix.row_vector(1).should == Matrix[[1]]
-  end  
-   
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/row_vectors_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/row_vectors_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/row_vectors_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -19,11 +19,8 @@
     @vectors.should == [Vector[1,2], Vector[3,4]]
   end
 
-  # Matrix[[]].row_vectors == [], Matrix[[]].column_vectors == [Vector[]].
-  # Whatever the correct output, they should at least be consistent.
-  ruby_bug "#1526", "1.9.1.129" do
-    it "returns an empty Array for empty matrices" do
-      Matrix[ [] ].row_vectors.should == []
-    end
+  it "returns an empty Array for empty matrices" do
+    Matrix[].row_vectors.should == []
+    Matrix[ [] ].row_vectors.should == [ Vector[] ]
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/shared/collect.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/collect.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/collect.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,13 +1,19 @@
 describe :collect, :shared => true do
   before :all do
-    @data = [ [1, 2], [1, 2] ]
+    @m = Matrix[ [1, 2], [1, 2] ]
   end
 
   it "returns an instance of Matrix" do
-    Matrix[ *@data ].send(@method){|n| n * 2 }.should be_kind_of(Matrix)
+    @m.send(@method){|n| n * 2 }.should be_kind_of(Matrix)
   end
 
   it "returns a Matrix where each element is the result of the block" do
-    Matrix[ *@data ].send(@method) { |n| n * 2 }.should == Matrix[ [2, 4], [2, 4] ]
+    @m.send(@method) { |n| n * 2 }.should == Matrix[ [2, 4], [2, 4] ]
   end
+
+  ruby_bug "#1531", "1.8.7" do
+    it "returns an enumerator if no block is given" do
+      @m.send(@method).should be_kind_of(enumerator_class)
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -26,25 +26,14 @@
     m.send(@method).should == 2
   end
 
-  it "returns 0 for an empty Matrix" do
-    m = Matrix[ [] ]
-    m.send(@method).should == 0
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns 1 for an empty Matrix" do
+      m = Matrix[ ]
+      m.send(@method).should == 1
+    end
   end
 
-  # Matrix#square? returns true if the first row of the matrix has the same
-  # number of columns as the matrix has rows. This causes the .determinant
-  # method to raise a NoMethodError for '-'. I've reported it as
-  # http://redmine.ruby-lang.org/issues/show/1515 , and will guard for this bug
-  # in the #square? test. The examples below deliberately avoid this condition.
-  it "returns 0 when the Matrix is not square" do
-    m = Matrix[ [1], [2,3] ]
-    m.send(@method).should == 0
-
-    m = Matrix[ [1,2,3], [4,2] ]
-    m.send(@method).should == 0
-  end
-
-  ruby_bug "#1531", "1.9.1" do
+  ruby_bug "#1531", "1.8.7" do
     it "returns the determinant of a Matrices containing 0 as first entry" do
       Matrix[[0,1],[1,0]].send(@method).should == -1
     end

Modified: MacRuby/trunk/spec/frozen/library/matrix/shared/equal_value.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/equal_value.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/equal_value.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,5 +1,4 @@
 require 'matrix'
-require File.dirname(__FILE__) + '/../../../fixtures/matrix'
 
 describe :equal, :shared => true do
   before do
@@ -7,19 +6,16 @@
   end
 
   it "returns true for self" do
-    @matrix.eql?(@matrix).should be_true
+    @matrix.send(@method, @matrix).should be_true
   end
 
-  ruby_bug("[ruby-dev:36298]", "1.8.7") do
-    it "returns true when the each corresponding elements are equal in the sense of Object#eql?" do
-      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true
+  it "returns true for equal matrices" do
+    @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_true
+  end
 
-      num1, num2 = TrivialField.new, TrivialField.new
-      Matrix[[num1]].eql?(Matrix[[num2]]).should be_true
-    end
-
-    it "returns false when there are a pair corresponding elements which are not equal in the sense of Object#eql?" do
-      @matrix.eql?(Matrix[ [1, 2, 3, 4, 5.0], [2, 3, 4, 5, 6] ]).should be_false
-    end
+  it "returns false for different matrices" do
+    @matrix.send(@method, Matrix[ [42, 2, 3, 4, 5], [2, 3, 4, 5, 6] ]).should be_false
+    @matrix.send(@method, Matrix[ [1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7] ]).should be_false
+    @matrix.send(@method, Matrix[ [1, 2, 3], [2, 3, 4] ]).should be_false
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,32 +1,33 @@
 require 'matrix'
 
 describe :inverse, :shared => true do
- 
+
   it "returns a Matrix" do
     Matrix[ [1,2], [2,1] ].send(@method).should be_an_instance_of(Matrix)
   end
 
   it "returns the inverse of the Matrix" do
-    Matrix[ 
-      [1, 3, 3],     [1, 4, 3],  [1, 3, 4] 
-    ].send(@method).should == 
     Matrix[
+      [1, 3, 3],     [1, 4, 3],  [1, 3, 4]
+    ].send(@method).should ==
+    Matrix[
       [7, -3, -3],   [-1, 1, 0], [-1, 0, 1]
     ]
+  end
 
-    # FIXME: This example fails on 1.8.7 without 'mathn' being required.
-    # Embarrassingly, it works on JRuby. Ask brixen what to do here
-    Matrix[ 
-      [1, 2, 3],    [0, 1, 4],     [5, 6, 0] 
-    ].send(@method).should == 
-    Matrix[
-      [-24, 18, 5], [20, -15, -4], [-5, 4, 1]
-    ]
-  end 
+  ruby_bug "?", "1.8.7" do
+    it "returns the inverse of the Matrix (other case)" do
+      Matrix[
+        [1, 2, 3],    [0, 1, 4],     [5, 6, 0]
+      ].send(@method).should be_close_to_matrix([
+        [-24, 18, 5], [20, -15, -4], [-5, 4, 1]
+      ])
+    end
+  end
 
   it "raises a ErrDimensionMismatch if the Matrix is not square" do
-    lambda{ Matrix[ [1,2], [1] ].send(@method) }.should 
+    lambda{ Matrix[ [1,2], [1] ].send(@method) }.should
       raise_error(Matrix::ErrDimensionMismatch)
-  end  
+  end
 
 end

Added: MacRuby/trunk/spec/frozen/library/matrix/shared/trace.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/trace.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/trace.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,14 @@
+require 'matrix'
+
+describe :trace, :shared => true do
+  it "returns the sum of diagonal elements in a square Matrix" do
+    Matrix[[7,6], [3,9]].trace.should == 16
+  end
+
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns the sum of diagonal elements in a rectangular Matrix" do
+      lambda{ Matrix[[1,2,3], [4,5,6]].trace}.should raise_error(Matrix::ErrDimensionMismatch)
+    end
+  end
+
+end

Modified: MacRuby/trunk/spec/frozen/library/matrix/shared/transpose.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/transpose.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/transpose.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -4,4 +4,11 @@
   it "returns a transposed matrix" do
     Matrix[[1, 2], [3, 4], [5, 6]].send(@method).should == Matrix[[1, 3, 5], [2, 4, 6]]
   end
+
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "can transpose empty matrices" do
+      m = Matrix[[], [], []]
+      m.send(@method).send(@method).should == m
+    end
+  end
 end

Added: MacRuby/trunk/spec/frozen/library/matrix/spec_helper.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/spec_helper.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/spec_helper.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -0,0 +1,34 @@
+class BeCloseToMatrixMatcher
+  def initialize(expected, tolerance = TOLERANCE)
+    @expected = Matrix[*expected]
+    @tolerance = tolerance
+  end
+
+  def matches?(actual)
+    @actual = actual
+    return false unless @actual.is_a? Matrix
+    return false unless @actual.row_size == @expected.row_size
+    @actual.row_size.times do |i|
+      a, e = @actual.row(i), @expected.row(i)
+      return false unless a.size == e.size
+      a.size.times do |j|
+        return false unless (a[j] - e[j]).abs < @tolerance
+      end
+    end
+    true
+  end
+
+  def failure_message
+    ["Expected #{@expected}", "to be within +/- #{@tolerance} of #{@actual}"]
+  end
+
+  def negative_failure_message
+    ["Expected #{@expected}", "not to be within +/- #{@tolerance} of #{@actual}"]
+  end
+end
+
+class Object
+  def be_close_to_matrix(expected, tolerance = TOLERANCE)
+    BeCloseToMatrixMatcher.new(expected, tolerance)
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/matrix/square_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/square_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/square_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -8,22 +8,23 @@
     Matrix[ [100,3,5], [9.5, 4.9, 8], [2,0,77] ].square?.should be_true
   end
 
-  # .square? should return false if the Matrix is non square. However, there
-  # is a bug whereby .square? will return true as long as the first row has
-  # the same number of columns as the Matrix has rows. Hence the awkward
-  # examples.
-  it "returns false when the Matrix is not square and the first row has a
-  different number of columns than the Matrix has rows" do
+  it "returns true when the Matrix has only one element" do
+    Matrix[ [9] ].square?.should be_true
+  end
+
+  it "returns false when the Matrix is rectangular" do
     Matrix[ [1, 2] ].square?.should be_false
-    Matrix[ [1], [9,7], [2] ].square?.should be_false
   end
 
-  # FIXME: Remove guard when bug is fixed.
-  ruby_bug "#1515", "1.9.1.192" do 
-    it "returns false when the Matrix is not square
-    and the first row has the same number of columns as the matrix has rows." do
-      Matrix[ [1,2,3], [4,5], [6] ].square?.should be_false 
+  it "returns false when the Matrix is rectangular" do
+    Matrix[ [1], [2] ].square?.should be_false
+  end
+
+  ruby_bug "redmine:1532", "1.8.7" do
+    it "returns handles empty matrices" do
+      Matrix[].square?.should be_true
+      Matrix[[]].square?.should be_false
+      Matrix.columns([[]]).square?.should be_false
     end
-  end  
-
+  end
 end  

Modified: MacRuby/trunk/spec/frozen/library/matrix/tr_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/tr_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/tr_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/trace'
 require 'matrix'
 
 describe "Matrix#tr" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like(:trace, :tr)
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/trace_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/trace_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/trace_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,7 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/trace'
 require 'matrix'
 
 describe "Matrix#trace" do
-  it "needs to be reviewed for spec completeness"
+  it_behaves_like(:trace, :trace)
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/vector/eql_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/vector/eql_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/vector/eql_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,6 +1,5 @@
 require File.dirname(__FILE__) + '/../../../spec_helper'
 require 'matrix'
-require File.dirname(__FILE__) + '/../../../fixtures/matrix'
 
 describe "Vector#eql?" do
   before do
@@ -12,13 +11,6 @@
   end
 
   ruby_bug("[ruby-dev:36298]", "1.8.7") do
-    it "returns true when the each corresponding elements are equal in the sense of Object#eql?" do
-      @vector.eql?(Vector[1, 2, 3, 4, 5]).should be_true
-
-      num1, num2 = TrivialField.new, TrivialField.new
-      Vector[num1].eql?(Vector[num2]).should be_true
-    end
-
     it "returns false when there are a pair corresponding elements which are not equal in the sense of Object#eql?" do
       @vector.eql?(Vector[1, 2, 3, 4, 5.0]).should be_false
     end

Modified: MacRuby/trunk/spec/frozen/library/matrix/zero_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/zero_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/matrix/zero_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -26,29 +26,4 @@
       end
     end
   end
-  
-  it "returns an object of type Matrix" do
-    Matrix.zero(3).class.should == Matrix
-  end
-  
-  it "creates a square matrix with size given by the argument" do
-    m3 = Matrix.zero(3)
-    m3.row_size.should == 3
-    m3.column_size.should == 3
-    
-    m8 = Matrix.zero(8)
-    m8.row_size.should == 8
-    m8.column_size.should == 8
-  end
-  
-  it "initializes all cells to 0" do
-    size = 10 # arbitrary value
-    m = Matrix.zero(size)
-    
-    (0...size).each do |i|
-      (0...size).each do |j|
-        m[i, j].should == 0
-      end
-    end
-  end
 end

Modified: MacRuby/trunk/spec/frozen/library/mutex/lock_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/mutex/lock_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/mutex/lock_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -26,4 +26,10 @@
     th.join
     v.should == 1
   end
+
+  it "raises ThreadError if the current thread already locks this monitor" do
+    mutex = Mutex.new
+    mutex.lock
+    lambda { mutex.lock }.should raise_error(ThreadError)
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/mutex/try_lock_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/mutex/try_lock_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/mutex/try_lock_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -5,8 +5,18 @@
   it "returns true if lock can be aquired immediately" do
     m = Mutex.new
     m.try_lock.should be_true
+    m.try_lock.should be_false
   end
 
+  it "actually locks" do
+    m = Mutex.new
+    m.try_lock
+
+    m.locked?.should be_true
+    lambda { m.lock }.should raise_error(ThreadError)
+    lambda { m.try_lock }.should_not raise_error(ThreadError)
+  end
+
   it "returns false if lock can not be aquired immediately" do
     m1 = Mutex.new
     m2 = Mutex.new

Modified: MacRuby/trunk/spec/frozen/library/mutex/unlock_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/mutex/unlock_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/mutex/unlock_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -25,6 +25,17 @@
     th.join
   end
 
+  it "raises ThreadError if previously locking thread is gone" do
+    mutex = Mutex.new
+    th = Thread.new do
+      mutex.lock
+    end
+
+    th.join
+
+    lambda { mutex.unlock }.should raise_error(ThreadError)
+  end
+
   it "returns nil if successful" do
     mutex = Mutex.new
     mutex.lock

Modified: MacRuby/trunk/spec/frozen/library/socket/basicsocket/send_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/basicsocket/send_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/basicsocket/send_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -26,6 +26,7 @@
      t.status.should_not be_nil
 
      @socket.send('hello', 0).should == 5
+     @socket.shutdown # indicate, that we are done sending
 
      t.join
      data.should == 'hello'
@@ -44,6 +45,7 @@
      t.status.should_not be_nil
 
      @socket.send('helloU', Socket::MSG_PEEK | Socket::MSG_OOB).should == 6
+     @socket.shutdown # indicate, that we are done sending
 
      t.join
      peek_data.should == "hello"
@@ -62,6 +64,7 @@
 
      sockaddr = Socket.pack_sockaddr_in(SocketSpecs.port, "127.0.0.1")
      @socket.send('hello', 0, sockaddr).should == 5
+     @socket.shutdown # indicate, that we are done sending
 
      t.join
      data.should == 'hello'

Modified: MacRuby/trunk/spec/frozen/library/socket/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/fixtures/classes.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/fixtures/classes.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -22,6 +22,6 @@
   end
 
   def self.socket_path
-    "/tmp/unix_server_spec.socket"
+    tmp("unix_server_spec.socket")
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/socket/ipsocket/recvfrom_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/ipsocket/recvfrom_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/ipsocket/recvfrom_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -22,6 +22,7 @@
     end
 
     @client.send('hello', 0)
+    @client.shutdown
     t.join
 
     data.first.should == 'hello'
@@ -36,6 +37,7 @@
     end
 
     @client.send('hello', 0)
+    @client.shutdown
     t.join
 
     data.first.should == 'hel'
@@ -50,6 +52,7 @@
     end
 
     @client.send('hello', 0)
+    @client.shutdown
     t.join
 
     data.size.should == 2

Modified: MacRuby/trunk/spec/frozen/library/socket/socket/bind_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/socket/bind_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/socket/bind_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -3,10 +3,9 @@
 
 include Socket::Constants
 
-describe "Socket#bind" do
-
+describe "Socket#bind on SOCK_DGRAM socket" do
   before :each do
-    @sock = Socket.new(AF_INET, SOCK_DGRAM, 0);    
+    @sock = Socket.new(AF_INET, SOCK_DGRAM, 0);
     @sockaddr = Socket.pack_sockaddr_in(SocketSpecs.port, "127.0.0.1");
   end
 
@@ -18,13 +17,64 @@
   it "binds to a port" do
     lambda { @sock.bind(@sockaddr) }.should_not raise_error
   end
-  
-  it "raises an error if we try to bind to an already bound port" do
+
+  it "returns 0 if successful" do
+    @sock.bind(@sockaddr).should == 0
+  end
+
+  it "raises Errno::EINVAL when binding to an already bound port" do
     @sock.bind(@sockaddr);
 
-    sock2 = Socket.new(AF_INET, SOCK_DGRAM, 0);
-    lambda { sock2.bind(@sockaddr) }.should raise_error;
+    lambda { @sock.bind(@sockaddr); }.should raise_error(Errno::EINVAL);
+  end
 
-    sock2.close unless sock2.closed?
+  it "raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available from the local machine" do
+    sockaddr1 = Socket.pack_sockaddr_in(SocketSpecs.port, "4.3.2.1");
+    lambda { @sock.bind(sockaddr1); }.should raise_error(Errno::EADDRNOTAVAIL)
   end
+
+  platform_is_not :os => [:windows, :cygwin] do
+    it "raises Errno::EACCES when the current user does not have permission to bind" do
+      sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1");
+      lambda { @sock.bind(sockaddr1); }.should raise_error(Errno::EACCES)
+    end
+  end
 end
+
+describe "Socket#bind on SOCK_STREAM socket" do
+  before :each do
+    @sock = Socket.new(AF_INET, SOCK_STREAM, 0);
+    @sockaddr = Socket.pack_sockaddr_in(SocketSpecs.port, "127.0.0.1");
+  end
+
+  after :each do
+    @sock.closed?.should be_false
+    @sock.close
+  end
+
+  it "binds to a port" do
+    lambda { @sock.bind(@sockaddr) }.should_not raise_error
+  end
+
+  it "returns 0 if successful" do
+    @sock.bind(@sockaddr).should == 0
+  end
+
+  it "raises Errno::EINVAL when binding to an already bound port" do
+    @sock.bind(@sockaddr);
+
+    lambda { @sock.bind(@sockaddr); }.should raise_error(Errno::EINVAL);
+  end
+
+  it "raises Errno::EADDRNOTAVAIL when the specified sockaddr is not available from the local machine" do
+    sockaddr1 = Socket.pack_sockaddr_in(SocketSpecs.port, "4.3.2.1");
+    lambda { @sock.bind(sockaddr1); }.should raise_error(Errno::EADDRNOTAVAIL)
+  end
+
+  platform_is_not :os => [:windows, :cygwin] do
+    it "raises Errno::EACCES when the current user does not have permission to bind" do
+      sockaddr1 = Socket.pack_sockaddr_in(1, "127.0.0.1");
+      lambda { @sock.bind(sockaddr1); }.should raise_error(Errno::EACCES)
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/socket/socket/for_fd_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/socket/for_fd_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/socket/for_fd_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -23,13 +23,16 @@
       host.read(3).should == "bar"
     ensure
       if (server && !server.closed?)
-        server.close unless server.closed?
+        server.close
       end
       if (client && !client.closed?)
-        client.close unless server.closed?
+        client.close
       end
       if (new_sock && !new_sock.closed?)
-        new_sock.close
+        begin
+          new_sock.close
+        rescue Errno::EBADF
+        end
       end
     end
   end

Modified: MacRuby/trunk/spec/frozen/library/socket/socket/getnameinfo_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/socket/getnameinfo_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/socket/getnameinfo_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -28,7 +28,9 @@
   it "gets the name information and resolves the service" do
     sockaddr = Socket.sockaddr_in 80, '127.0.0.1'
     name_info = Socket.getnameinfo(sockaddr)
-    name_info.should == ["localhost", "http"]
+    name_info.size.should == 2
+    name_info[0].should == "localhost"
+    # see http://www.iana.org/assignments/port-numbers
+    name_info[1].should =~ /^(www|http|www-http)$/
   end
 end
-

Modified: MacRuby/trunk/spec/frozen/library/socket/tcpserver/accept_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/tcpserver/accept_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/tcpserver/accept_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -24,6 +24,7 @@
     
     socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
     socket.write('hello')
+    socket.shutdown(1) # we are done with sending
     socket.read.should == 'goodbye'
     t.join
     data.should == 'hello'

Modified: MacRuby/trunk/spec/frozen/library/socket/tcpserver/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/tcpserver/new_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/tcpserver/new_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -53,4 +53,19 @@
     # TODO: This should also accept strings like 'https', but I don't know how to
     # pick such a service port that will be able to reliably bind...
   end
+  
+  it "raises Errno::EADDRNOTAVAIL when the adress is unknown" do
+    lambda { TCPServer.new("1.2.3.4", 4000) }.should raise_error(Errno::EADDRNOTAVAIL)
+  end
+  
+  it "raises a SocketError when the host is unknown" do
+    lambda { TCPServer.new("http://asdffdsaasdfaasdfasdfgfdadsdfdsf.com", 4000) }.should raise_error(SocketError)
+  end
+
+  it "raises Errno::EADDRINUSE when address is already in use" do
+    lambda {
+      @server = TCPServer.new('127.0.0.1', SocketSpecs.port)
+      @server = TCPServer.new('127.0.0.1', SocketSpecs.port)
+    }.should raise_error(Errno::EADDRINUSE)
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/socket/tcpsocket/shared/new.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/tcpsocket/shared/new.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/socket/tcpsocket/shared/new.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -16,7 +16,9 @@
   it "connects to a listening server" do
     thread = Thread.new do
       server = TCPServer.new(SocketSpecs.port)
-      server.accept
+      conn = server.accept
+      conn.recv(50)
+      conn.close
       server.close
     end
     Thread.pass while thread.status and thread.status != 'sleep'
@@ -31,7 +33,9 @@
   it "has an address once it has connected to a listening server" do
     thread = Thread.new do
       server = TCPServer.new('127.0.0.1', SocketSpecs.port)
-      server.accept
+      conn = server.accept
+      conn.recv(50)
+      conn.close
       server.close
     end
     Thread.pass while thread.status and thread.status != 'sleep'

Modified: MacRuby/trunk/spec/frozen/library/tempfile/initialize_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/tempfile/initialize_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/tempfile/initialize_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -13,7 +13,8 @@
   it "opens a new tempfile with the passed name in the passed directory" do
     @tempfile.send(:initialize, "basename", tmp(""))
     File.exist?(@tempfile.path).should be_true
-    @tempfile.path.should =~ /^#{tmp("")}/
+    tmpdir = tmp("")
+    @tempfile.path[0, tmpdir.length].should == tmpdir
     @tempfile.path.should include("basename")
   end
 

Modified: MacRuby/trunk/spec/frozen/library/tempfile/path_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/tempfile/path_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/tempfile/path_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -4,7 +4,8 @@
 describe "Tempfile#path" do
   it "returns the path to the tempfile" do
     @tempfile = Tempfile.new("specs", tmp(""))
-    @tempfile.path.should =~ /^#{tmp("")}/
+    tmpdir = tmp("")
+    @tempfile.path[0, tmpdir.length].should == tmpdir
     @tempfile.path.should include("specs")
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/tmpdir/dir/mktmpdir_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/tmpdir/dir/mktmpdir_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/tmpdir/dir/mktmpdir_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -50,6 +50,7 @@
     end
   
     it "returns the blocks return value" do
+      Dir.stub!(:mkdir)
       Dir.mktmpdir { :test }.should equal(:test)
     end
   end
@@ -90,4 +91,4 @@
       lambda { Dir.mktmpdir(10) }.should raise_error(ArgumentError)
     end
   end
-end
\ No newline at end of file
+end

Modified: MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,7 +2,7 @@
 require 'zlib'
 
 describe 'Zlib::Deflate#params' do
-  ruby_bug '293', '1.9.0' do
+  ruby_bug '239', '1.9.0' do
   it 'changes the deflate parameters' do
     data = 'abcdefghijklm'
 

Modified: MacRuby/trunk/spec/frozen/library/zlib/inflate/append_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/zlib/inflate/append_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/zlib/inflate/append_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,11 +2,59 @@
 require 'zlib'
 
 describe 'Zlib::Inflate#<<' do
+  before :all do
+    @foo_deflated = "x\234K\313\317\a\000\002\202\001E"
+  end
+
+  before :each do
+    @z = Zlib::Inflate.new
+  end
+
+  after :each do
+    @z.close unless @z.closed?
+  end
+
   it 'appends data to the input stream' do
-    zs = Zlib::Inflate.new
-    zs << "x\234K\313\317\a\000\002\202\001E"
+    @z << @foo_deflated
+    @z.finish.should == 'foo'
+  end
 
-    zs.finish.should == 'foo'
+  it 'treats nil argument as the end of compressed data' do
+    @z = Zlib::Inflate.new
+    @z << @foo_deflated << nil
+    @z.finish.should == 'foo'
   end
+
+  it 'just passes through the data after nil argument' do
+    @z = Zlib::Inflate.new
+    @z << @foo_deflated << nil
+    @z << "-after_nil_data"
+    @z.finish.should == 'foo-after_nil_data'
+  end
+
+  it 'properly handles data in chunks' do
+    # add bytes, one by one
+    @foo_deflated.each_byte { |d| @z << d.chr}
+    @z.finish.should == "foo"
+  end
+
+  it 'properly handles incomplete data' do
+    # add bytes, one by one
+    @foo_deflated[0, 5].each_byte { |d| @z << d.chr}
+    lambda { @z.finish }.should raise_error(Zlib::BufError)
+  end
+
+  it 'properly handles excessive data, byte-by-byte' do
+    # add bytes, one by one
+    data = @foo_deflated * 2
+    data.each_byte { |d| @z << d.chr}
+    @z.finish.should == "foo" + @foo_deflated
+  end
+
+  it 'properly handles excessive data, in one go' do
+    # add bytes, one by one
+    data = @foo_deflated * 2
+    @z << data
+    @z.finish.should == "foo" + @foo_deflated
+  end
 end
-

Modified: MacRuby/trunk/spec/frozen/library/zlib/inflate/inflate_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/zlib/inflate/inflate_spec.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/library/zlib/inflate/inflate_spec.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -25,6 +25,20 @@
     unzipped.should == "\000" * 32 * 1024
   end
 
+  it 'works in pass-through mode, once finished' do
+    data = "x\234c`\200\001\000\000\n\000\001"
+
+    unzipped = @inflator.inflate data
+    @inflator.finish  # this is a precondition
+
+    out = @inflator.inflate('uncompressed_data')
+    out << @inflator.finish
+    out.should == 'uncompressed_data'
+
+    @inflator << ('uncompressed_data') << nil
+    @inflator.finish.should == 'uncompressed_data'
+  end
+
 end
 
 describe 'Zlib::Inflate::inflate' do
@@ -45,5 +59,51 @@
     zipped.should == "\000" * 32 * 1024
   end
 
+  it 'properly handles data in chunks' do
+    data =  "x\234K\313\317\a\000\002\202\001E"
+    z = Zlib::Inflate.new
+    # add bytes, one by one
+    result = ""
+    data.each_byte { |d| result << z.inflate(d.chr)}
+    result << z.finish
+    result.should == "foo"
+  end
+
+  it 'properly handles incomplete data' do
+    data =  "x\234K\313\317\a\000\002\202\001E"[0,5]
+    z = Zlib::Inflate.new
+    # add bytes, one by one, but not all
+    result = ""
+    data.each_byte { |d| result << z.inflate(d.chr)}
+    lambda { result << z.finish }.should raise_error(Zlib::BufError)
+  end
+
+  it 'properly handles excessive data, byte-by-byte' do
+    main_data = "x\234K\313\317\a\000\002\202\001E"
+    data =  main_data * 2
+    result = ""
+
+    z = Zlib::Inflate.new
+    # add bytes, one by one
+    data.each_byte { |d| result << z.inflate(d.chr)}
+    result << z.finish
+
+    # the first chunk is inflated to its completion,
+    # the second chunk is just passed through.
+    result.should == "foo" + main_data
+  end
+
+  it 'properly handles excessive data, in one go' do
+    main_data = "x\234K\313\317\a\000\002\202\001E"
+    data =  main_data * 2
+    result = ""
+
+    z = Zlib::Inflate.new
+    result << z.inflate(data)
+    result << z.finish
+
+    # the first chunk is inflated to its completion,
+    # the second chunk is just passed through.
+    result.should == "foo" + main_data
+  end
 end
-

Modified: MacRuby/trunk/spec/frozen/shared/rational/div.rb
===================================================================
--- MacRuby/trunk/spec/frozen/shared/rational/div.rb	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/shared/rational/div.rb	2009-11-16 23:45:01 UTC (rev 3023)
@@ -2,38 +2,38 @@
 require 'rational'
 
 describe :rational_div_rat, :shared => true do
-  it "performs integer division and returns the result" do 
+  it "performs integer division and returns the result" do
     Rational(2, 3).div(Rational(2, 3)).should == 1
     Rational(-2, 9).div(Rational(-9, 2)).should == 0
   end
-  
+
   it "raises a ZeroDivisionError when the argument has a numerator of 0" do
     lambda { Rational(3, 4).div(Rational(0, 3)) }.should raise_error(ZeroDivisionError)
-  end    
- 
+  end
+
   # 1.8 doesn't accept Floats for Rational() arguments
   ruby_version_is "1.9" do
     it "raises a ZeroDivisionError when the argument has a numerator of 0.0" do
       lambda { Rational(3, 4).div(Rational(0.0, 3)) }.should raise_error(ZeroDivisionError)
     end
   end
-end  
+end
 
 describe :rational_div_float, :shared => true do
 
   # The version guard is necessary because 1.8 can't cope with Floats passed
   # to Rational(), so we need to simplify the examples accordingly.
-  
+
   ruby_version_is "1.9" do
-    it "performs integer division and returns the result" do 
+    it "performs integer division and returns the result" do
       Rational(2, 3).div(30.333).should == 0
       Rational(2, 9).div(Rational(-8.6)).should == -1
       Rational(3.12).div(0.5).should == 6
     end
   end
-  
+
   ruby_version_is ""..."1.9" do
-    it "performs integer division and returns the result" do 
+    it "performs integer division and returns the result" do
       Rational(2, 3).div(30.333).should == 0
       Rational(7, 12).div(0.5).should == 1
     end
@@ -42,39 +42,40 @@
   ruby_version_is ""..."1.9" do
     it "raises a FloatDomainError when the argument is 0.0" do
       lambda { Rational(3, 4).div(0.0) }.should raise_error(FloatDomainError)
-    end    
+    end
   end
 
   ruby_version_is "1.9" do
     it "raises a ZeroDivisionError when the argument is 0.0" do
       lambda { Rational(3, 4).div(0.0) }.should raise_error(ZeroDivisionError)
-    end    
+    end
   end
-end  
+end
 
 describe :rational_div_int, :shared => true do
-  it "performs integer division and returns the result" do 
+  it "performs integer division and returns the result" do
     Rational(2, 1).div(1).should == 2
     Rational(25, 5).div(-50).should == -1
   end
-  
+
   it "raises a ZeroDivisionError when the argument is 0" do
     lambda { Rational(3, 4).div(0) }.should raise_error(ZeroDivisionError)
-  end    
-end  
+  end
+end
 
 describe :rational_div, :shared => true do
-  it "returns an Integer" do 
+  it "returns an Integer" do
     Rational(229, 21).div(82).should be_kind_of(Integer)
   end
-  
+
   it "raises an ArgumentError if passed more than one argument" do
     lambda { Rational(3, 4).div(2,3) }.should raise_error(ArgumentError)
-  end    
+  end
 
-  ruby_bug "#1648", "1.8.7" do
+  # See http://redmine.ruby-lang.org/issues/show/1648
+  ruby_version_is "1.8.8" do
     it "raises a TypeError if passed a non-numeric argument" do
       lambda { Rational(3, 4).div([]) }.should raise_error(TypeError)
     end
-  end  
-end  
+  end
+end

Modified: MacRuby/trunk/spec/frozen/tags/1.9/core/argf/bytes_tags.txt
===================================================================
--- MacRuby/trunk/spec/frozen/tags/1.9/core/argf/bytes_tags.txt	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/tags/1.9/core/argf/bytes_tags.txt	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,2 +1 @@
 fails:ARGF.bytes returns self when passed a block
-fails:ARGF.bytes returns an Enumerable::Enumerator when passed no block

Modified: MacRuby/trunk/spec/frozen/tags/1.9/core/argf/chars_tags.txt
===================================================================
--- MacRuby/trunk/spec/frozen/tags/1.9/core/argf/chars_tags.txt	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/tags/1.9/core/argf/chars_tags.txt	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,2 +1 @@
 fails:ARGF.chars returns self when passed a block
-fails:ARGF.chars returns an Enumerable::Enumerator when passed no block

Modified: MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_byte_tags.txt
===================================================================
--- MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_byte_tags.txt	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_byte_tags.txt	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,2 +1 @@
 fails:ARGF.each_byte returns self when passed a block
-fails:ARGF.each_byte returns an Enumerable::Enumerator when passed no block

Modified: MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_char_tags.txt
===================================================================
--- MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_char_tags.txt	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/tags/1.9/core/argf/each_char_tags.txt	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1,2 +1 @@
 fails:ARGF.each_char returns self when passed a block
-fails:ARGF.each_char returns an Enumerable::Enumerator when passed no block

Deleted: MacRuby/trunk/spec/frozen/tags/1.9/core/argf/lineno_tags.txt
===================================================================
--- MacRuby/trunk/spec/frozen/tags/1.9/core/argf/lineno_tags.txt	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/tags/1.9/core/argf/lineno_tags.txt	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1 +0,0 @@
-fails:ARGF.lineno returns the current line number on each file

Modified: MacRuby/trunk/spec/frozen/upstream
===================================================================
--- MacRuby/trunk/spec/frozen/upstream	2009-11-16 23:15:04 UTC (rev 3022)
+++ MacRuby/trunk/spec/frozen/upstream	2009-11-16 23:45:01 UTC (rev 3023)
@@ -1 +1 @@
-1dffcb6782dfa03652348a3143569abba086d290
\ No newline at end of file
+bb54356acee1c73a63472b3ae57479da6cac48f1
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091116/9d8397e6/attachment-0001.html>


More information about the macruby-changes mailing list