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

source_changes at macosforge.org source_changes at macosforge.org
Fri May 14 10:36:07 PDT 2010


Revision: 4103
          http://trac.macosforge.org/projects/ruby/changeset/4103
Author:   eloy.de.enige at gmail.com
Date:     2010-05-14 10:36:03 -0700 (Fri, 14 May 2010)
Log Message:
-----------
Update RubySpec to 2113588fc23df1d2750e2b81d34defa97030cf3b

Modified Paths:
--------------
    MacRuby/trunk/spec/frozen/core/array/combination_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/bignum/bit_and_spec.rb
    MacRuby/trunk/spec/frozen/core/bignum/bit_or_spec.rb
    MacRuby/trunk/spec/frozen/core/bignum/bit_xor_spec.rb
    MacRuby/trunk/spec/frozen/core/bignum/exponent_spec.rb
    MacRuby/trunk/spec/frozen/core/encoding/aliases_spec.rb
    MacRuby/trunk/spec/frozen/core/encoding/locale_charmap_spec.rb
    MacRuby/trunk/spec/frozen/core/exception/errno_spec.rb
    MacRuby/trunk/spec/frozen/core/fiber/resume_spec_disabled.rb
    MacRuby/trunk/spec/frozen/core/file/basename_spec.rb
    MacRuby/trunk/spec/frozen/core/file/expand_path_spec.rb
    MacRuby/trunk/spec/frozen/core/fixnum/exponent_spec.rb
    MacRuby/trunk/spec/frozen/core/float/to_s_spec.rb
    MacRuby/trunk/spec/frozen/core/hash/eql_spec.rb
    MacRuby/trunk/spec/frozen/core/hash/equal_value_spec.rb
    MacRuby/trunk/spec/frozen/core/hash/keep_if_spec.rb
    MacRuby/trunk/spec/frozen/core/hash/select_spec.rb
    MacRuby/trunk/spec/frozen/core/hash/shared/eql.rb
    MacRuby/trunk/spec/frozen/core/io/copy_stream_spec.rb
    MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb
    MacRuby/trunk/spec/frozen/core/io/popen_spec.rb
    MacRuby/trunk/spec/frozen/core/io/read_spec.rb
    MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/clone_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/core/kernel/lambda_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/load_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/private_methods_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/public_methods_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/rand_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/shared/lambda.rb
    MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb
    MacRuby/trunk/spec/frozen/core/kernel/spawn_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/srand_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/system_spec.rb
    MacRuby/trunk/spec/frozen/core/marshal/fixtures/marshal_data.rb
    MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb
    MacRuby/trunk/spec/frozen/core/module/autoload_spec.rb
    MacRuby/trunk/spec/frozen/core/module/class_variable_set_spec.rb
    MacRuby/trunk/spec/frozen/core/module/const_missing_spec.rb
    MacRuby/trunk/spec/frozen/core/module/define_method_spec.rb
    MacRuby/trunk/spec/frozen/core/module/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/core/module/remove_class_variable_spec.rb
    MacRuby/trunk/spec/frozen/core/process/kill_spec.rb
    MacRuby/trunk/spec/frozen/core/process/setrlimit_spec.rb
    MacRuby/trunk/spec/frozen/core/random/bytes_spec.rb
    MacRuby/trunk/spec/frozen/core/random/new_seed_spec.rb
    MacRuby/trunk/spec/frozen/core/random/rand_spec.rb
    MacRuby/trunk/spec/frozen/core/range/each_spec.rb
    MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb
    MacRuby/trunk/spec/frozen/core/string/split_spec.rb
    MacRuby/trunk/spec/frozen/core/string/sub_spec.rb
    MacRuby/trunk/spec/frozen/core/string/sum_spec.rb
    MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb
    MacRuby/trunk/spec/frozen/core/string/unpack_spec.rb
    MacRuby/trunk/spec/frozen/core/time/strftime_spec.rb
    MacRuby/trunk/spec/frozen/language/block_spec.rb
    MacRuby/trunk/spec/frozen/language/defined_spec.rb
    MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb
    MacRuby/trunk/spec/frozen/language/encoding_spec.rb
    MacRuby/trunk/spec/frozen/language/file_spec.rb
    MacRuby/trunk/spec/frozen/language/fixtures/defined.rb
    MacRuby/trunk/spec/frozen/language/line_spec.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/sqrt_spec.rb
    MacRuby/trunk/spec/frozen/library/ftools/chmod_spec.rb
    MacRuby/trunk/spec/frozen/library/ftools/install_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/divide_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/plus_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb
    MacRuby/trunk/spec/frozen/library/matrix/singular_spec.rb
    MacRuby/trunk/spec/frozen/library/set/sortedset/initialize_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/ipsocket/getaddress_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/udpsocket/send_spec.rb
    MacRuby/trunk/spec/frozen/library/socket/unixserver/accept_spec.rb
    MacRuby/trunk/spec/frozen/library/stringio/pos_spec.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/getbyte_spec.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/getch_spec.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/matched_spec.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/post_match_spec.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/pre_match_spec.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/rest_spec.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/shared/peek.rb
    MacRuby/trunk/spec/frozen/library/tempfile/shared/length.rb
    MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb
    MacRuby/trunk/spec/frozen/upstream

Added Paths:
-----------
    MacRuby/trunk/spec/frozen/core/file/read_spec.rb
    MacRuby/trunk/spec/frozen/core/file/shared/read.rb
    MacRuby/trunk/spec/frozen/core/kernel/singleton_class_spec.rb
    MacRuby/trunk/spec/frozen/core/module/fixtures/autoload_s.rb
    MacRuby/trunk/spec/frozen/language/false_spec.rb
    MacRuby/trunk/spec/frozen/language/nil_spec.rb
    MacRuby/trunk/spec/frozen/language/self_spec.rb
    MacRuby/trunk/spec/frozen/language/shared/pseudo_variable.rb
    MacRuby/trunk/spec/frozen/language/true_spec.rb
    MacRuby/trunk/spec/frozen/library/digest/hexencode_spec.rb
    MacRuby/trunk/spec/frozen/library/digest/md5/file_spec.rb
    MacRuby/trunk/spec/frozen/library/digest/sha1/file_spec.rb
    MacRuby/trunk/spec/frozen/library/digest/sha256/file_spec.rb
    MacRuby/trunk/spec/frozen/library/digest/sha384/file_spec.rb
    MacRuby/trunk/spec/frozen/library/digest/sha512/file_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/build_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/conj_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/conjugate_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/each_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/each_with_index_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/empty_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/imag_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/imaginary_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/real_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/rect_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/rectangular_spec.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/conjugate.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/imaginary.rb
    MacRuby/trunk/spec/frozen/library/matrix/shared/rectangular.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range.rb
    MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range_matched.rb

Removed Paths:
-------------
    MacRuby/trunk/spec/frozen/core/random/marshal_dump_spec.rb
    MacRuby/trunk/spec/frozen/core/random/marshal_load_spec.rb

Modified: MacRuby/trunk/spec/frozen/core/array/combination_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/combination_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/array/combination_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -2,33 +2,45 @@
 
 describe "Array#combination" do
   ruby_version_is "1.8.7" do
+    before :each do
+      @array = [1, 2, 3, 4]
+    end
+
     it "returns an enumerator when no block is provided" do
-      [1, 2, 3, 4].combination(2).should be_an_instance_of(enumerator_class)
+      @array.combination(2).should be_an_instance_of(enumerator_class)
     end
 
     it "returns self when a block is given" do
-      a = [1, 2, 3, 4]
-      a.combination(2){}.should equal(a)
+      @array.combination(2){}.should equal(@array)
     end
 
     it "yields nothing for out of bounds length and return self" do
-      a = [1, 2, 3, 4]
-      a.combination(5).to_a.should == []
-      a.combination(-1).to_a.should == []
+      @array.combination(5).to_a.should == []
+      @array.combination(-1).to_a.should == []
     end
 
-    it "yields the excepted combinations" do
-      a = [1, 2, 3, 4]
-      a.combination(3).to_a.sort.should == [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
+    it "yields the expected combinations" do
+      @array.combination(3).to_a.sort.should == [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
     end
 
+    it "yields nothing if the argument is out of bounds" do
+      @array.combination(-1).to_a.should == []
+      @array.combination(5).to_a.should == []
+    end
+
+    it "yields a copy of self if the argument is the size of the receiver" do
+      r = @array.combination(4).to_a
+      r.should == [@array]
+      r[0].should_not equal(@array)
+    end
+
     it "yields [] when length is 0" do
-      [1,2,3].combination(0).to_a.should == [[]] # one combination of length 0
+      @array.combination(0).to_a.should == [[]] # one combination of length 0
       [].combination(0).to_a.should == [[]] # one combination of length 0
     end
     
     it "yields a partition consisting of only singletons" do
-      [1,2,3,4].combination(1).to_a.should == [[1],[2],[3],[4]]
+      @array.combination(1).to_a.should == [[1],[2],[3],[4]]
     end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/array/product_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/product_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/array/product_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -23,4 +23,28 @@
       [1, 2].product([]).should == []
     end
   end
+
+  ruby_version_is "1.9" do
+    describe "when given a block" do
+      it "yields all combinations in turn" do
+        acc = []
+        [1,2].product([3,4,5],[6,8]){|array| acc << array}
+        acc.should == [[1, 3, 6], [1, 3, 8], [1, 4, 6], [1, 4, 8], [1, 5, 6], [1, 5, 8],
+                       [2, 3, 6], [2, 3, 8], [2, 4, 6], [2, 4, 8], [2, 5, 6], [2, 5, 8]]
+
+        acc = []
+        [1,2].product([3,4,5],[],[6,8]){|array| acc << array}
+        acc.should be_empty
+      end
+
+      it "returns self" do
+        arr = [1,2]
+        arr.product([3,4,5],[6,8]){}.should equal(arr)
+        arr = []
+        arr.product([3,4,5],[6,8]){}.should equal(arr)
+        arr = [1,2]
+        arr.product([]){}.should equal(arr)
+      end
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/array/reject_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/reject_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/array/reject_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -23,13 +23,13 @@
     array.reject { true }.should == []
   end
 
-  not_compliant_on :rubinius, :ironruby do
+  not_compliant_on :ironruby do
     it "returns subclass instance on Array subclasses" do
       ArraySpecs::MyArray[1, 2, 3].reject { |x| x % 2 == 0 }.should be_kind_of(ArraySpecs::MyArray)
     end
   end
 
-  deviates_on :rubinius, :ironruby do
+  deviates_on :ironruby do
     it "does not return subclass instance on Array subclasses" do
       ArraySpecs::MyArray[1, 2, 3].reject { |x| x % 2 == 0 }.should be_kind_of(Array)
     end

Modified: MacRuby/trunk/spec/frozen/core/bignum/bit_and_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/bignum/bit_and_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/bignum/bit_and_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -12,11 +12,23 @@
     (@bignum & bignum_value(9921)).should == 9223372036854775809
 
     ((2*bignum_value) & 1).should == 0
+    ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616
+  end
+
+  it "returns self bitwise AND other when one operand is negative" do
     ((2*bignum_value) & -1).should == 18446744073709551616
     ((4*bignum_value) & -1).should == 36893488147419103232
-    ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616
+    (@bignum & -0xffffffffffffff5).should == 9223372036854775809
+    (@bignum & - at bignum).should == 1
+    (@bignum & -0x8000000000000000).should == 9223372036854775808
   end
 
+  it "returns self bitwise AND other when both operands are negative" do
+    (- at bignum & -0x4000000000000005).should == -13835058055282163717
+    (- at bignum & - at bignum).should == -9223372036854775813
+    (- at bignum & -0x4000000000000000).should == -13835058055282163712
+  end
+
   ruby_version_is ""..."1.9" do
     it "coerces Float arguments into Integers" do
       (@bignum & 3.4).should == 1

Modified: MacRuby/trunk/spec/frozen/core/bignum/bit_or_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/bignum/bit_or_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/bignum/bit_or_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -11,6 +11,18 @@
     (@bignum | bignum_value).should == 9223372036854775819
   end
 
+  it "returns self bitwise OR other when one operand is negative" do
+    (@bignum | -0x40000000000000000).should == -64563604257983430645
+    (@bignum | - at bignum).should == -1
+    (@bignum | -0x8000000000000000).should == -9223372036854775797
+  end
+
+  it "returns self bitwise OR other when both operands are negative" do
+    (- at bignum | -0x4000000000000005).should == -1
+    (- at bignum | - at bignum).should == -9223372036854775819
+    (- at bignum | -0x4000000000000000).should == -11
+  end
+
   ruby_version_is ""..."1.9" do
     it "coerces Float arguments to Integers" do
       (bignum_value | bignum_value(0xffff).to_f).should == 9223372036854841344

Modified: MacRuby/trunk/spec/frozen/core/bignum/bit_xor_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/bignum/bit_xor_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/bignum/bit_xor_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -11,6 +11,18 @@
     (@bignum ^ 14).should == 9223372036854775836
   end
 
+  it "returns self bitwise EXCLUSIVE OR other when one operand is negative" do
+    (@bignum ^ -0x40000000000000000).should == -64563604257983430638
+    (@bignum ^ - at bignum).should == -4
+    (@bignum ^ -0x8000000000000000).should == -18446744073709551598
+  end
+
+  it "returns self bitwise EXCLUSIVE OR other when both operands are negative" do
+    (- at bignum ^ -0x40000000000000000).should == 64563604257983430638
+    (- at bignum ^ - at bignum).should == 0
+    (- at bignum ^ -0x4000000000000000).should == 13835058055282163694
+  end
+
   ruby_version_is ""..."1.9" do
     it "coerces Float arguments into Integers" do
       (@bignum ^ 14.5).should == 9223372036854775836

Modified: MacRuby/trunk/spec/frozen/core/bignum/exponent_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/bignum/exponent_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/bignum/exponent_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -15,6 +15,12 @@
     lambda { @bignum ** "10" }.should raise_error
     lambda { @bignum ** :symbol }.should raise_error
   end
+
+  it "switch to a Float when the values is too big" do
+    flt = (@bignum ** @bignum)
+    flt.should be_kind_of(Float)
+    flt.infinite?.should == 1
+  end
   
   ruby_version_is '1.9' do
     it "returns a complex number when negative and raised to a fractional power" do

Modified: MacRuby/trunk/spec/frozen/core/encoding/aliases_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/encoding/aliases_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/encoding/aliases_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -32,8 +32,8 @@
       Encoding.aliases['external'].should == Encoding.default_external.name
     end
 
-    it "has a 'locale' key with the locale charmap encoding as its value" do
-      Encoding.aliases['locale'].should == Encoding.locale_charmap
+    it "has a 'locale' key and its value equals to the name of the encoding finded by the locale charmap" do
+      Encoding.aliases['locale'].should == Encoding.find(Encoding.locale_charmap).name
     end
 
     it "only contains valid aliased encodings" do

Modified: MacRuby/trunk/spec/frozen/core/encoding/locale_charmap_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/encoding/locale_charmap_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/encoding/locale_charmap_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -7,22 +7,31 @@
     end
 
     # FIXME: Get this working on Windows
-    platform_is :os => [:darwin, :linux] do
-      # FIXME: This spec fails on Mac OS X because it doesn't have ANSI_X3.4-1968 locale.
-      # FIXME: If ENV['LC_ALL'] is already set, it comes first.
-      it "returns a value based on the LANG environment variable" do
-        old_lang = ENV['LANG']
-        ENV['LANG'] = 'C'
+    platform_is :linux do
+      it "returns a value based on the LC_ALL environment variable" do
+        old_lc_all = ENV['LC_ALL']
+        ENV['LC_ALL'] = 'C'
         ruby_exe("print Encoding.locale_charmap").should == 'ANSI_X3.4-1968'
-        ENV['LANG'] = old_lang
+        ENV['LC_ALL'] = old_lc_all
       end
+    end
 
-      it "is unaffected by assigning to ENV['LANG'] in the same process" do
+    platform_is :bsd, :darwin do
+      it "returns a value based on the LC_ALL environment variable" do
+        old_lc_all = ENV['LC_ALL']
+        ENV['LC_ALL'] = 'C'
+        ruby_exe("print Encoding.locale_charmap").should == 'US-ASCII'
+        ENV['LC_ALL'] = old_lc_all
+      end
+    end
+
+    platform_is :os => [:bsd, :darwin, :linux] do
+      it "is unaffected by assigning to ENV['LC_ALL'] in the same process" do
         old_charmap = Encoding.locale_charmap
-        old_lang = ENV['LANG']
-        ENV['LANG'] = 'C'
+        old_lc_all = ENV['LC_ALL']
+        ENV['LC_ALL'] = 'C'
         Encoding.locale_charmap.should == old_charmap
-        ENV['LANG'] = old_lang
+        ENV['LC_ALL'] = old_lc_all
       end
     end
   end

Modified: MacRuby/trunk/spec/frozen/core/exception/errno_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/exception/errno_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/exception/errno_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -3,3 +3,14 @@
 describe "SystemCallError#errno" do
   it "needs to be reviewed for spec completeness"
 end
+
+describe "Errno::EAGAIN" do
+  # From http://jira.codehaus.org/browse/JRUBY-4747
+  it "is the same class as Errno::EWOULDBLOCK if they represent the same errno value" do
+    if Errno::EAGAIN::Errno == Errno::EWOULDBLOCK::Errno
+      Errno::EAGAIN.should == Errno::EWOULDBLOCK
+    else
+      Errno::EAGAIN.should_not == Errno::EWOULDBLOCK
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/core/fiber/resume_spec_disabled.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/fiber/resume_spec_disabled.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/fiber/resume_spec_disabled.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -13,17 +13,26 @@
       fiber2.resume.should == :fiber2
     end
 
-    ruby_bug "redmine #595", "1.9" do
-      it "executes the ensure clause" do
-        fib = Fiber.new{
-          begin
+    with_feature :fork do
+      ruby_bug "redmine #595", "1.9.2" do
+        it "executes the ensure clause" do
+          rd, wr = IO.pipe
+          if Kernel::fork then
+            wr.close
+            rd.read.should == "executed"
+            rd.close
+          else
+            rd.close
+            Fiber.new {
+              begin
+                Fiber.yield
+              ensure
+                wr.write "executed"
+              end
+            }.resume
             exit 0
-          rescue SystemExit
-          ensure
-            :ensure
           end
-        }
-        fib.resume.should == :ensure
+        end
       end
     end
   end

Modified: MacRuby/trunk/spec/frozen/core/file/basename_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/basename_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/file/basename_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -69,6 +69,11 @@
     File.basename("foo/").should == "foo"
   end
 
+  it "ignores a trailing directory seperator" do
+    File.basename("foo.rb/", '.rb').should == "foo"
+    File.basename("bar.rb///", '.*').should == "bar"
+  end
+
   it "return the basename for unix suffix" do
     File.basename("bar.c", ".c").should == "bar"
     File.basename("bar.txt", ".txt").should == "bar"

Modified: MacRuby/trunk/spec/frozen/core/file/expand_path_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/expand_path_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/file/expand_path_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -80,13 +80,22 @@
       File.expand_path('~/a','~/b').should == "#{ENV['HOME']}/a"
     end
 
-    not_compliant_on :macruby do
-      it "leaves multiple prefixed slashes untouched" do
-        File.expand_path('//').should == '//'
-        File.expand_path('////').should == '////'
+    not_compliant_on :rubinius, :macruby do
+      it "does not replace multiple '/' at the beginning of the path" do
+        File.expand_path('////some/path').should == "////some/path"
       end
     end
 
+    deviates_on :rubinius, :macruby do
+      it "replaces multiple '/' with a single '/' at the beginning of the path" do
+        File.expand_path('////some/path').should == "/some/path"
+      end
+    end
+
+    it "replaces multiple '/' with a single '/'" do
+      File.expand_path('/some////path').should == "/some/path"
+    end
+
     it "raises an ArgumentError if the path is not valid" do
       lambda { File.expand_path("~a_not_existing_user") }.should raise_error(ArgumentError)
     end
@@ -96,6 +105,10 @@
       File.expand_path("~#{ENV['USER']}/a").should == "#{ENV['HOME']}/a"
     end
 
+    it "does not expand ~ENV['USER'] when it's not at the start" do
+      File.expand_path("/~#{ENV['USER']}/a").should == "/~#{ENV['USER']}/a"
+    end
+
     it "expands ../foo with ~/dir as base dir to /path/to/user/home/foo" do
       File.expand_path('../foo', '~/dir').should == "#{ENV['HOME']}/foo"
     end

Added: MacRuby/trunk/spec/frozen/core/file/read_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/read_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/file/read_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/read', __FILE__)
+
+describe "File.read" do
+  it_behaves_like :file_read_directory, :read, File
+end

Added: MacRuby/trunk/spec/frozen/core/file/shared/read.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/shared/read.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/file/shared/read.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,21 @@
+require File.expand_path('../../../dir/fixtures/common', __FILE__)
+
+describe :file_read_directory, :shared => true do
+  platform_is :darwin, :linux do
+    it 'raises a Errno::EISDIR when passed a path that is a directory' do
+      lambda { @object.send(@method, ".") }.should raise_error(Errno::EISDIR)
+    end
+  end
+
+  platform_is :bsd do
+    it 'does not raises any exception when passed a path that is a directory' do
+      lambda { @object.send(@method, ".") }.should_not raise_error
+    end
+  end
+
+  platform_is :windows do
+    it 'raises a Errno::EACCES when passed a path that is a directory' do
+      lambda { @object.send(@method, ".") }.should raise_error(Errno::EACCES)
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/core/fixnum/exponent_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/fixnum/exponent_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/fixnum/exponent_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -12,6 +12,18 @@
     (2 ** 40).should == 1099511627776
   end
 
+  it "can raise 1 to a Bignum safely" do
+    big = bignum_value(4611686018427387904)
+    (1 ** big).should == 1
+  end
+
+  it "switches to a Float when the number is too big" do
+    big = bignum_value(4611686018427387904)
+    flt = (2 ** big)
+    flt.should be_kind_of(Float)
+    flt.infinite?.should == 1
+  end
+
   conflicts_with :Rational do
     ruby_version_is ""..."1.9" do
       ruby_bug "ruby-dev:32084", "1.8.6.138" do

Modified: MacRuby/trunk/spec/frozen/core/float/to_s_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/float/to_s_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/float/to_s_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -29,6 +29,18 @@
     end
   end
 
+  ruby_bug "#3273", "1.8.7" do
+    it "outputs the necessary number of digits to represent the float" do
+      0.21611564636388508.to_s.to_f.should == 0.21611564636388508
+    end
+  end
+
+  ruby_bug "#3273", "1.8" do
+    it "outputs a minimal form to represent the float" do
+      0.56.to_s.should == "0.56"
+    end
+  end
+
   platform_is_not :openbsd do
     it "returns the correct values for -0.0" do
       -0.0.to_s.should == "-0.0"

Modified: MacRuby/trunk/spec/frozen/core/hash/eql_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/hash/eql_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/hash/eql_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -15,4 +15,5 @@
   ruby_version_is '1.9' do
     it_behaves_like :hash_eql_additional_more, :eql?
   end
+
 end

Modified: MacRuby/trunk/spec/frozen/core/hash/equal_value_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/hash/equal_value_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/hash/equal_value_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -8,6 +8,11 @@
   it_behaves_like :hash_eql_additional_more, :==
 
   it "compares values with == semantics" do
-    new_hash("x" => 1.0).should == new_hash("x" => 1)
+    l_val = mock("left")
+    r_val = mock("right")
+
+    l_val.should_receive(:==).with(r_val).and_return(true)
+
+    (new_hash(1 => l_val) == new_hash(1 => r_val)).should be_true
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/hash/keep_if_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/hash/keep_if_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/hash/keep_if_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,7 +1,31 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/iteration', __FILE__)
 
 ruby_version_is "1.9" do
   describe "Hash#keep_if" do
-    it "needs to be reviewed for spec completeness"
+    it "yields two arguments: key and value" do
+      all_args = []
+      new_hash(1 => 2, 3 => 4).keep_if { |*args| all_args << args }
+      all_args.should == [[1, 2], [3, 4]]
+    end
+
+    it "keeps every entry for which block is true and returns self" do
+      h = new_hash(:a => 1, :b => 2, :c => 3, :d => 4)
+      h.keep_if { |k,v| v % 2 == 0 }.should equal(h)
+      h.should == new_hash(:b => 2, :d => 4)
+    end
+
+    it "returns self even if unmodified" do
+      h = new_hash(1 => 2, 3 => 4)
+      h.keep_if { true }.should equal(h)
+    end
+
+    it "raises an RuntimeError if called on a frozen instance" do
+      lambda { HashSpecs.frozen_hash.keep_if { true } }.should raise_error(RuntimeError)
+      lambda { HashSpecs.empty_frozen_hash.keep_if { false } }.should raise_error(RuntimeError)
+    end
+
+    it_behaves_like(:hash_iteration_no_block, :keep_if)
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/hash/select_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/hash/select_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/hash/select_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -65,6 +65,33 @@
 
 ruby_version_is "1.9" do
   describe "Hash#select!" do
-    it "needs to be reviewed for spec completeness"
+    before(:each) do
+      @hsh = new_hash(1 => 2, 3 => 4, 5 => 6)
+      @empty = new_hash
+    end
+
+    it "is equivalent to keep_if if changes are made" do
+      new_hash(:a => 2).select! { |k,v| v <= 1 }.should ==
+        new_hash(:a => 2).keep_if { |k, v| v <= 1 }
+
+      h = new_hash(1 => 2, 3 => 4)
+      all_args_select = []
+      all_args_keep_if = []
+      h.dup.select! { |*args| all_args_select << args }
+      h.dup.keep_if { |*args| all_args_keep_if << args }
+      all_args_select.should == all_args_keep_if
+    end
+
+    it "returns nil if no changes were made" do
+      new_hash(:a => 1).select! { |k,v| v <= 1 }.should == nil
+    end
+
+    it "raises a RuntimeError if called on a frozen instance that is modified" do
+      lambda { HashSpecs.empty_frozen_hash.select! { false } }.should raise_error(RuntimeError)
+    end
+
+    it "raises a RuntimeError if called on a frozen instance that would not be modified" do
+      lambda { HashSpecs.frozen_hash.select! { true } }.should raise_error(RuntimeError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/hash/shared/eql.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/hash/shared/eql.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/hash/shared/eql.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -186,6 +186,19 @@
     a[0].tainted?.should be_true
     a[1].tainted?.should be_true
   end
+
+  # The specs above all pass in 1.8.6p287 for Hash#== but not Hash#eql
+  # except this one, which does not pass for Hash#==.
+  ruby_version_is "1.8.7" do
+    it "compares the values in self to values in other hash" do
+      l_val = mock("left")
+      r_val = mock("right")
+
+      l_val.should_receive(:eql?).with(r_val).and_return(true)
+
+      new_hash(1 => l_val).eql?(new_hash(1 => r_val)).should be_true
+    end
+  end
 end
 
 describe :hash_eql_additional_more, :shared => true do

Modified: MacRuby/trunk/spec/frozen/core/io/copy_stream_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/copy_stream_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/io/copy_stream_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -4,4 +4,47 @@
   describe "IO.copy_stream" do
     it "needs to be reviewed for spec completeness"
   end
+
+  describe "IO.copy_stream" do
+    before :each do
+      # TODO: multi-line content (esp. on Windows!)
+      @content = "one-two-three"
+
+      @filename_src = tmp("source")
+      touch(@filename_src) { |f| f.write(@content) }
+      @io_src = new_io(@filename_src, "rb")
+
+      @filename_dest = tmp("destination")
+      # TODO: new_io doesn't work here due to bug in mspsec
+      # @io_dest = new_io(@filename_dest, "w")
+      @io_dest = File.open(@filename_dest, "wb")
+    end
+
+    after :each do
+      @io_src.close unless @io_src.closed?
+      @io_dest.close unless @io_dest.closed?
+      File.unlink @filename_src
+      File.unlink @filename_dest
+    end
+
+    it "copies from an IO instance to a named file" do
+      IO.copy_stream(@io_src, @filename_dest).should == @content.size
+      File.read(@filename_dest).should == @content
+    end
+
+    it "copies from a named file to a named file" do
+      IO.copy_stream(@filename_src, @filename_dest).should == @content.size
+      File.read(@filename_dest).should == @content
+    end
+
+    it "copies from a named file to an IO instance" do
+      IO.copy_stream(@filename_src, @io_dest).should == @content.size
+      File.read(@filename_dest).should == @content
+    end
+
+    it "copies from an IO instance to an IO instance" do
+      IO.copy_stream(@io_src, @io_dest).should == @content.size
+      File.read(@filename_dest).should == @content
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -106,4 +106,26 @@
       end
     end
   end
+
+  describe "when the filename starts with |" do
+    it "gets data from the standard out of the subprocess" do
+      IO.foreach("|sh -c 'echo hello;echo line2'") { |l| ScratchPad << l }
+      ScratchPad.recorded.should == ["hello\n", "line2\n"]
+    end
+
+    it "gets data from a fork when passed -" do
+      parent_pid = $$
+
+      ret = IO.foreach("|-") { |l| ScratchPad << l; true }
+
+      if $$ == parent_pid
+        ScratchPad.recorded.should == ["hello\n", "from a fork\n"]
+      else # child
+        puts "hello"
+        puts "from a fork"
+        exit!
+      end
+    end
+  end
+
 end

Modified: MacRuby/trunk/spec/frozen/core/io/popen_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/popen_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/io/popen_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,62 +1,88 @@
 require File.expand_path('../../../spec_helper', __FILE__)
 
-describe "IO::popen" do
-  # NOTE: cause Errno::EBADF on 1.8.6
-  #ruby_bug "#", "1.8.6" do
-    it "reads from a read-only pipe" do
-      IO.popen("echo foo", "r") do |io|
-        io.read.should == "foo\n"
+describe "IO.popen" do
+  it "reads from a read-only pipe" do
+    IO.popen("echo foo", "r") do |io|
+      io.read.should == "foo\n"
 
-        lambda { io.write('foo').should }.should \
-          raise_error(IOError, 'not opened for writing')
+      lambda {
+        io.write('foo')
+      }.should raise_error(IOError, 'not opened for writing')
+    end
+  end
+
+  platform_is_not :windows do
+    it "reads and writes to a read/write pipe" do
+      data = IO.popen("cat", "r+") do |io|
+        io.write("bar")
+        io.read 3
       end
+
+      data.should == "bar"
     end
 
-    platform_is_not :windows do
-      it "reads and writes to a read/write pipe" do
-        data = IO.popen("cat", "r+") do |io|
-          io.write("bar")
-          io.read 3
+    it "writes to a write-only pipe" do
+      begin
+        tmp_file = tmp "IO_popen_spec_#{$$}"
+
+        data = IO.popen "cat > #{tmp_file}", 'w' do |io|
+          io.write 'bar'
+
+          lambda { io.read.should }.should \
+            raise_error(IOError, 'not opened for reading')
         end
+        system 'sync' # sync to flush writes for File.read below
 
-        data.should == "bar"
+        File.read(tmp_file).should == 'bar'
+
+      ensure
+        File.unlink tmp_file if File.exist? tmp_file
       end
+    end
+  end
 
-      it "writes to a write-only pipe" do
-        begin
-          tmp_file = tmp "IO_popen_spec_#{$$}"
+  it "returns the value of the block when passed a block" do
+    val = IO.popen("yes", "r") do |i|
+      :hello
+    end
 
-          data = IO.popen "cat > #{tmp_file}", 'w' do |io|
-            io.write 'bar'
+    val.should == :hello
+  end
 
-            lambda { io.read.should }.should \
-              raise_error(IOError, 'not opened for reading')
-          end
-          system 'sync' # sync to flush writes for File.read below
+  it "closes the IO when used with a block" do
+    io = IO.popen("yes", "r") do |i|
+      i
+    end
 
-          File.read(tmp_file).should == 'bar'
+    io.closed?.should be_true
+  end
 
-        ensure
-          File.unlink tmp_file if File.exist? tmp_file
-        end
-      end
+  it "allows the IO to be closed inside the block" do
+    io = IO.popen('yes', 'r') do |i|
+      i.close
+      i
     end
 
-    it "allows the io to be closed inside the block" do
-      io = IO.popen('yes', 'r') do |io|
-        io.close
+    io.closed?.should be_true
+  end
 
-        io.closed?.should == true
+  it "returns the IO if no block given" do
+    io = IO.popen("yes", "r")
+    io.closed?.should be_false
 
-        io
-      end
+    io.read(1).should == "y"
+    io.close
+  end
 
-      io.closed?.should == true
+  it "starts returns a forked process if the command is -" do
+    io = IO.popen("-")
+
+    if io # parent
+      io.gets.should == "hello from child\n"
+      io.close
+    else # child
+      puts "hello from child"
+      exit!
     end
-  #end
+  end
 end
-
-
-describe "IO.popen" do
-  it "needs to be reviewed for spec completeness"
-end

Modified: MacRuby/trunk/spec/frozen/core/io/read_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/read_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/io/read_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -66,6 +66,32 @@
   end
 end
 
+describe "IO.read from a pipe" do
+  it "runs the rest as a subprocess and returns the standard output" do
+    IO.read("|sh -c 'echo hello'").should == "hello\n"
+  end
+
+  it "opens a pipe to a fork if the rest is -" do
+    str = IO.read("|-")
+    if str # parent
+      str.should == "hello from child\n"
+    else #child
+      puts "hello from child"
+      exit!
+    end
+  end
+
+  it "reads only the specified number of bytes requested" do
+    IO.read("|sh -c 'echo hello'", 1).should == "h"
+  end
+
+  it "raises Errno::ESPIPE if passed an offset" do
+    lambda {
+      IO.read("|sh -c 'echo hello'", 1, 1)
+    }.should raise_error(Errno::ESPIPE)
+  end
+end
+
 describe "IO.read on an empty file" do
   before :each do
     @fname = tmp("io_read_empty.txt")
@@ -107,6 +133,16 @@
     @io.read(4).should == '7890'
   end
 
+  it "clears the output buffer if there is nothing to read" do
+    @io.pos = 10
+
+    buf = 'non-empty string'
+
+    @io.read(10, buf).should == nil
+
+    buf.should == ''
+  end
+
   it "consumes zero bytes when reading zero bytes" do
     pre_pos = @io.pos
 

Modified: MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -97,6 +97,25 @@
       @io.readlines(obj).should == IOSpecs.lines_r_separator
     end
   end
+
+  describe "when passed a string that starts with a |" do
+    it "gets data from the standard out of the subprocess" do
+      lines = IO.readlines("|sh -c 'echo hello;echo line2'")
+      lines.should == ["hello\n", "line2\n"]
+    end
+
+    it "gets data from a fork when passed -" do
+      lines = IO.readlines("|-")
+
+      if lines # parent
+        lines.should == ["hello\n", "from a fork\n"]
+      else
+        puts "hello"
+        puts "from a fork"
+        exit!
+      end
+    end
+  end
 end
 
 describe "IO#readlines" do

Modified: MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -93,7 +93,7 @@
   ruby_version_is "1.9" do
     it "returns the definition trace of a block when evaluated in a Proc binding" do
       stack = CallerFixture.caller_of(CallerFixture.block)
-      stack[0].should == "(eval):1:in `<top (required)>'"
+      stack[0].should =~ /caller_fixture1\.rb:4:in `<top \(required\)>'/
       stack[1].should =~ /caller_fixture2\.rb:18:in `eval'/
       stack[2].should =~ /caller_fixture2\.rb:18:in `caller_of'/
       stack[3].should =~ /caller_spec\.rb:95:in `block \(3 levels\) in <top \(required\)>'/
@@ -101,7 +101,7 @@
 
     it "returns the definition trace of a Proc" do
       stack = CallerFixture.caller_of(CallerFixture.example_proc)
-      stack[0].should == "(eval):1:in `example_proc'"
+      stack[0].should =~ /caller_fixture1\.rb:14:in `example_proc'/
       stack[1].should =~ /caller_fixture2\.rb:18:in `eval'/
       stack[2].should =~ /caller_fixture2\.rb:18:in `caller_of'/
       stack[3].should =~ /caller_spec\.rb:103:in `block \(3 levels\) in <top \(required\)>'/
@@ -119,7 +119,7 @@
     # the correct behaviour
     it "returns the correct definition line for a complex Proc trace" do
       stack = CallerFixture.caller_of(CallerFixture.entry_point)
-      stack[0].should == "(eval):1:in `third'"
+      stack[0].should =~ /caller_fixture1\.rb:29:in `third'/
       stack[1].should =~ /caller_fixture2\.rb:18:in `eval'/
       stack[2].should =~ /caller_fixture2\.rb:18:in `caller_of'/
       stack[3].should =~ /caller_spec.rb:121:in `block \(3 levels\) in <top \(required\)>'/

Modified: MacRuby/trunk/spec/frozen/core/kernel/clone_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/clone_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/clone_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -44,4 +44,10 @@
       CLONE.should == :clone
     end
   end
+
+  it "raises TypeError when called on nil" do
+    lambda {
+      nil.clone
+    }.should raise_error(TypeError)
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/eval_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -252,28 +252,15 @@
     end
   end
 
-  ruby_version_is ""..."1.9" do
-    it "uses the filename of the binding if none is provided" do
-      eval("__FILE__").should == "(eval)"
-      eval("__FILE__", binding).should == __FILE__
-      eval("__FILE__", binding, "success").should == "success"
-      eval("eval '__FILE__', binding").should == "(eval)"
-      eval("eval '__FILE__', binding", binding).should == __FILE__
-      eval("eval '__FILE__', binding", binding, 'success').should == 'success'
-    end
+  it "uses the filename of the binding if none is provided" do
+    eval("__FILE__").should == "(eval)"
+    eval("__FILE__", binding).should == __FILE__
+    eval("__FILE__", binding, "success").should == "success"
+    eval("eval '__FILE__', binding").should == "(eval)"
+    eval("eval '__FILE__', binding", binding).should == __FILE__
+    eval("eval '__FILE__', binding", binding, 'success').should == 'success'
   end
 
-  ruby_version_is "1.9" do
-    it "uses a filename of (eval) if none is provided" do
-      eval("__FILE__").should == "(eval)"
-      eval("__FILE__", binding).should == "(eval)"
-      eval("__FILE__", binding, "success").should == "success"
-      eval("eval '__FILE__', binding").should == "(eval)"
-      eval("eval '__FILE__', binding", binding).should == "(eval)"
-      eval("eval '__FILE__', binding", binding, 'success').should == '(eval)'
-    end
-  end
-
   # Found via Rubinius bug github:#149
   it "should not alter the value of __FILE__ in the binding" do
     first_time =  EvalSpecs.call_eval

Modified: MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -52,6 +52,18 @@
     def juu_san; end
   end
 
+  class PrivateSup
+    def public_in_sub
+    end
+
+    private :public_in_sub
+  end
+
+  class PublicSub < PrivateSup
+    def public_in_sub
+    end
+  end
+
   class A
     # 1.9 as Kernel#public_method, so we don't want this one to clash:
     def pub_method; :public_method; end

Modified: MacRuby/trunk/spec/frozen/core/kernel/lambda_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/lambda_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/lambda_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -5,15 +5,72 @@
 # The functionality of lambdas is specified in core/proc
 
 describe "Kernel.lambda" do
+  it_behaves_like(:kernel_lambda, :lambda)
+  it_behaves_like(:kernel_lambda_return_like_method, :lambda)
+
   it "is a private method" do
     Kernel.should have_private_instance_method(:lambda)
   end
 
-  it_behaves_like(:kernel_lambda, :lambda)
-  it_behaves_like(:kernel_lambda_return_like_method, :lambda)
-  
+  ruby_version_is ""..."1.9" do
+    it "does not check the arity of the call when no args are specified" do
+      l = lambda { :called }
+      l.call.should == :called
+
+      # Check one and two args because the block argument handling changes
+      # at two arguments.
+      l.call(1).should == :called
+      l.call(1, 2).should == :called
+    end
+
+    it "does not check the arity when 1 arg is specified" do
+      l = lambda { |a| :called }
+
+      l.call.should == :called
+      l.call(1).should == :called
+      l.call(1, 2).should == :called
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "checks the arity of the call when no args are specified" do
+      l = lambda { :called }
+      l.call.should == :called
+
+      lambda { l.call(1) }.should raise_error(ArgumentError)
+      lambda { l.call(1, 2) }.should raise_error(ArgumentError)
+    end
+
+    it "checks the arity when 1 arg is specified" do
+      l = lambda { |a| :called }
+      l.call(1).should == :called
+
+      lambda { l.call }.should raise_error(ArgumentError)
+      lambda { l.call(1, 2) }.should raise_error(ArgumentError)
+    end
+  end
+
+  it "accepts 0 arguments when used with ||" do
+    lambda {
+      lambda { || }.call(1)
+    }.should raise_error(ArgumentError)
+  end
+
+  it "strictly checks the arity when 0 or 2..inf args are specified" do
+    l = lambda { |a,b| }
+
+    lambda {
+      l.call
+    }.should raise_error(ArgumentError)
+
+    lambda {
+      l.call(1)
+    }.should raise_error(ArgumentError)
+
+    lambda {
+      l.call(1,2)
+    }.should_not raise_error(ArgumentError)
+  end
+
 end
 
-describe "Kernel#lambda" do
-  it "needs to be reviewed for spec completeness"
-end

Modified: MacRuby/trunk/spec/frozen/core/kernel/load_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/load_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/load_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -35,6 +35,6 @@
   it_behaves_like :kernel_require_basic, :load, Kernel
 end
 
-describe "Kernel#load" do
+describe "Kernel.load" do
   it_behaves_like :kernel_load, :load, Kernel
 end

Modified: MacRuby/trunk/spec/frozen/core/kernel/private_methods_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/private_methods_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/private_methods_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -9,14 +9,22 @@
       m = KernelSpecs::Methods.new.private_methods(false)
       m.should include("juu_shi")
     end
-    
+
     it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do
       m = (KernelSpecs::Methods.private_methods(false) & KernelSpecs::Methods.private_methods)
-      
+
       m.should include("shichi")
       m = KernelSpecs::Methods.new.private_methods
       m.should include('juu_shi')
     end
+
+    it "respects the class hierarchy when decided what is private" do
+      m = KernelSpecs::PrivateSup.new
+      m.private_methods.should include("public_in_sub")
+
+      m = KernelSpecs::PublicSub.new
+      m.private_methods.should_not include("public_in_sub")
+    end
   end
 
   ruby_version_is "1.9" do
@@ -26,10 +34,10 @@
       m = KernelSpecs::Methods.new.private_methods(false)
       m.should include(:juu_shi)
     end
-    
+
     it "returns a list of the names of privately accessible methods in the object and its ancestors and mixed-in modules" do
       m = (KernelSpecs::Methods.private_methods(false) & KernelSpecs::Methods.private_methods)
-      
+
       m.should include(:shichi)
       m = KernelSpecs::Methods.new.private_methods
       m.should include(:juu_shi)

Modified: MacRuby/trunk/spec/frozen/core/kernel/public_methods_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/public_methods_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/public_methods_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -19,14 +19,14 @@
 
   ruby_version_is "1.9" do
     it "returns a list of the names of publicly accessible methods in the object" do
-      KernelSpecs::Methods.public_methods(false).sort.should include(:allocate, :hachi,
-        :ichi, :juu, :juu_ni, :new, :roku, :san, :shi, :superclass)
+      KernelSpecs::Methods.public_methods(false).sort.should include(:hachi,
+        :ichi, :juu, :juu_ni, :roku, :san, :shi)
       KernelSpecs::Methods.new.public_methods(false).sort.should include(:juu_san, :ni)
     end
     
     it "returns a list of the names of publicly accessible methods in the object and its ancestors and mixed-in modules" do
       (KernelSpecs::Methods.public_methods(false) & KernelSpecs::Methods.public_methods).sort.should include(
-        :allocate, :hachi, :ichi, :juu, :juu_ni, :new, :roku, :san, :shi, :superclass)
+        :hachi, :ichi, :juu, :juu_ni, :roku, :san, :shi)
       m = KernelSpecs::Methods.new.public_methods
       m.should include(:ni, :juu_san)
     end

Modified: MacRuby/trunk/spec/frozen/core/kernel/rand_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/rand_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/rand_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -5,34 +5,60 @@
   it "is a private method" do
     Kernel.should have_private_instance_method(:rand)
   end
-  
-  it "returns a random float less than 1 if no max argument is passed" do
-    rand.kind_of?(Float).should == true
+
+  it "returns a float if no argument is passed" do
+    rand.should be_kind_of(Float)
   end
 
-  it "returns a random int or bigint less than the argument for an integer argument" do
-    rand(77).kind_of?(Integer).should == true
+  it "returns an integer for an integer argument" do
+    rand(77).should be_kind_of(Integer)
   end
 
-  it "returns a random integer less than the argument casted to an int for a float argument greater than 1" do
-    rand(1.3).kind_of?(Integer).should == true
+  it "returns an integer for a float argument greater than 1" do
+    rand(1.3).should be_kind_of(Integer)
   end
 
-  it "returns a random float less than 1 for float arguments less than 1" do
-    rand(0.01).kind_of?(Float).should == true
+  it "returns a float for an argument between -1 and 1" do
+    rand(-0.999).should be_kind_of(Float)
+    rand(-0.01).should be_kind_of(Float)
+    rand(0).should be_kind_of(Float)
+    rand(0.01).should be_kind_of(Float)
+    rand(0.999).should be_kind_of(Float)
   end
 
+  it "ignores the sign of the argument" do
+    [0, 1, 2, 3].should include(rand(-4))
+  end
+
   it "never returns a value greater or equal to 1.0 with no arguments" do
     1000.times do
-      (rand < 1.0).should == true
+      (0...1.0).should include(rand)
     end
   end
 
   it "never returns a value greater or equal to any passed in max argument" do
     1000.times do
-      (rand(100) < 100).should == true
+      (0...100).to_a.should include(rand(100))
     end
   end
+
+  ruby_version_is ""..."1.9" do
+    it "calls to_i on its argument" do
+      l = mock('limit')
+      l.should_receive(:to_i).and_return 7
+
+      rand l
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "calls to_int on its argument" do
+      l = mock('limit')
+      l.should_receive(:to_int).and_return 7
+
+      rand l
+    end
+  end
 end
 
 describe "Kernel#rand" do

Modified: MacRuby/trunk/spec/frozen/core/kernel/shared/lambda.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/shared/lambda.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/shared/lambda.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -10,7 +10,7 @@
 end
 
 describe :kernel_lambda_return_like_method, :shared => true do
-  it "returns from the #{@method} itself; not the creation site of the #{@method}" do
+  it "returns from the #{@method} itself, not the creation site of the #{@method}" do
     @reached_end_of_method = nil
     def test
       send(@method) { return }.call

Modified: MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -465,17 +465,16 @@
       ENV["HOME"] = @env_home
     end
 
-    ruby_version_is "".."1.9" do
-      it "does not perform tilde expansion before storing paths in $LOADED_FEATURES" do
+    ruby_bug "#3171", "1.8.7.249" do
+      it "performs tilde expansion on a .rb file before storing paths in $LOADED_FEATURES" do
+        path = File.expand_path("load_fixture.rb", CODE_LOADING_DIR)
         @object.require("~/load_fixture.rb").should be_true
-        $LOADED_FEATURES.should == ["~/load_fixture.rb"]
+        $LOADED_FEATURES.should == [path]
       end
-    end
 
-    ruby_version_is "1.9" do
-      it "performs tilde expansion before storing paths in $LOADED_FEATURES" do
+      it "performs tilde expansion on a non-extensioned file before storing paths in $LOADED_FEATURES" do
         path = File.expand_path("load_fixture.rb", CODE_LOADING_DIR)
-        @object.require("~/load_fixture.rb").should be_true
+        @object.require("~/load_fixture").should be_true
         $LOADED_FEATURES.should == [path]
       end
     end

Added: MacRuby/trunk/spec/frozen/core/kernel/singleton_class_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/singleton_class_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/kernel/singleton_class_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,30 @@
+ruby_version_is "1.9" do
+  describe "Kernel#singleton_class" do
+    it "returns class extended from an object" do
+      x = Object.new
+      xs = class << x; self; end
+      xs.should == x.singleton_class
+    end
+    
+    it "returns NilClass for nil" do
+      nil.singleton_class.should == NilClass
+    end
+    
+    it "returns TrueClass for true" do
+      true.singleton_class.should == TrueClass
+    end
+    
+    it "returns FalseClass for false" do
+      false.singleton_class.should == FalseClass
+    end
+    
+    it "raises TypeError for Fixnum" do
+      lambda { 123.singleton_class }.should raise_error(TypeError)
+    end
+    
+    it "raises TypeError for Symbol" do
+      lambda { :foo.singleton_class }.should raise_error(TypeError)
+    end
+    
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/core/kernel/spawn_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/spawn_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/spawn_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -4,6 +4,7 @@
   describe "Kernel.spawn" do
     before(:each) do
       @f = tmp("spawn-#{rand}-#{$$}")
+      @ruby = MSpecScript.config[:target]
     end
 
     after(:each) do
@@ -12,34 +13,34 @@
 
     it "executes the given command" do
       File.exists?(@f).should be_false
-      pid = spawn("ruby -e 'print :spawn' >#{@f}")
+      pid = spawn("#{@ruby} -e 'print :spawn' >#{@f}")
       Process.wait pid
       File.exists?(@f).should be_true
       File.read(@f).should == "spawn"
     end
 
     it "executes the given command as a new process" do
-      pid = spawn("ruby -v >#{@f}")
+      pid = spawn("#{@ruby} -v >#{@f}")
       Process.wait pid
       pid.should_not == Process.pid
     end
 
     it "returns the process ID of the new process as a Fixnum" do
-      pid = spawn("ruby -v >#{@f}")
+      pid = spawn("#{@ruby} -v >#{@f}")
       Process.wait pid
       pid.should be_an_instance_of(Fixnum)
     end
 
     it "returns immediately" do
       start = Time.now
-      pid = spawn('ruby -e "sleep 10"')
+      pid = spawn("#{@ruby} -e 'sleep 10'")
       (Time.now - start).should < 1
       Process.kill :KILL, pid
       Process.wait pid
     end
 
     it "sets the child's environment variables according to a supplied hash" do
-      pid = spawn({"spawn_of_ruby" => 'yes'}, "ruby -e 'print ENV[\"spawn_of_ruby\"]' >#{@f}")
+      pid = spawn({"spawn_of_ruby" => 'yes'}, "#{@ruby} -e 'print ENV[\"spawn_of_ruby\"]' >#{@f}")
       Process.wait pid
       File.exists?(@f).should be_true
       File.read(@f).should == "yes"
@@ -47,7 +48,7 @@
 
     platform_is_not :windows do
       it "joins the current process group by default" do
-        pid = spawn("ruby -e 'print Process.getpgid(Process.pid)' >#{@f}")
+        pid = spawn("#{@ruby} -e 'print Process.getpgid(Process.pid)' >#{@f}")
         Process.wait pid
         File.exists?(@f).should be_true
         pgid = File.read(@f).to_i
@@ -55,7 +56,7 @@
       end
 
       it "joins a new process group if :pgroup => true" do
-        pid = spawn("ruby -e 'print Process.getpgid(Process.pid)' >#{@f}", {:pgroup => true})
+        pid = spawn("#{@ruby} -e 'print Process.getpgid(Process.pid)' >#{@f}", {:pgroup => true})
         Process.wait pid
         File.exists?(@f).should be_true
         pgid = File.read(@f).to_i
@@ -64,7 +65,7 @@
     end
 
     it "uses the current working directory as its working directory" do
-      pid = spawn("ruby -e 'print Dir.pwd' >#{@f}")
+      pid = spawn("#{@ruby} -e 'print Dir.pwd' >#{@f}")
       Process.wait pid
       File.exists?(@f).should be_true
       File.read(@f).should == Dir.pwd
@@ -73,26 +74,83 @@
     it "uses the given working directory if :chdir => dir is supplied" do
       dir = File.expand_path('../')
       dir.should_not == Dir.pwd
-      pid = spawn("ruby -e 'print Dir.pwd' >#{@f}", {:chdir => dir})
+      pid = spawn("#{@ruby} -e 'print Dir.pwd' >#{@f}", {:chdir => dir})
       Process.wait pid
       File.exists?(@f).should be_true
       File.read(@f).should == dir
     end
 
-    it "redirects STDERR to the given file descriptior if if :err => Fixnum" do
-      file = File.open(@f,'w')
+    it "redirects STDOUT to the given file descriptior if :out => Fixnum" do
+      file = File.open(@f, 'w')
       fd = file.fileno
-      pid = spawn("ruby -e 'warn(:glark)'", {:err => fd})
+      pid = spawn("#{@ruby} -e 'print(:glark)'", {:out => fd})
       Process.wait pid
+      file.close
       File.read(@f).should =~ /glark/
+    end
+
+    it "redirects STDOUT to the given file if :out => String" do
+      pid = spawn("#{@ruby} -e 'print(:glark)'", {:out => @f})
+      Process.wait pid
+      File.read(@f).should =~ /glark/
+    end
+
+    it "redirects STDOUT to the given file if :out => IO" do
+      r, w = IO.pipe
+      pid = spawn("#{@ruby} -e 'print(:glark)'", {:out => w})
+      Process.wait pid
+      w.close
+      r.read.should =~ /glark/
+    end
+
+    it "redirects STDERR to the given file descriptior if :err => Fixnum" do
+      file = File.open(@f, 'w')
+      fd = file.fileno
+      pid = spawn("#{@ruby} -e 'warn(:glark)'", {:err => fd})
+      Process.wait pid
+      File.read(@f).should =~ /glark/
       file.close
     end
 
     it "redirects STDERR to the given file if :err => String" do
-      pid = spawn("ruby -e 'warn(:glark)'", {:err => @f})
+      pid = spawn("#{@ruby} -e 'warn(:glark)'", {:err => @f})
       Process.wait pid
       File.read(@f).should =~ /glark/
     end
 
+    it "redirects STDOUT to the given file if :err => IO" do
+      r, w = IO.pipe
+      pid = spawn("#{@ruby} -e 'warn(:glark)'", {:err => w})
+      Process.wait pid
+      w.close
+      r.read.should =~ /glark/
+    end
+
+    it "redirects both STDERR and STDOUT to the given file descriptior, name or IO" do
+      file = File.open(@f, 'w')
+      pid = spawn("#{@ruby} -e 'print(:glark); warn(:bang)'", {[:out, :err] => file.fileno})
+      Process.wait pid
+      file.close
+      File.read(@f).should =~ /glark/
+      File.read(@f).should =~ /bang/
+
+      pid = spawn("#{@ruby} -e 'print(:glark); warn(:bang)'", {[:out, :err] => @f})
+      Process.wait pid
+      File.read(@f).should =~ /glark/
+      File.read(@f).should =~ /bang/
+
+      r, w = IO.pipe
+      pid = spawn("#{@ruby} -e 'print(:glark); warn(:bang)'", {[:out, :err] => w})
+      Process.wait pid
+      w.close
+      tmp = r.read
+      tmp.should =~ /glark/
+      tmp.should =~ /bang/
+    end
+
+    it 'generates a process of a command based on the given set of strings, regarding the first as the command and the others as the arguments' do
+      Process.wait spawn('echo', 'a b', :out => @f)
+      File.read(@f).should == "a b\n"
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/kernel/srand_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/srand_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/srand_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -5,13 +5,13 @@
   it "is a private method" do
     Kernel.should have_private_instance_method(:srand)
   end
-  
-  it "srand should return the previous seed value" do
+
+  it "returns the previous seed value" do
     srand(10)
     srand(20).should == 10
   end
 
-  it "srand should seed the RNG correctly and repeatably" do
+  it "seeds the RNG correctly and repeatably" do
     srand(10)
     x = rand
     srand(10)
@@ -23,10 +23,37 @@
     srand.should_not == 0
   end
 
-  it "calls #to_i on number" do
+  it "accepts and uses a seed of 0" do
+    srand(0)
+    srand.should == 0
+  end
+
+  it "accepts a negative seed" do
+    srand(-17)
+    srand.should == -17
+  end
+
+  it "accepts a Bignum as a seed" do
+    srand(0x12345678901234567890)
+    srand.should == 0x12345678901234567890
+  end
+
+  it "calls #to_int on seed" do
     srand(3.8)
     srand.should == 3
+
+    s = mock('seed')
+    s.should_receive(:to_int).and_return 0
+    srand(s)
   end
+
+  it "raises a TypeError when passed nil" do
+    lambda { srand(nil) }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError when passed a String" do
+    lambda { srand("7") }.should raise_error(TypeError)
+  end
 end
 
 describe "Kernel#srand" do

Modified: MacRuby/trunk/spec/frozen/core/kernel/system_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/system_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/kernel/system_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -2,6 +2,9 @@
 require File.expand_path('../fixtures/classes', __FILE__)
 
 describe "Kernel#system" do
+  before do
+    @ruby = MSpecScript.config[:target]
+  end
 
   it "can run basic things that exist" do
     begin
@@ -67,12 +70,12 @@
   end
 
   it "expands shell variables when given a single string argument" do
-    result = system("ruby #{@helper_script} #{@shell_var} foo")
+    result = system("#{@ruby} #{@helper_script} #{@shell_var} foo")
     result.should be_true
   end
   
   it "does not expand shell variables when given multiples arguments" do
-    result = system("ruby", @helper_script, @shell_var, "foo")
+    result = system("#{@ruby}", @helper_script, @shell_var, "foo")
     result.should be_false
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/marshal/fixtures/marshal_data.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/marshal/fixtures/marshal_data.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/marshal/fixtures/marshal_data.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -140,6 +140,15 @@
 Struct.new "Useful", :a, :b
 
 module MarshalSpec
+  def self.random_data
+    randomizer = Random.new(42)
+    1000.times{randomizer.rand} # Make sure we exhaust his first state of 624 random words
+    dump_data = File.binread(fixture(__FILE__, 'random.dump'))
+    [randomizer, dump_data]
+  rescue => e
+    ["Error when building Random marshal data #{e}", ""]
+  end
+
   DATA = {
     "nil" => [nil, "\004\b0"],
     "1..2" => [(1..2),
@@ -342,6 +351,7 @@
                      "\004\bC:\016UserArray[\000"],
     "Struct" => [Struct::Pyramid.new,
                  "\004\bS:\024Struct::Pyramid\000"],
+    "Random" => random_data,
   }
 end
 

Modified: MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/marshal/load_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -327,12 +327,21 @@
     end
   end
 
+  # Note: Ruby 1.9 should be compatible with older marshal format
   MarshalSpec::DATA.each do |description, (object, marshal, attributes)|
     it "loads a #{description}" do
       Marshal.load(marshal).should == object
     end
   end
-  
+
+  ruby_version_is "1.9" do
+    MarshalSpec::DATA_19.each do |description, (object, marshal, attributes)|
+      it "loads a #{description}" do
+        Marshal.load(marshal).should == object
+      end
+    end
+  end
+
   it "returns an untainted object if source is untainted" do
     x = Object.new
     y = Marshal.load(Marshal.dump(x))

Modified: MacRuby/trunk/spec/frozen/core/module/autoload_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/autoload_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/module/autoload_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -114,6 +114,31 @@
     ScratchPad.recorded.should be_nil
   end
 
+  it "ignores the autoload request if the file is already loaded" do
+    filename = fixture(__FILE__, "autoload_s.rb")
+
+    require filename
+
+    ScratchPad.recorded.should == :loaded
+    ScratchPad.clear
+
+    ModuleSpecs::Autoload.autoload :S, filename
+    ModuleSpecs::Autoload.autoload?(:S).should be_nil
+  end
+
+  it "retains the autoload even if the request to require fails" do
+    filename = fixture(__FILE__, "a_path_that_should_not_exist.rb")
+
+    ModuleSpecs::Autoload.autoload :NotThere, filename
+    ModuleSpecs::Autoload.autoload?(:NotThere).should == filename
+
+    lambda {
+      require filename
+    }.should raise_error(LoadError)
+
+    ModuleSpecs::Autoload.autoload?(:NotThere).should == filename
+  end
+
   it "allows multiple autoload constants for a single file" do
     filename = fixture(__FILE__, "autoload_lm.rb")
     ModuleSpecs::Autoload.autoload :L, filename
@@ -205,20 +230,19 @@
     ModuleSpecs::Autoload::U::V::X.should == :autoload_uvx
   end
 
-  # TODO: Remove duplicate specs (this one and that which follows it) when ruby_bug is fixed
-  ruby_bug "#1745", "1.9" do
-    # [ruby-core:19127]
-    it "raises a NameError when the autoload file did not define the constant and a module is opened with the same name" do
-      lambda do
-        module ModuleSpecs::Autoload
-          class W
-            autoload :Y, fixture(__FILE__, "autoload_w.rb")
+  ruby_version_is "1.9" do
+    # [ruby-core:19127] [ruby-core:29941]
+    it "does NOT raise a NameError when the autoload file did not define the constant and a module is opened with the same name" do
+      module ModuleSpecs::Autoload
+        class W
+          autoload :Y, fixture(__FILE__, "autoload_w.rb")
 
-            class Y
-            end
+          class Y
           end
         end
-      end.should raise_error(NameError)
+      end
+
+      ModuleSpecs::Autoload::W::Y.should be_kind_of(Class)
       ScratchPad.recorded.should == :loaded
     end
   end

Modified: MacRuby/trunk/spec/frozen/core/module/class_variable_set_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/class_variable_set_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/module/class_variable_set_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -13,7 +13,7 @@
   end
 
   it "sets the value of a class variable with the given name defined in an included module" do
-    c = Class.new { include ModuleSpecs::MVars }
+    c = Class.new { include ModuleSpecs::MVars.dup }
     c.send(:class_variable_set, "@@mvar", :new_mvar).should == :new_mvar
     c.send(:class_variable_get, "@@mvar").should == :new_mvar
   end

Modified: MacRuby/trunk/spec/frozen/core/module/const_missing_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/const_missing_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/module/const_missing_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -9,4 +9,10 @@
   it "is called when an undefined constant is referenced via #const_get" do
     ConstantSpecs::ClassA.const_get(:CS_CONSTX).should == :CS_CONSTX
   end
+
+  it "raises NameError and includes the name of the value that wasn't found" do
+    lambda {
+      ConstantSpecs.const_missing("HelloMissing")
+    }.should raise_error(NameError, /ConstantSpecs::HelloMissing/)
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/module/define_method_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/define_method_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/module/define_method_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -55,6 +55,14 @@
     o.test1.should == o.another_test
   end
 
+  it "calls #method_added after the method is added to the Module" do
+    DefineMethodSpecClass.should_receive(:method_added).with(:test_ma)
+
+    class DefineMethodSpecClass
+      define_method(:test_ma) { true }
+    end
+  end
+
   it "defines a new method with the given name and the given block as body in self" do
     class DefineMethodSpecClass
       define_method(:block_test1) { self }
@@ -107,6 +115,16 @@
     o.proc_test.should be_true
   end
 
+  it "accepts a String method name" do
+    klass = Class.new do
+      define_method("string_test") do
+        "string_test result"
+      end
+    end
+
+    klass.new.string_test.should == "string_test result"
+  end
+
   it "is private" do
     Module.should have_private_instance_method(:define_method)
   end

Added: MacRuby/trunk/spec/frozen/core/module/fixtures/autoload_s.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/fixtures/autoload_s.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/module/fixtures/autoload_s.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,5 @@
+module ModuleSpecs::Autoload
+  S = :autoload_s
+end
+
+ScratchPad.record :loaded

Modified: MacRuby/trunk/spec/frozen/core/module/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/fixtures/classes.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/module/fixtures/classes.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -7,6 +7,9 @@
   class SubclassSpec
   end
 
+  class RemoveClassVariable
+  end
+
   module LookupModInMod
     INCS = :ethereal
   end

Modified: MacRuby/trunk/spec/frozen/core/module/remove_class_variable_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/remove_class_variable_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/module/remove_class_variable_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,8 +1,38 @@
 require File.expand_path('../../../spec_helper', __FILE__)
 require File.expand_path('../fixtures/classes', __FILE__)
 
-ruby_version_is "1.9" do
-  describe "Module#remove_class_variable" do
-    it "needs to be reviewed for spec completeness"
+describe "Module#remove_class_variable" do
+  it "removes class variable" do
+    m = ModuleSpecs::MVars.dup
+    m.send(:remove_class_variable, :@@mvar)
+    m.class_variable_defined?(:@@mvar).should == false
   end
+
+  it "returns the value of removing class variable" do
+    m = ModuleSpecs::MVars.dup
+    m.send(:remove_class_variable, :@@mvar).should == :mvar
+  end
+
+  it "raises a NameError when removing class variable declared in included module" do
+    c = ModuleSpecs::RemoveClassVariable.new { include ModuleSpecs::MVars.dup }
+    lambda { c.send(:remove_class_variable, :@@mvar) }.should raise_error(NameError)
+  end
+
+  it "raises a NameError when passed a symbol with one leading @" do
+    lambda { ModuleSpecs::MVars.send(:remove_class_variable, :@mvar) }.should raise_error(NameError)
+  end
+
+  it "raises a NameError when passed a symbol with no leading @" do
+    lambda { ModuleSpecs::MVars.send(:remove_class_variable, :mvar)  }.should raise_error(NameError)
+  end
+
+  it "raises a NameError when an uninitialized class variable is given" do
+    lambda { ModuleSpecs::MVars.send(:remove_class_variable, :@@nonexisting_class_variable) }.should raise_error(NameError)
+  end
+
+  ruby_version_is "" ... "1.9" do
+    it "is private" do
+      Module.should have_private_instance_method(:remove_class_variable)
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/process/kill_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/process/kill_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/process/kill_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -21,6 +21,18 @@
   end
 
   platform_is_not :windows do
+    it "accepts symbols as signal names" do
+      begin
+        flag = false
+        @saved_trap = Signal.trap("HUP") { flag = true }
+        Process.kill(:HUP, Process.pid).should == 1
+        sleep 0.5
+        flag.should == true
+      ensure
+        Signal.trap("HUP", @saved_trap)
+      end
+    end
+
     it "tests for the existence of a process without sending a signal" do
       Process.kill(0, 0).should == 1
       pid = Process.fork {

Modified: MacRuby/trunk/spec/frozen/core/process/setrlimit_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/process/setrlimit_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/process/setrlimit_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -97,11 +97,10 @@
 
     platform_is :os => [:netbsd, :freebsd] do
       it "limit and get all socket buffers (bytes)" do
-        #TODO
-        # lim = Process.setrlimit(Process::RLIMIT_SBSIZE, )
-        # lim.kind_of?(Integer).should == true
-        # max.kind_of?(Integer).should == true
-        # Process.setrlimit(Process::RLIMIT_SBSIZE , ).should == nil
+        lim, max = Process.getrlimit(Process::RLIMIT_SBSIZE)
+        lim.kind_of?(Integer).should == true
+        max.kind_of?(Integer).should == true
+        Process.setrlimit(Process::RLIMIT_SBSIZE , lim, max).should == nil
       end
     end
   end

Modified: MacRuby/trunk/spec/frozen/core/random/bytes_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/random/bytes_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/random/bytes_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -15,9 +15,24 @@
     end
 
     it "returns the same output for a given seed" do
-      Random.new(33).bytes(2).should == "\x14\\"
+      Random.new(33).bytes(2).should == Random.new(33).bytes(2)
     end
 
+    # Should double check this is official spec
+    it "returns the same numeric output for a given seed accross all implementations and platforms" do
+      rnd = Random.new(33)
+      rnd.bytes(2).should == "\x14\\"
+      rnd.bytes(1000) # skip some
+      rnd.bytes(2).should == "\xA1p"
+    end
+
+    it "returns the same numeric output for a given huge seed accross all implementations and platforms" do
+      rnd = Random.new(bignum_value ** 4)
+      rnd.bytes(2).should == "_\x91"
+      rnd.bytes(1000) # skip some
+      rnd.bytes(2).should == "\x17\x12"
+    end
+
     it "returns a random binary String" do
       Random.new.bytes(12).should_not == Random.new.bytes(12)
     end

Deleted: MacRuby/trunk/spec/frozen/core/random/marshal_dump_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/random/marshal_dump_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/random/marshal_dump_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,7 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-
-ruby_version_is "1.9" do
-  describe "Random#marshal_dump" do
-    it "needs to be reviewed for spec completeness"
-  end
-end

Deleted: MacRuby/trunk/spec/frozen/core/random/marshal_load_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/random/marshal_load_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/random/marshal_load_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,7 +0,0 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-
-ruby_version_is "1.9" do
-  describe "Random#marshal_load" do
-    it "needs to be reviewed for spec completeness"
-  end
-end

Modified: MacRuby/trunk/spec/frozen/core/random/new_seed_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/random/new_seed_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/random/new_seed_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -12,14 +12,6 @@
       bigs.uniq.size.should == 200  
     end
 
-    # This is probably implementation-specific, but given the complexity and
-    # importance of random number generation, it seems prudent to be explcit
-    # about the current behaviour.
-    it "returns a number less than 40 digits long" do
-      bigs = 2000.times.map { Random.new_seed.to_s.length }.uniq
-      bigs.max.should < 40
-    end
-
     it "is not affected by Kernel#srand" do
       begin
         srand 25

Modified: MacRuby/trunk/spec/frozen/core/random/rand_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/random/rand_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/random/rand_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -77,7 +77,12 @@
       b = 20.times.map { prng.rand(90) }
       a.should == b
     end
-    
+
+    it "eventually returns all possible values" do
+      prng = Random.new 33
+      100.times.map{ prng.rand(10) }.uniq.sort.should == (0...10).to_a
+    end
+
     it "raises an ArgumentError when the argument is 0" do
       lambda do
         Random.new.rand(0)
@@ -92,8 +97,9 @@
   end
 
   describe "Random#rand with Bignum" do
-    it "returns a Bignum" do
-      Random.new(1).rand(bignum_value).should be_an_instance_of(Bignum)
+    it "typically returns a Bignum" do
+      rnd = Random.new(1)
+      10.times.map{ rnd.rand(bignum_value) }.max.should be_an_instance_of(Bignum)
     end
 
     it "returns a Bignum greater than or equal to 0" do
@@ -186,6 +192,12 @@
       a.should == b
     end
     
+    it "eventually returns all possible values" do
+      prng = Random.new 33
+      100.times.map{ prng.rand(10..20) }.uniq.sort.should == (10..20).to_a
+      100.times.map{ prng.rand(10...20) }.uniq.sort.should == (10...20).to_a
+    end
+
     it "allows the startpoint to be an object of a different class to the endpoint" do
       lambda do
         Random.new.rand(89..100.87)

Modified: MacRuby/trunk/spec/frozen/core/range/each_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/range/each_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/range/each_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -41,7 +41,8 @@
   end
 
   it "returns self" do
-    (1..10).each {}.should == (1..10)
+    range = 1..10
+    range.each{}.should equal(range)
   end
 
   ruby_version_is "1.8.7" do

Modified: MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/string/modulo_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -105,6 +105,14 @@
     lambda { "%1$1$s" % "foo" }.should raise_error(ArgumentError)
   end
 
+  it "respects positional arguments and precision tokens given for one format specifier" do
+    ("%2$1d" % [1, 0]).should == "0"
+    ("%2$1d" % [0, 1]).should == "1"
+
+    ("%2$.2f" % [1, 0]).should == "0.00"
+    ("%2$.2f" % [0, 1]).should == "1.00"
+  end
+
   it "raises an ArgumentError when multiple width star tokens are given for one format specifier" do
     lambda { "%**s" % [5, 5, 5] }.should raise_error(ArgumentError)
   end
@@ -856,7 +864,6 @@
       lambda { format % "." }.should raise_error(ArgumentError)
       lambda { format % "10." }.should raise_error(ArgumentError)
       lambda { format % "5x" }.should raise_error(ArgumentError)
-      lambda { format % "0xA" }.should raise_error(ArgumentError)
       lambda { format % "0b1" }.should raise_error(ArgumentError)
       lambda { format % "10e10.5" }.should raise_error(ArgumentError)
       lambda { format % "10__10" }.should raise_error(ArgumentError)
@@ -866,6 +873,16 @@
       obj.should_receive(:to_f).and_return(5.0)
       (format % obj).should == (format % 5.0)
     end
+    ruby_version_is ""..."1.9.2" do
+      it "behaves as if calling Kernel#Float for #{format} arguments, when the passed argument is hexadecimal string" do
+        lambda { format % "0xA" }.should raise_error(ArgumentError)
+      end
+    end
+    ruby_version_is "1.9.2" do
+      it "behaves as if calling Kernel#Float for #{format} arguments, when the passed argument is hexadecimal string" do
+        (format % "0xA").should == (format % 0xA)
+      end
+    end
 
     it "doesn't taint the result for #{format} when argument is tainted" do
       (format % "5".taint).tainted?.should == false

Modified: MacRuby/trunk/spec/frozen/core/string/split_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/split_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/string/split_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -317,7 +317,7 @@
   # When split is called with a limit of -1, empty fields are not suppressed
   # and a final empty field is *alawys* created (who knows why). This empty
   # string is not tainted (again, who knows why) on 1.8 but is on 1.9.
-  ruby_bug "#", "1.9" do
+  ruby_bug "#", "1.8" do
     it "taints an empty string if self is tainted" do
       ":".taint.split(//, -1).last.tainted?.should be_true
     end

Modified: MacRuby/trunk/spec/frozen/core/string/sub_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/sub_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/string/sub_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -339,15 +339,13 @@
   end
 
   ruby_version_is "1.9" do    
-    ruby_bug "[ruby-core:23666]", "1.9" do
-      it "raises a RuntimeError when self is frozen" do
-        s = "hello"
-        s.freeze
+    it "raises a RuntimeError when self is frozen" do
+      s = "hello"
+      s.freeze
 
-        lambda { s.sub!(/ROAR/, "x")    }.should raise_error(RuntimeError)
-        lambda { s.sub!(/e/, "e")       }.should raise_error(RuntimeError)
-        lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
-      end
+      lambda { s.sub!(/ROAR/, "x")    }.should raise_error(RuntimeError)
+      lambda { s.sub!(/e/, "e")       }.should raise_error(RuntimeError)
+      lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
     end
   end    
 end
@@ -397,12 +395,25 @@
     end
   end
 
-  it "raises a RuntimeError when self is frozen" do
-    s = "hello"
-    s.freeze
+  ruby_version_is ""..."1.9" do
+    it "raises a TypeError when self is frozen" do
+      s = "hello"
+      s.freeze
 
-    s.sub!(/ROAR/) { "x" } # ok
-    lambda { s.sub!(/e/) { "e" } }.should raise_error(RuntimeError)
-    lambda { s.sub!(/[aeiou]/) { '*' } }.should raise_error(RuntimeError)
+      s.sub!(/ROAR/) { "x" } # ok
+      lambda { s.sub!(/e/) { "e" }       }.should raise_error(TypeError)
+      lambda { s.sub!(/[aeiou]/) { '*' } }.should raise_error(TypeError)
+    end
   end
+
+  ruby_version_is "1.9" do    
+    it "raises a RuntimeError when self is frozen" do
+      s = "hello"
+      s.freeze
+
+      lambda { s.sub!(/ROAR/) { "x" }    }.should raise_error(RuntimeError)
+      lambda { s.sub!(/e/) { "e" }       }.should raise_error(RuntimeError)
+      lambda { s.sub!(/[aeiou]/) { '*' } }.should raise_error(RuntimeError)
+    end
+  end    
 end

Modified: MacRuby/trunk/spec/frozen/core/string/sum_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/sum_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/string/sum_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -14,4 +14,9 @@
 
     "hello".sum(obj).should == "hello".sum(8)
   end
+
+  it "returns sum of the bytes in self if n less or equal to zero" do
+    "xyz".sum(0).should == 363
+    "xyz".sum(-10).should == 363
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -14,22 +14,12 @@
    ".5e1".to_f.should == 5.0
   end
 
-  not_compliant_on :jruby do
-    it "treats special float value strings as characters" do
-      "NaN".to_f.should == 0
-      "Infinity".to_f.should == 0
-      "-Infinity".to_f.should == 0
-    end
+  it "treats special float value strings as characters" do
+    "NaN".to_f.should == 0
+    "Infinity".to_f.should == 0
+    "-Infinity".to_f.should == 0
   end
 
-  deviates_on :jruby do
-    it "creates special float values from string representations" do
-      "NaN".to_f.nan?.should == true
-      "Infinity".to_f.infinite?.should == 1
-      "-Infinity".to_f.infinite?.should == -1
-    end
-  end
-
   it "allows for varying case" do
     "123.45e1".to_f.should == 1234.5
     "123.45E1".to_f.should == 1234.5

Modified: MacRuby/trunk/spec/frozen/core/string/unpack_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/unpack_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/string/unpack_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -369,6 +369,14 @@
       "\377\377\377\377".unpack("I").should == [4294967295]
       "\000\000\000\000\000\000\000\000".unpack("I*").should == [0,0]
     end
+    big_endian do
+      "\000\001\000\000".unpack("i").should == [65536]
+      "\000\001\000\000\000\001\000\000".unpack("i2").should == [65536, 65536]
+      "\000\001\000\000\000\001\000\000hello".unpack("i2a5").should == [65536, 65536, "hello"]
+      "\377\377\377\377".unpack("i").should == [-1]
+      "\377\377\377\377".unpack("I").should == [4294967295]
+      "\000\000\000\000\000\000\000\000".unpack("I*").should == [0,0]
+    end
   end
 
   it "ignores the result if there aren't 4 bytes" do
@@ -378,6 +386,12 @@
       "\000".unpack("I*").should == []
       "\000\000\000\000\000\000\000\000\000".unpack("I*").should == [0,0]
     end
+    big_endian do
+      "\000".unpack("I").should == [nil]
+      "\000".unpack("I2").should == [nil, nil]
+      "\000".unpack("I*").should == []
+      "\000\000\000\000\000\000\000\000\000".unpack("I*").should == [0,0]
+    end
   end
 end
 
@@ -390,6 +404,13 @@
       "\377\377\377\377".unpack("l").should == [-1]
       "\377\377\377\377".unpack("L").should == [4294967295]
     end
+    big_endian do
+      "\000\001\000\000".unpack("l").should == [65536]
+      "\000\001\000\000\000\001\000\000".unpack("l2").should == [65536, 65536]
+      "\000\001\000\000\000\001\000\000hello".unpack("l2a5").should == [65536, 65536, "hello"]
+      "\377\377\377\377".unpack("l").should == [-1]
+      "\377\377\377\377".unpack("L").should == [4294967295]
+    end
   end
 
   it "ignores the result if there aren't 4 bytes" do
@@ -399,6 +420,12 @@
       "\000".unpack("L*").should == []
       "\000\000\000\000\000\000\000\000\000".unpack("I*").should == [0,0]
     end
+    big_endian do
+      "\000".unpack("L").should == [nil]
+      "\000".unpack("L2").should == [nil, nil]
+      "\000".unpack("L*").should == []
+      "\000\000\000\000\000\000\000\000\000".unpack("I*").should == [0,0]
+    end
   end
 end
 
@@ -480,6 +507,8 @@
     expected = "A fax has arrived from remote ID ''.\r\n------------------------------------------------------------\r\nTime: 3/9/2006 3:50:52 PM\r\nReceived from remote ID: \r\nInbound user ID XXXXXXXXXX, routing code XXXXXXXXX\r\nResult: (0/352;0/0) Successful Send\r\nPage record: 1 - 1\r\nElapsed time: 00:58 on channel 11\r\n"
 
     input.unpack("M").first.should == expected
+
+    "abc=02def=\ncat=\n=01=\n".unpack("M9M3M4").should == ["abc\002defcat\001", "", ""]
   end
 end
 

Modified: MacRuby/trunk/spec/frozen/core/time/strftime_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/time/strftime_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/core/time/strftime_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -145,6 +145,16 @@
     time.strftime('%w').should == '5'
   end
   
+  it "returns the date alone with %x" do
+    time = Time.local(2009, 9, 18, 12, 0, 6)
+    time.strftime('%x').should == '09/18/09'
+  end
+  
+  it "returns the time alone with %X" do
+    time = Time.local(2009, 9, 18, 12, 0, 6)
+    time.strftime('%X').should == '12:00:06'
+  end
+  
   it "returns the year wihout a century with %y" do
     time = Time.local(2009, 9, 18, 12, 0, 0)
     time.strftime('%y').should == '09'
@@ -153,8 +163,14 @@
   it "returns the year with %Y" do
     time = Time.local(2009, 9, 18, 12, 0, 0)
     time.strftime('%Y').should == '2009'
-  end  
-
+  end
+  
+  it "returns the timezone with %Z" do
+    time = Time.local(2009, 9, 18, 12, 0, 0)
+    zone = time.zone
+    time.strftime("%Z").should == zone
+  end
+  
   ruby_version_is "1.9" .. "" do
     it "supports am/pm formatting with %P" do
       time = Time.local(2004, 8, 26, 22, 38, 3)

Modified: MacRuby/trunk/spec/frozen/language/block_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/block_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/language/block_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -7,6 +7,13 @@
     BlockSpecs::Yield.new.two_args {|one, two, three| ret = [one, two, three]}
     ret.should == [1, 2, nil]
   end
+  
+  it "raises ArgumentError if argument is passed, but the block takes none" do
+    lambda{
+      lambda{ || p "block with no argument" }.call(:arg)
+    }.should raise_error(ArgumentError)
+  end
+  
 end
 
 describe "A block with a 'rest' arg" do

Modified: MacRuby/trunk/spec/frozen/language/defined_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/defined_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/language/defined_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -43,6 +43,10 @@
       defined?(Object.print).should be_nil
     end
 
+    it "returns nil if the method is protected" do
+      defined?(DefinedSpecs::Basic.new.protected_method).should be_nil
+    end
+
     it "returns nil if the method is not defined" do
       defined?(Kernel.defined_specs_undefined_method).should be_nil
     end
@@ -808,17 +812,22 @@
   end
 
   ruby_version_is ""..."1.9" do
-    it "calls .const_missing if the constant is not defined" do
+    it "calls .const_missing if the parent to the constant is not defined" do
       Object.should_receive(:const_missing).with(:DefinedSpecsUndefined).and_return(nil)
       defined?(DefinedSpecsUndefined::A).should be_nil
     end
 
-    it "calls .const_missing and uses the return constant for scope" do
+    it "calls .const_missing for the parent and uses the return constant for scope" do
       Object.should_receive(:const_missing).with(:DefinedSpecsUndefined).and_return(DefinedSpecs)
       defined?(DefinedSpecsUndefined::Child).should == "constant"
     end
   end
 
+  it "does not call .const_missing if the constant is not defined" do
+    DefinedSpecs.should_not_receive(:const_missing)
+    defined?(DefinedSpecs::UnknownChild).should be_nil
+  end
+
   it "returns nil when an undefined constant is scoped to a defined constant" do
     defined?(DefinedSpecs::Child::B).should be_nil
   end

Modified: MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -88,16 +88,15 @@
       cls.superclass.should == class << Class; self end
     end
 
-    it "has the object's class as superclass" do
+    it "has class String as the superclass of a String instance" do
       cls = class << "blah"; self; end
       cls.superclass.should == String
     end
 
-    ruby_bug("#601", "1.9") do
-      it "raises a TypeError for Bignum's" do
-        (1<<1024).should be_kind_of(Bignum)
-        lambda { class << (1<<1024); self; end }.should raise_error(TypeError)
-      end
+    it "has class Bignum as the superclass of a Bignum instance" do
+      # This behavior may be changed in the future, though.  [Feature #3222]
+      cls = class << bignum_value; self; end
+      cls.superclass.should == Bignum
     end
   end
 

Modified: MacRuby/trunk/spec/frozen/language/encoding_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/encoding_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/language/encoding_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,4 +1,5 @@
 require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/pseudo_variable', __FILE__)
 
 ruby_version_is "1.9" do
   describe "The __ENCODING__ pseudo-variable" do
@@ -23,8 +24,6 @@
       eval(code).should == Encoding::US_ASCII
     end
 
-    it "is not assignable" do
-      lambda { eval("__ENCODING__ = nil") }.should raise_error(SyntaxError)
-    end
+    it_behaves_like :language_pseudo_variable, "__ENCODING__", nil
   end
 end

Added: MacRuby/trunk/spec/frozen/language/false_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/false_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/language/false_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,7 @@
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/pseudo_variable', __FILE__)
+
+describe "The false pseudo-variable" do
+  it_behaves_like :language_pseudo_variable, "false", "something else".dump
+end
+

Modified: MacRuby/trunk/spec/frozen/language/file_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/file_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/language/file_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,25 +1,28 @@
 require File.expand_path('../../spec_helper', __FILE__)
 require File.expand_path('../../fixtures/code_loading', __FILE__)
 require File.expand_path('../shared/__FILE__', __FILE__)
+require File.expand_path('../shared/pseudo_variable', __FILE__)
 
-describe "The __FILE__ constant" do
+describe "The __FILE__ pseudo-variable" do
+  it_behaves_like :language_pseudo_variable, "__FILE__", "/an/example/file/path.rb".dump
+
   it "equals (eval) inside an eval" do
     eval("__FILE__").should == "(eval)"
   end
 end
 
-describe "The __FILE__ constant" do
+describe "The __FILE__ pseudo-variable" do
   it_behaves_like :language___FILE__, :require, CodeLoadingSpecs::Method.new
 end
 
-describe "The __FILE__ constant" do
+describe "The __FILE__ pseudo-variable" do
   it_behaves_like :language___FILE__, :require, Kernel
 end
 
-describe "The __FILE__ constant" do
+describe "The __FILE__ pseudo-variable" do
   it_behaves_like :language___FILE__, :load, CodeLoadingSpecs::Method.new
 end
 
-describe "The __FILE__ constant" do
+describe "The __FILE__ pseudo-variable" do
   it_behaves_like :language___FILE__, :load, Kernel
 end

Modified: MacRuby/trunk/spec/frozen/language/fixtures/defined.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/fixtures/defined.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/language/fixtures/defined.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -29,6 +29,10 @@
     def a_defined_method
     end
 
+    def protected_method
+    end
+    protected :protected_method
+
     def local_variable_defined
       x = 2
       defined? x

Modified: MacRuby/trunk/spec/frozen/language/line_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/line_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/language/line_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,8 +1,11 @@
 require File.expand_path('../../spec_helper', __FILE__)
 require File.expand_path('../../fixtures/code_loading', __FILE__)
 require File.expand_path('../shared/__LINE__', __FILE__)
+require File.expand_path('../shared/pseudo_variable', __FILE__)
 
-describe "The __LINE__ constant" do
+describe "The __LINE__ pseudo-variable" do
+  it_behaves_like :language_pseudo_variable, "__FILE__", "/an/example/file/path.rb".dump
+
   before :each do
     ScratchPad.record []
   end
@@ -24,18 +27,18 @@
   end
 end
 
-describe "The __LINE__ constant" do
+describe "The __LINE__ pseudo-variable" do
   it_behaves_like :language___LINE__, :require, CodeLoadingSpecs::Method.new
 end
 
-describe "The __LINE__ constant" do
+describe "The __LINE__ pseudo-variable" do
   it_behaves_like :language___LINE__, :require, Kernel
 end
 
-describe "The __LINE__ constant" do
+describe "The __LINE__ pseudo-variable" do
   it_behaves_like :language___LINE__, :load, CodeLoadingSpecs::Method.new
 end
 
-describe "The __LINE__ constant" do
+describe "The __LINE__ pseudo-variable" do
   it_behaves_like :language___LINE__, :load, Kernel
 end

Added: MacRuby/trunk/spec/frozen/language/nil_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/nil_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/language/nil_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,6 @@
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/pseudo_variable', __FILE__)
+
+describe "The nil pseudo-variable" do
+  it_behaves_like :language_pseudo_variable, "nil", "something else".dump
+end

Added: MacRuby/trunk/spec/frozen/language/self_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/self_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/language/self_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,7 @@
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/pseudo_variable', __FILE__)
+
+describe "The self pseudo-variable" do
+  it_behaves_like :language_pseudo_variable, "self", "something else".dump
+end
+

Added: MacRuby/trunk/spec/frozen/language/shared/pseudo_variable.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/shared/pseudo_variable.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/language/shared/pseudo_variable.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,13 @@
+describe :language_pseudo_variable, :shared => true do
+  before do
+    @name = @method
+    @assigned_expression = @object
+  end
+
+  it "is syntactically inassignable" do
+    lambda {
+      eval("#{@name} = #{@assigned_expression}")
+    }.should raise_error(SyntaxError)
+  end
+end
+

Added: MacRuby/trunk/spec/frozen/language/true_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/true_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/language/true_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,7 @@
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../shared/pseudo_variable', __FILE__)
+
+describe "The true pseudo-variable" do
+  it_behaves_like :language_pseudo_variable, "true", "something else".dump
+end
+

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/sqrt_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/sqrt_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/sqrt_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -8,8 +8,8 @@
     @zero = BigDecimal("0")
     @zero_pos = BigDecimal("+0")
     @zero_neg = BigDecimal("-0")
-    @two = BigDecimal("2")
-    @three = BigDecimal("3")
+    @two = BigDecimal("2.0")
+    @three = BigDecimal("3.0")
     @nan = BigDecimal("NaN")
     @infinity = BigDecimal("Infinity")
     @infinity_minus = BigDecimal("-Infinity")
@@ -18,38 +18,65 @@
     @frac_2 = BigDecimal("0.9E-99999")
   end
 
-  it "returns sqrt of self with at least the given precision" do
+  it "returns square root of 2 with desired precision" do
     string = "1.41421356237309504880168872420969807856967187537694807317667973799073247846210703885038753432764157"
     (1..99).each { |idx|
       @two.sqrt(idx).should be_close(BigDecimal(string), BigDecimal("1E-#{idx-1}"))
     }
+  end
+  
+  it "returns square root of 3 with desired precision" do
     sqrt_3 = "1.732050807568877293527446341505872366942805253810380628055806979451933016908800037081146186757248575"
     (1..99).each { |idx|
       @three.sqrt(idx).should be_close(BigDecimal(sqrt_3), BigDecimal("1E-#{idx-1}"))
     }
+  end
+  
+  it "returns square root of 121 with desired precision" do
     BigDecimal('121').sqrt(5).should be_close(11, 0.00001)
+  end
+  
+  it "returns square root of 0.9E-99999 with desired precision" do
     @frac_2.sqrt(1).to_s.should == "0.3E-49999"
   end
 
-  it "requires a single fixnum argument" do
+  it "raises ArgumentError when no argument is given" do
     lambda {
       @one.sqrt
     }.should raise_error(ArgumentError)
+  end
+  
+  it "raises ArgumentError if a negative number is given" do
     lambda {
       @one.sqrt(-1)
     }.should raise_error(ArgumentError)
+  end
+  
+  it "raises ArgumentError if 2 arguments are given" do
     lambda {
       @one.sqrt(1, 1)
     }.should raise_error(ArgumentError)
+  end
+  
+  it "raises TypeError if nil is given" do
     lambda {
       @one.sqrt(nil)
     }.should raise_error(TypeError)
+  end
+  
+  it "raises TypeError if a string is given" do
     lambda {
       @one.sqrt("stuff")
     }.should raise_error(TypeError)
+  end
+  
+  it "raises TypeError if a plain Object is given" do
     lambda {
       @one.sqrt(Object.new)
     }.should raise_error(TypeError)
+  end
+  
+  it "returns 1 if precision is 0 or 1" do
     @one.sqrt(1).should == 1
     @one.sqrt(0).should == 1
   end
@@ -60,14 +87,23 @@
     }.should raise_error(FloatDomainError)
   end
 
-  it "properly handles special values" do
+  it "returns positive infitinity for infinity" do
     @infinity.sqrt(1).should == @infinity
+  end
+  
+  it "raises FloatDomainError for negative infinity" do
     lambda {
       @infinity_minus.sqrt(1)
     }.should raise_error(FloatDomainError)
+  end
+  
+  it "raises FloatDomainError for NaN" do
     lambda {
       @nan.sqrt(1)
     }.should raise_error(FloatDomainError)
+  end
+  
+  it "returns 0 for 0, +0.0 and -0.0" do
     @zero.sqrt(1).should == 0
     @zero_pos.sqrt(1).should == 0
     @zero_neg.sqrt(1).should == 0

Added: MacRuby/trunk/spec/frozen/library/digest/hexencode_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/digest/hexencode_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/digest/hexencode_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,31 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'digest'
+
+describe "Digest.hexencode" do
+  before(:each) do
+    @string   = 'sample string'
+    @encoded  = "73616d706c6520737472696e67"
+  end
+
+  it "returns '' when passed an empty String" do
+    Digest.hexencode('').should == ''
+  end
+
+  it "returns the hex-encoded value of a non-empty String" do
+    Digest.hexencode(@string).should == @encoded
+  end
+
+  it "calls #to_str on an object and returns the hex-encoded value of the result" do
+    obj = mock("to_str")
+    obj.should_receive(:to_str).and_return(@string)
+    Digest.hexencode(obj).should == @encoded
+  end
+
+  it "raises a TypeError when passed nil" do
+    lambda { Digest.hexencode(nil) }.should raise_error(TypeError)
+  end
+
+  it "raises a TypeError when passed a Fixnum" do
+    lambda { Digest.hexencode(9001) }.should raise_error(TypeError)
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/digest/md5/file_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/digest/md5/file_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/digest/md5/file_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,43 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+require File.expand_path('../../../../core/file/shared/read', __FILE__)
+
+describe "Digest::MD5.file" do
+
+  describe "when passed a path to a file that exists" do
+    before :each do
+      @file = tmp("md5_temp")
+      touch(@file, 'wb') {|f| f.write MD5Constants::Contents }
+    end
+
+    after :each do
+      rm_r @file
+    end
+
+    it 'returns a Digest::MD5 object' do
+      Digest::MD5.file(@file).should be_kind_of(Digest::MD5)
+    end
+  
+    it 'returns a Digest::MD5 object with the correct digest' do
+      Digest::MD5.file(@file).digest.should == MD5Constants::Digest
+    end
+
+    it "calls #to_str on an object and returns the Digest::MD5 with the result" do
+      obj = mock("to_str")
+      obj.should_receive(:to_str).and_return(@file)
+      result = Digest::MD5.file(obj)
+      result.should be_kind_of(Digest::MD5)
+      result.digest.should == MD5Constants::Digest
+    end
+  end
+
+  it_behaves_like :file_read_directory, :file, Digest::MD5
+
+  it 'raises a Errno::ENOENT when passed a path that does not exist' do
+    lambda { Digest::MD5.file("") }.should raise_error(Errno::ENOENT)
+  end
+
+  it 'raises a TypeError when passed nil' do
+    lambda { Digest::MD5.file(nil) }.should raise_error(TypeError)
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/digest/sha1/file_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/digest/sha1/file_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/digest/sha1/file_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,42 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+
+describe "Digest::SHA1.file" do
+
+  describe "when passed a path to a file that exists" do
+    before :each do
+      @file = tmp("md5_temp")
+      touch(@file, 'wb') {|f| f.write SHA1Constants::Contents }
+    end
+
+    after :each do
+      rm_r @file
+    end
+
+    it 'returns a Digest::SHA1 object' do
+      Digest::SHA1.file(@file).should be_kind_of(Digest::SHA1)
+    end
+  
+    it 'returns a Digest::SHA1 object with the correct digest' do
+      Digest::SHA1.file(@file).digest.should == SHA1Constants::Digest
+    end
+
+    it "calls #to_str on an object and returns the Digest::SHA1 with the result" do
+      obj = mock("to_str")
+      obj.should_receive(:to_str).and_return(@file)
+      result = Digest::SHA1.file(obj)
+      result.should be_kind_of(Digest::SHA1)
+      result.digest.should == SHA1Constants::Digest
+    end
+  end
+
+  it_behaves_like :file_read_directory, :file, Digest::SHA1
+
+  it 'raises a Errno::ENOENT when passed a path that does not exist' do
+    lambda { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT)
+  end
+
+  it 'raises a TypeError when passed nil' do
+    lambda { Digest::SHA1.file(nil) }.should raise_error(TypeError)
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/digest/sha256/file_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/digest/sha256/file_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/digest/sha256/file_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,42 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+
+describe "Digest::SHA256.file" do
+
+  describe "when passed a path to a file that exists" do
+    before :each do
+      @file = tmp("md5_temp")
+      touch(@file, 'wb') {|f| f.write SHA256Constants::Contents }
+    end
+
+    after :each do
+      rm_r @file
+    end
+
+    it 'returns a Digest::SHA256 object' do
+      Digest::SHA256.file(@file).should be_kind_of(Digest::SHA256)
+    end
+  
+    it 'returns a Digest::SHA256 object with the correct digest' do
+      Digest::SHA256.file(@file).digest.should == SHA256Constants::Digest
+    end
+
+    it "calls #to_str on an object and returns the Digest::SHA256 with the result" do
+      obj = mock("to_str")
+      obj.should_receive(:to_str).and_return(@file)
+      result = Digest::SHA256.file(obj)
+      result.should be_kind_of(Digest::SHA256)
+      result.digest.should == SHA256Constants::Digest
+    end
+  end
+
+  it_behaves_like :file_read_directory, :file, Digest::SHA256
+
+  it 'raises a Errno::ENOENT when passed a path that does not exist' do
+    lambda { Digest::SHA256.file("") }.should raise_error(Errno::ENOENT)
+  end
+
+  it 'raises a TypeError when passed nil' do
+    lambda { Digest::SHA256.file(nil) }.should raise_error(TypeError)
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/digest/sha384/file_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/digest/sha384/file_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/digest/sha384/file_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,42 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+
+describe "Digest::SHA384.file" do
+
+  describe "when passed a path to a file that exists" do
+    before :each do
+      @file = tmp("md5_temp")
+      touch(@file, 'wb') {|f| f.write SHA384Constants::Contents }
+    end
+
+    after :each do
+      rm_r @file
+    end
+
+    it 'returns a Digest::SHA384 object' do
+      Digest::SHA384.file(@file).should be_kind_of(Digest::SHA384)
+    end
+  
+    it 'returns a Digest::SHA384 object with the correct digest' do
+      Digest::SHA384.file(@file).digest.should == SHA384Constants::Digest
+    end
+
+    it "calls #to_str on an object and returns the Digest::SHA384 with the result" do
+      obj = mock("to_str")
+      obj.should_receive(:to_str).and_return(@file)
+      result = Digest::SHA384.file(obj)
+      result.should be_kind_of(Digest::SHA384)
+      result.digest.should == SHA384Constants::Digest
+    end
+  end
+
+  it_behaves_like :file_read_directory, :file, Digest::SHA384
+
+  it 'raises a Errno::ENOENT when passed a path that does not exist' do
+    lambda { Digest::SHA384.file("") }.should raise_error(Errno::ENOENT)
+  end
+
+  it 'raises a TypeError when passed nil' do
+    lambda { Digest::SHA384.file(nil) }.should raise_error(TypeError)
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/digest/sha512/file_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/digest/sha512/file_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/digest/sha512/file_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,42 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../shared/constants', __FILE__)
+
+describe "Digest::SHA512.file" do
+
+  describe "when passed a path to a file that exists" do
+    before :each do
+      @file = tmp("md5_temp")
+      touch(@file, 'wb') {|f| f.write SHA512Constants::Contents }
+    end
+
+    after :each do
+      rm_r @file
+    end
+
+    it 'returns a Digest::SHA512 object' do
+      Digest::SHA512.file(@file).should be_kind_of(Digest::SHA512)
+    end
+  
+    it 'returns a Digest::SHA512 object with the correct digest' do
+      Digest::SHA512.file(@file).digest.should == SHA512Constants::Digest
+    end
+
+    it "calls #to_str on an object and returns the Digest::SHA512 with the result" do
+      obj = mock("to_str")
+      obj.should_receive(:to_str).and_return(@file)
+      result = Digest::SHA512.file(obj)
+      result.should be_kind_of(Digest::SHA512)
+      result.digest.should == SHA512Constants::Digest
+    end
+  end
+
+  it_behaves_like :file_read_directory, :file, Digest::SHA512
+
+  it 'raises a Errno::ENOENT when passed a path that does not exist' do
+    lambda { Digest::SHA512.file("") }.should raise_error(Errno::ENOENT)
+  end
+
+  it 'raises a TypeError when passed nil' do
+    lambda { Digest::SHA512.file(nil) }.should raise_error(TypeError)
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/ftools/chmod_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/ftools/chmod_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/ftools/chmod_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -19,11 +19,11 @@
       end
 
       it "changes the mode to 1st arg for files in 2nd arg" do
-        `ls -l chmod_test_1`.should =~ /^-rwxrwxrwx /
-        `ls -l chmod_test_2`.should =~ /^-rwxrwxrwx /
+        `ls -l chmod_test_1`.should =~ /^-rwxrwxrwx/
+        `ls -l chmod_test_2`.should =~ /^-rwxrwxrwx/
         File.chmod 0644, "chmod_test_1", "chmod_test_2"
-        `ls -l chmod_test_1`.should =~ /^-rw-r--r-- /
-        `ls -l chmod_test_2`.should =~ /^-rw-r--r-- /
+        `ls -l chmod_test_1`.should =~ /^-rw-r--r--/
+        `ls -l chmod_test_2`.should =~ /^-rw-r--r--/
       end
     end
   end

Modified: MacRuby/trunk/spec/frozen/library/ftools/install_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/ftools/install_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/ftools/install_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -17,9 +17,9 @@
       end
 
       it "changes the mode to 1st arg for files in 2nd arg" do
-        `ls -l install_test_1`.should =~ /^-rwxrwxrwx /
+        `ls -l install_test_1`.should =~ /^-rwxrwxrwx/
         File.install "install_test_1", "install_test_2", 0644
-        `ls -l install_test_2`.should =~ /^-rw-r--r-- /
+        `ls -l install_test_2`.should =~ /^-rw-r--r--/
       end
     end
   end

Added: MacRuby/trunk/spec/frozen/library/matrix/build_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/build_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/build_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,68 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'matrix'
+
+ruby_version_is "1.9" do
+  describe "Matrix.build" do
+
+    it "returns a Matrix object of the given size" do
+      m = Matrix.build(3, 4){1}
+      m.should be_an_instance_of(Matrix)
+      m.row_size.should == 3
+      m.column_size.should == 4
+    end
+
+    it "builds the Matrix using the given block" do
+      Matrix.build(2, 3){|col, row| 10*col - row}.should ==
+        Matrix[[0, -1, -2], [10, 9, 8]]
+    end
+
+    it "iterates through the first row, then the second, ..." do
+      acc = []
+      Matrix.build(2, 3){|*args| acc << args}
+      acc.should == [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2]]
+    end
+
+    it "returns an Enumerator is no block is given" do
+      enum = Matrix.build(2, 1)
+      enum.should  be_an_instance_of(enumerator_class)
+      enum.each{1}.should == Matrix[[1], [1]]
+    end
+
+    it "requires integers as parameters" do
+      lambda { Matrix.build("1", "2"){1} }.should raise_error(TypeError)
+      lambda { Matrix.build(nil, nil){1} }.should raise_error(TypeError)
+      lambda { Matrix.build(1..2){1} }.should raise_error(TypeError)
+    end
+
+    it "requires non-negative integers" do
+      lambda { Matrix.build(-1, 1){1} }.should raise_error(ArgumentError)
+      lambda { Matrix.build(+1,-1){1} }.should raise_error(ArgumentError)
+    end
+
+    it "returns empty Matrix if one argument is zero" do
+      m = Matrix.build(0, 3){
+        raise "Should not yield"
+      }
+      m.should be_empty
+      m.column_size.should == 3
+
+      m = Matrix.build(3, 0){
+        raise "Should not yield"
+      }
+      m.should be_empty
+      m.row_size.should == 3
+    end
+
+    it "tries to calls :to_int on arguments" do
+      int = mock('int')
+      int.should_receive(:to_int).twice.and_return(2)
+      Matrix.build(int, int){ 1 }.should == Matrix[ [1,1], [1,1] ]
+    end
+
+    it "builds an nxn Matrix when given only one argument" do
+      m = Matrix.build(3){1}
+      m.row_size.should == 3
+      m.column_size.should == 3
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/conj_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/conj_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/conj_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/conjugate', __FILE__)
+
+ruby_version_is "1.9" do
+  describe "Matrix#conj" do
+    it_behaves_like(:matrix_conjugate, :conj)
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/conjugate_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/conjugate_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/conjugate_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/conjugate', __FILE__)
+
+ruby_version_is "1.9" do
+  describe "Matrix#conjugate" do
+    it_behaves_like(:matrix_conjugate, :conjugate)
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/library/matrix/divide_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/divide_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/divide_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -9,7 +9,7 @@
     @c = Matrix[ [1.2, 2.4], [3.6, 4.8] ]
   end
 
-  ruby_bug "?", "1.9" do
+  ruby_bug "?", "1.8.7" do
     it "returns the result of dividing self by another Matrix" do
       (@a / @b).should be_close_to_matrix([[2.5, -1.5], [1.5, -0.5]])
     end
@@ -38,4 +38,13 @@
   it "returns an instance of Matrix" do
     (@a /@b).should be_kind_of(Matrix)
   end
+
+  ruby_bug "redmine:2365", "1.8.7" do
+    it "raises a TypeError if other is of wrong type" do
+      lambda { @a / nil        }.should raise_error(TypeError)
+      lambda { @a / "a"        }.should raise_error(TypeError)
+      lambda { @a / [ [1, 2] ] }.should raise_error(TypeError)
+      lambda { @a / Object.new }.should raise_error(TypeError)
+    end
+  end
 end

Added: MacRuby/trunk/spec/frozen/library/matrix/each_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/each_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/each_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,27 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'matrix'
+
+ruby_version_is "1.9" do
+  describe "Matrix#each" do
+    before :all do
+      @m = Matrix[ [1, 2, 3], [4, 5, 6] ]
+      @result = (1..6).to_a
+    end
+
+    it "returns an Enumerator when called without a block" do
+      enum = @m.each
+      enum.should be_an_instance_of(enumerator_class)
+      enum.to_a.should == @result
+    end
+
+    it "returns self" do
+      @m.each{}.should equal(@m)
+    end
+
+    it "yields the elements starting with the those of the first row" do
+      a = []
+      @m.each {|x| a << x}
+      a.should ==  @result
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/each_with_index_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/each_with_index_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/each_with_index_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,34 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'matrix'
+
+ruby_version_is "1.9" do
+  describe "Matrix#each_with_index" do
+    before :all do
+      @m = Matrix[ [1, 2, 3], [4, 5, 6] ]
+      @result = [
+        [1, 0, 0],
+        [2, 0, 1],
+        [3, 0, 2],
+        [4, 1, 0],
+        [5, 1, 1],
+        [6, 1, 2]
+      ]
+    end
+
+    it "returns an Enumerator when called without a block" do
+      enum = @m.each_with_index
+      enum.should be_an_instance_of(enumerator_class)
+      enum.to_a.should == @result
+    end
+
+    it "returns self" do
+      @m.each_with_index{}.should equal(@m)
+    end
+
+    it "yields the elements starting with the those of the first row" do
+      a = []
+      @m.each_with_index {|x, r, c| a << [x, r, c]}
+      a.should == @result
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/empty_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/empty_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/empty_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,63 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'matrix'
+
+ruby_version_is "1.9" do
+  describe "Matrix#empty?" do
+    it "returns true when the Matrix is empty" do
+      Matrix[ ].empty?.should be_true
+      Matrix[ [], [], [] ].empty?.should be_true
+      Matrix[ [], [], [] ].transpose.empty?.should be_true
+    end
+
+    it "returns false when the Matrix has elements" do
+      Matrix[ [1, 2] ].empty?.should be_false
+      Matrix[ [1], [2] ].empty?.should be_false
+    end
+
+    it "doesn't accept any parameter" do
+      lambda{
+        Matrix[ [1, 2] ].empty?(42)
+      }.should raise_error(ArgumentError)
+    end
+  end
+
+  describe "Matrix.empty" do
+    it "returns an empty matrix of the requested size" do
+      m = Matrix.empty(3, 0)
+      m.row_size.should == 3
+      m.column_size.should == 0
+
+      m = Matrix.empty(0, 3)
+      m.row_size.should == 0
+      m.column_size.should == 3
+    end
+
+    it "has arguments defaulting to 0" do
+      Matrix.empty.should == Matrix.empty(0, 0)
+      Matrix.empty(42).should == Matrix.empty(42, 0)
+    end
+
+    it "does not accept more than two parameters" do
+      lambda{
+        Matrix.empty(1, 2, 3)
+      }.should raise_error(ArgumentError)
+    end
+
+    it "raises an error if both dimensions are > 0" do
+      lambda{
+        Matrix.empty(1, 2)
+      }.should raise_error(ArgumentError)
+    end
+
+    it "raises an error if any dimension is < 0" do
+      lambda{
+        Matrix.empty(-2, 0)
+      }.should raise_error(ArgumentError)
+
+      lambda{
+        Matrix.empty(0, -2)
+      }.should raise_error(ArgumentError)
+    end
+
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/imag_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/imag_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/imag_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/imaginary', __FILE__)
+
+ruby_version_is "1.9" do
+  describe "Matrix#imag" do
+    it_behaves_like(:matrix_imaginary, :imag)
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/imaginary_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/imaginary_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/imaginary_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/imaginary', __FILE__)
+
+ruby_version_is "1.9" do
+  describe "Matrix#imaginary" do
+    it_behaves_like(:matrix_imaginary, :imaginary)
+  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	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/minus_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -25,15 +25,12 @@
     lambda { @a - bignum_value }.should raise_error(Matrix::ErrOperationNotDefined)
   end
 
-  it "raises an exception if other is not a Matrix" do
-    # Note that MRI raises NoMethodError because #coerce is called
-    # on objects that don't provide it. This appears to be more of
-    # an "oops" rather than an aspect of the interface. We don't
-    # spec the exception class.
-
-    lambda { @a - nil        }.should raise_error
-    lambda { @a - "a"        }.should raise_error
-    lambda { @a - [ [1, 2] ] }.should raise_error
-    lambda { @a - Object.new }.should raise_error
+  ruby_bug "redmine:2365", "1.8.7" do
+    it "raises a TypeError if other is of wrong type" do
+      lambda { @a - nil        }.should raise_error(TypeError)
+      lambda { @a - "a"        }.should raise_error(TypeError)
+      lambda { @a - [ [1, 2] ] }.should raise_error(TypeError)
+      lambda { @a - Object.new }.should raise_error(TypeError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/multiply_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/multiply_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/multiply_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -51,4 +51,13 @@
       (Matrix.columns([[], [], []]) * Matrix[[1,2],[3,4],[5,6]]).should == Matrix.columns([[],[]])
     end
   end
+
+  ruby_bug "redmine:2365", "1.8.7" do
+    it "raises a TypeError if other is of wrong type" do
+      lambda { @a * nil        }.should raise_error(TypeError)
+      lambda { @a * "a"        }.should raise_error(TypeError)
+      lambda { @a * [ [1, 2] ] }.should raise_error(TypeError)
+      lambda { @a * Object.new }.should raise_error(TypeError)
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/matrix/plus_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/plus_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/plus_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -25,15 +25,12 @@
     lambda { @a + bignum_value }.should raise_error(ExceptionForMatrix::ErrOperationNotDefined)
   end
 
-  it "raises an exception if other is not a Matrix" do
-    # Note that MRI raises NoMethodError because #coerce is called
-    # on objects that don't provide it. This appears to be more of
-    # an "oops" rather than an aspect of the interface. We don't
-    # spec the exception class.
-
-    lambda { @a + nil        }.should raise_error
-    lambda { @a + "a"        }.should raise_error
-    lambda { @a + [ [1, 2] ] }.should raise_error
-    lambda { @a + Object.new }.should raise_error
+  ruby_bug "redmine:2365", "1.8.7" do
+    it "raises a TypeError if other is of wrong type" do
+      lambda { @a + nil        }.should raise_error(TypeError)
+      lambda { @a + "a"        }.should raise_error(TypeError)
+      lambda { @a + [ [1, 2] ] }.should raise_error(TypeError)
+      lambda { @a + Object.new }.should raise_error(TypeError)
+    end
   end
 end

Added: MacRuby/trunk/spec/frozen/library/matrix/real_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/real_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/real_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,37 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'matrix'
+
+ruby_version_is "1.9" do
+  describe "Matrix#real?" do
+    it "returns true for matrices with all real entries" do
+      Matrix[ [1,   2], [3, 4] ].real?.should be_true
+      Matrix[ [1.9, 2], [3, 4] ].real?.should be_true
+    end
+
+    it "returns true for empty matrices" do
+      Matrix.empty.real?.should be_true
+    end
+
+    it "returns false if one element is a Complex" do
+      Matrix[ [Complex(1,1), 2], [3, 4] ].real?.should be_false
+    end
+
+    conflicts_with :CMath do
+      it "returns false if one element is a Complex whose imaginary part is 0" do
+        Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should be_false
+      end
+    end
+  end
+
+  describe "Matrix#real" do
+    it "returns a matrix with the real part of the elements of the receiver" do
+      Matrix[ [1,   2], [3, 4] ].real.should == Matrix[ [1,   2], [3, 4] ]
+      Matrix[ [1.9, Complex(1,1)], [Complex(-0.42, 0), 4] ].real.should == Matrix[ [1.9, 1], [-0.42, 4] ]
+    end
+
+    it "returns empty matrices on the same size if empty" do
+      Matrix.empty(0, 3).real.should == Matrix.empty(0, 3)
+      Matrix.empty(3, 0).real.should == Matrix.empty(3, 0)
+    end
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/rect_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/rect_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/rect_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rectangular', __FILE__)
+
+ruby_version_is "1.9" do
+  describe "Matrix#rect" do
+    it_behaves_like(:matrix_rectangular, :rect)
+  end
+end
\ No newline at end of file

Added: MacRuby/trunk/spec/frozen/library/matrix/rectangular_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/rectangular_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/rectangular_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,8 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/rectangular', __FILE__)
+
+ruby_version_is "1.9" do
+  describe "Matrix#rectangular" do
+    it_behaves_like(:matrix_rectangular, :rectangular)
+  end
+end
\ No newline at end of file

Modified: MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/regular_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -3,28 +3,33 @@
 
 describe "Matrix#regular?" do
 
-  # Bug #1020 and an unfamiliarity with properties of matrices stopped me
-  # from writing a complete specification here. 
-  it "needs to be reviewed for spec completeness"
-
-  ruby_bug "#1020", "1.9.1.129" do
-    it "returns false unless rank(A) != n" do
+  ruby_bug "#1020", "1.8.7" do
+    it "returns false for singular matrices" do
       m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
-      m.square?.should be_true
-      m.rank.should_not == m.column_size
       m.regular?.should be_false
-    end 
 
-    it "returns false if the determinant is 0" do
       m = Matrix[ [1,2,9], [3,4,9], [1,2,9] ]
-      m.det.should == 0
-      m.square?.should be_true
       m.regular?.should be_false
     end
 
     it "returns true if the Matrix is regular" do
       Matrix[ [0,1], [1,0] ].regular?.should be_true
-    end  
-  end    
+    end
+  end
 
+  ruby_bug "", "1.8.7" do
+    it "returns true for an empty 0x0 matrix" do
+      Matrix.empty(0,0).regular?.should be_true
+    end
+
+    it "raises an error for rectangular matrices" do
+       lambda {
+         Matrix[[1], [2], [3]].regular?
+       }.should raise_error(Matrix::ErrDimensionMismatch)
+
+       lambda {
+         Matrix.empty(3,0).regular?
+       }.should raise_error(Matrix::ErrDimensionMismatch)
+     end
+  end
 end

Added: MacRuby/trunk/spec/frozen/library/matrix/shared/conjugate.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/conjugate.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/conjugate.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,13 @@
+require 'matrix'
+
+describe :matrix_conjugate, :shared => true do
+  it "returns a matrix with all entries 'conjugated'" do
+    Matrix[ [1,   2], [3, 4] ].send(@method).should == Matrix[ [1,   2], [3, 4] ]
+    Matrix[ [1.9, Complex(1,1)], [3, 4] ].send(@method).should == Matrix[ [1.9, Complex(1,-1)], [3, 4] ]
+  end
+
+  it "returns empty matrices on the same size if empty" do
+    Matrix.empty(0, 3).send(@method).should == Matrix.empty(0, 3)
+    Matrix.empty(3, 0).send(@method).should == Matrix.empty(3, 0)
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/determinant.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -34,8 +34,20 @@
   end
 
   ruby_bug "#1531", "1.8.7" do
-    it "returns the determinant of a Matrices containing 0 as first entry" do
+    it "returns the determinant even for Matrices containing 0 as first entry" do
       Matrix[[0,1],[1,0]].send(@method).should == -1
     end
   end
+
+  ruby_bug "#2770", "1.8.7" do
+    it "raises an error for rectangular matrices" do
+      lambda {
+        Matrix[[1], [2], [3]].send(@method)
+      }.should raise_error(Matrix::ErrDimensionMismatch)
+
+      lambda {
+        Matrix.empty(3,0).send(@method)
+      }.should raise_error(Matrix::ErrDimensionMismatch)
+    end
+  end
 end

Added: MacRuby/trunk/spec/frozen/library/matrix/shared/imaginary.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/imaginary.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/imaginary.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,13 @@
+require 'matrix'
+
+describe :matrix_imaginary, :shared => true do
+  it "returns a matrix with the imaginary part of the elements of the receiver" do
+    Matrix[ [1,   2], [3, 4] ].send(@method).should == Matrix[ [0,   0], [0, 0] ]
+    Matrix[ [1.9, Complex(1,1)], [Complex(-2,0.42), 4] ].send(@method).should == Matrix[ [0, 1], [0.42, 0] ]
+  end
+
+  it "returns empty matrices on the same size if empty" do
+    Matrix.empty(0, 3).send(@method).should == Matrix.empty(0, 3)
+    Matrix.empty(3, 0).send(@method).should == Matrix.empty(3, 0)
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/inverse.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -27,7 +27,7 @@
 
   it "raises a ErrDimensionMismatch if the Matrix is not square" do
     lambda{
-      Matrix[ [1,2], [1] ].send(@method)
+      Matrix[ [1,2,3], [1,2,3] ].send(@method)
     }.should raise_error(Matrix::ErrDimensionMismatch)
   end
 

Added: MacRuby/trunk/spec/frozen/library/matrix/shared/rectangular.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/shared/rectangular.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/matrix/shared/rectangular.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,11 @@
+require 'matrix'
+
+describe :matrix_rectangular, :shared => true do
+  it "returns [receiver.real, receiver.imag]" do
+    m = Matrix[ [1.2, Complex(1,2)], [Complex(-2,0.42), 4] ]
+    m.send(@method).should == [m.real, m.imag]
+
+    m = Matrix.empty(3, 0)
+    m.send(@method).should == [m.real, m.imag]
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/matrix/singular_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/matrix/singular_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/matrix/singular_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -2,5 +2,34 @@
 require 'matrix'
 
 describe "Matrix#singular?" do
-  it "needs to be reviewed for spec completeness"
+  ruby_bug "#1020", "1.8.7" do
+    it "returns true for singular matrices" do
+      m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
+      m.singular?.should be_true
+
+      m = Matrix[ [1,2,9], [3,4,9], [1,2,9] ]
+      m.singular?.should be_true
+    end
+
+    it "returns false if the Matrix is regular" do
+      Matrix[ [0,1], [1,0] ].singular?.should be_false
+    end
+  end
+
+  ruby_bug "", "1.8.7" do
+    it "returns false for an empty 0x0 matrix" do
+      Matrix.empty(0,0).singular?.should be_false
+    end
+
+    it "raises an error for rectangular matrices" do
+       lambda {
+         Matrix[[1], [2], [3]].singular?
+       }.should raise_error(Matrix::ErrDimensionMismatch)
+
+       lambda {
+         Matrix.empty(3,0).singular?
+       }.should raise_error(Matrix::ErrDimensionMismatch)
+     end
+  end
+
 end

Modified: MacRuby/trunk/spec/frozen/library/set/sortedset/initialize_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/set/sortedset/initialize_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/set/sortedset/initialize_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -22,9 +22,11 @@
     s.should include(9)
   end
 
-  ruby_bug "redmine #118", "1.9" do
-    it "takes only comparable values" do
-      lambda { SortedSet[3, 4, SortedSet[5, 6]] }.should raise_error(ArgumentError)
+  ruby_version_is ""..."1.9" do
+    ruby_bug "redmine #118", "1.8.7" do
+      it "takes only values which respond to <=>" do
+        lambda { SortedSet[3, 4, SortedSet[5, 6]] }.should raise_error(ArgumentError)
+      end
     end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/socket/ipsocket/getaddress_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/ipsocket/getaddress_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/socket/ipsocket/getaddress_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -13,8 +13,15 @@
     IPSocket.getaddress("0.0.0.0").should == "0.0.0.0"
   end
 
-  it "raises an error on unknown hostnames" do
-    lambda { IPSocket.getaddress("imfakeidontexistanditrynottobeslow.com") }.should raise_error(SocketError)
+  # There is no way to make this fail-proof on all machines, because
+  # DNS servers like opendns return A records for ANY host, including
+  # traditionally invalidly named ones.
+  quarantine! do
+    it "raises an error on unknown hostnames" do
+      lambda {
+        IPSocket.getaddress("rubyspecdoesntexist.fallingsnow.net")
+      }.should raise_error(SocketError)
+    end
   end
 
 end

Modified: MacRuby/trunk/spec/frozen/library/socket/tcpserver/accept_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/tcpserver/accept_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/socket/tcpserver/accept_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -39,12 +39,13 @@
     # kill thread, ensure it dies in a reasonable amount of time
     t.kill
     a = 1
-    while a < 1000
+    while a < 2000
       break unless t.alive?
       Thread.pass
+      sleep 0.2
       a += 1
     end
-    a.should < 1000
+    a.should < 2000
   end
 
   it "can be interrupted by Thread#raise" do

Modified: MacRuby/trunk/spec/frozen/library/socket/tcpserver/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/tcpserver/new_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/socket/tcpserver/new_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -57,9 +57,16 @@
   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)
+
+  # There is no way to make this fail-proof on all machines, because
+  # DNS servers like opendns return A records for ANY host, including
+  # traditionally invalidly named ones.
+  quarantine! do
+    it "raises a SocketError when the host is unknown" do
+      lambda {
+        TCPServer.new("--notavalidname", 4000)
+      }.should raise_error(SocketError)
+    end
   end
 
   it "raises Errno::EADDRINUSE when address is already in use" do

Modified: MacRuby/trunk/spec/frozen/library/socket/udpsocket/send_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/udpsocket/send_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/socket/udpsocket/send_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -24,7 +24,7 @@
     @socket.send("ad hoc", 0, SocketSpecs.hostname,SocketSpecs.port)
     @socket.close
     @server_thread.join
-      
+
     @msg[0].should == "ad hoc"
     @msg[1][0].should == "AF_INET"
     @msg[1][1].should be_kind_of(Fixnum)

Modified: MacRuby/trunk/spec/frozen/library/socket/unixserver/accept_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/socket/unixserver/accept_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/socket/unixserver/accept_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -38,12 +38,13 @@
       # kill thread, ensure it dies in a reasonable amount of time
       t.kill
       a = 1
-      while a < 1000
+      while a < 2000
         break unless t.alive?
         Thread.pass
+        sleep 0.2
         a += 1
       end
-      a.should < 1000
+      a.should < 2000
       server.close
     end
 

Modified: MacRuby/trunk/spec/frozen/library/stringio/pos_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringio/pos_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringio/pos_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -19,4 +19,10 @@
   it "raises an EINVAL if given a negative argument" do
     lambda { @io.pos = -10 }.should  raise_error(Errno::EINVAL)
   end
+  
+  it "updates the current byte offset after reaching EOF" do
+    @io.read
+    @io.pos = 26
+    @io.read(1).should == "r"
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/stringscanner/getbyte_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/getbyte_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/getbyte_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,5 +1,6 @@
 require File.expand_path('../../../spec_helper', __FILE__)
 require File.expand_path('../shared/get_byte', __FILE__)
+require File.expand_path('../shared/extract_range', __FILE__)
 require 'strscan'
 
 describe "StringScanner#getbyte" do
@@ -22,4 +23,6 @@
       $VERBOSE = old
     end
   end
+
+  it_behaves_like :extract_range, :getbyte
 end

Modified: MacRuby/trunk/spec/frozen/library/stringscanner/getch_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/getch_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/getch_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,4 +1,5 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range', __FILE__)
 require 'strscan'
 
 describe "StringScanner#getch" do
@@ -39,13 +40,5 @@
     s.getch.should == nil
   end
 
-  it "always returns instance of String, never a String subclass" do
-    cls = Class.new(String)
-    sub = cls.new("abc")
-
-    s = StringScanner.new(sub)
-    ch = s.getch
-    ch.should_not be_kind_of(cls)
-    ch.should == "a"
-  end
+  it_behaves_like :extract_range, :getch
 end

Modified: MacRuby/trunk/spec/frozen/library/stringscanner/matched_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/matched_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/matched_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,4 +1,5 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
 require 'strscan'
 
 describe "StringScanner#matched" do
@@ -19,6 +20,8 @@
     @s.match?(/\d+/)
     @s.matched.should == nil
   end
+
+  it_behaves_like :extract_range_matched, :matched
 end
 
 describe "StringScanner#matched?" do

Modified: MacRuby/trunk/spec/frozen/library/stringscanner/post_match_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/post_match_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/post_match_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,4 +1,5 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
 require 'strscan'
 
 describe "StringScanner#post_match" do
@@ -22,4 +23,6 @@
     @s.scan(/\s+/)
     @s.post_match.should == nil
   end
+
+  it_behaves_like :extract_range_matched, :post_match
 end

Modified: MacRuby/trunk/spec/frozen/library/stringscanner/pre_match_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/pre_match_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/pre_match_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,4 +1,5 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
 require 'strscan'
 
 describe "StringScanner#pre_match" do
@@ -22,4 +23,6 @@
     @s.scan(/\s+/)
     @s.pre_match.should == nil
   end
+
+  it_behaves_like :extract_range_matched, :pre_match
 end

Modified: MacRuby/trunk/spec/frozen/library/stringscanner/rest_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/rest_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/rest_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1,4 +1,5 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../shared/extract_range_matched', __FILE__)
 require 'strscan'
 
 describe "StringScanner#rest" do
@@ -20,6 +21,9 @@
     @s.terminate
     @s.rest.should == ""
   end
+
+  it_behaves_like :extract_range_matched, :rest
+
 end
 
 describe "StringScanner#rest?" do

Added: MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,22 @@
+describe :extract_range, :shared => true do
+  it "returns an instance of String when passed a String subclass" do
+    cls = Class.new(String)
+    sub = cls.new("abc")
+
+    s = StringScanner.new(sub)
+    ch = s.send(@method)
+    ch.should_not be_kind_of(cls)
+    ch.should be_an_instance_of(String)
+  end
+
+  it "taints the returned String if the input was tainted" do
+    str = 'abc'
+    str.taint
+
+    s = StringScanner.new(str)
+
+    s.send(@method).tainted?.should be_true
+    s.send(@method).tainted?.should be_true
+    s.send(@method).tainted?.should be_true
+  end
+end

Added: MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range_matched.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range_matched.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/shared/extract_range_matched.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -0,0 +1,22 @@
+describe :extract_range_matched, :shared => true do
+  it "returns an instance of String when passed a String subclass" do
+    cls = Class.new(String)
+    sub = cls.new("abc")
+
+    s = StringScanner.new(sub)
+    s.scan(/\w{1}/)
+
+    ch = s.send(@method)
+    ch.should_not be_kind_of(cls)
+    ch.should be_an_instance_of(String)
+  end
+
+  it "taints the returned String if the input was tainted" do
+    str = 'abc'
+    str.taint
+
+    s = StringScanner.new(str)
+    s.scan(/\w{1}/)
+    s.send(@method).tainted?.should be_true
+  end
+end

Modified: MacRuby/trunk/spec/frozen/library/stringscanner/shared/peek.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/stringscanner/shared/peek.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/stringscanner/shared/peek.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -21,10 +21,28 @@
 
   it "raises a RangeError when the passed argument is a Bignum" do
     lambda { @s.send(@method, bignum_value) }.should raise_error(RangeError)
-  end 
-  
+  end
+
   it "raises a TypeError when the passed argument is not a Fixnum" do
     lambda { @s.send(@method, "test") }.should raise_error(TypeError)
   end
-    
+
+  it "returns an instance of String when passed a String subclass" do
+    cls = Class.new(String)
+    sub = cls.new("abc")
+
+    s = StringScanner.new(sub)
+
+    ch = s.send(@method, 1)
+    ch.should_not be_kind_of(cls)
+    ch.should be_an_instance_of(String)
+  end
+
+  it "taints the returned String if the input was tainted" do
+    str = 'abc'
+    str.taint
+
+    s = StringScanner.new(str)
+    s.send(@method, 1).tainted?.should be_true
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/tempfile/shared/length.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/tempfile/shared/length.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/tempfile/shared/length.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -9,9 +9,19 @@
     @tempfile.send(@method).should eql(5)
   end
 
-  it "returns 0 when self is closed" do
-    @tempfile.print("Test!")
-    @tempfile.close
-    @tempfile.send(@method).should eql(0)
+  ruby_version_is ''...'1.9.2' do
+    it "returns 0 when self is closed" do
+      @tempfile.print("Test!")
+      @tempfile.close
+      @tempfile.send(@method).should eql(0)
+    end
   end
+
+  ruby_version_is '1.9.2' do
+    it "returns the size of self even if self is closed" do
+      @tempfile.print("Test!")
+      @tempfile.close
+      @tempfile.send(@method).should eql(5)
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/library/zlib/deflate/params_spec.rb	2010-05-14 17:36:03 UTC (rev 4103)
@@ -13,8 +13,7 @@
     d.params Zlib::BEST_COMPRESSION, Zlib::DEFAULT_STRATEGY
     d << data
 
-    d.finish.should ==
-      "x\001\000\v\000\364\377abcdefghijk\000\000\000\377\377\313\311\005\000#\364\005<"
+    Zlib::Inflate.inflate(d.finish).should == 'abcdefghijklm'
   end
   end
 end

Modified: MacRuby/trunk/spec/frozen/upstream
===================================================================
--- MacRuby/trunk/spec/frozen/upstream	2010-05-14 07:51:31 UTC (rev 4102)
+++ MacRuby/trunk/spec/frozen/upstream	2010-05-14 17:36:03 UTC (rev 4103)
@@ -1 +1 @@
-9940f1d4cc02e606fca503dca8c0c49e6219a0a9
\ No newline at end of file
+2113588fc23df1d2750e2b81d34defa97030cf3b
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100514/779cfb11/attachment-0001.html>


More information about the macruby-changes mailing list