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

source_changes at macosforge.org source_changes at macosforge.org
Mon Dec 6 14:05:51 PST 2010


Revision: 4984
          http://trac.macosforge.org/projects/ruby/changeset/4984
Author:   eloy.de.enige at gmail.com
Date:     2010-12-06 14:05:47 -0800 (Mon, 06 Dec 2010)
Log Message:
-----------
Update RubySpec to d7ff2bee090df4b254f7fcaa70bef6f0e6081dff

Modified Paths:
--------------
    MacRuby/trunk/spec/frozen/core/array/cycle_spec.rb
    MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb
    MacRuby/trunk/spec/frozen/core/array/fill_spec.rb
    MacRuby/trunk/spec/frozen/core/array/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/core/array/flatten_spec.rb
    MacRuby/trunk/spec/frozen/core/array/pop_spec.rb
    MacRuby/trunk/spec/frozen/core/array/reject_spec.rb
    MacRuby/trunk/spec/frozen/core/array/shift_spec.rb
    MacRuby/trunk/spec/frozen/core/array/shuffle_spec.rb
    MacRuby/trunk/spec/frozen/core/array/sort_by_spec.rb
    MacRuby/trunk/spec/frozen/core/array/uniq_spec.rb
    MacRuby/trunk/spec/frozen/core/enumerable/shared/find.rb
    MacRuby/trunk/spec/frozen/core/env/shared/value.rb
    MacRuby/trunk/spec/frozen/core/file/stat/inspect_spec.rb
    MacRuby/trunk/spec/frozen/core/float/round_spec.rb
    MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb
    MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/require_relative_spec.rb
    MacRuby/trunk/spec/frozen/core/module/class_exec_spec.rb
    MacRuby/trunk/spec/frozen/core/module/module_exec_spec.rb
    MacRuby/trunk/spec/frozen/core/numeric/step_spec.rb
    MacRuby/trunk/spec/frozen/core/object/new_spec.rb
    MacRuby/trunk/spec/frozen/core/proc/new_spec.rb
    MacRuby/trunk/spec/frozen/core/random/rand_spec.rb
    MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb
    MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb
    MacRuby/trunk/spec/frozen/core/time/_dump_spec.rb
    MacRuby/trunk/spec/frozen/core/time/_load_spec.rb
    MacRuby/trunk/spec/frozen/language/defined_spec.rb
    MacRuby/trunk/spec/frozen/language/fixtures/defined.rb
    MacRuby/trunk/spec/frozen/library/bigdecimal/mode_spec.rb
    MacRuby/trunk/spec/frozen/library/openstruct/delete_field_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/array_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/class_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/ext/array_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/class_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/io_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/jruby.h
    MacRuby/trunk/spec/frozen/optional/capi/ext/kernel_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/module_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/object_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/rubyspec.h
    MacRuby/trunk/spec/frozen/optional/capi/ext/string_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/symbol_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/globals_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/io_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/kernel_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/module_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/object_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/range_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/spec_helper.rb
    MacRuby/trunk/spec/frozen/optional/capi/string_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/symbol_spec.rb
    MacRuby/trunk/spec/frozen/upstream

Added Paths:
-----------
    MacRuby/trunk/spec/frozen/core/module/shared/class_exec.rb
    MacRuby/trunk/spec/frozen/optional/capi/ext/regexp_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/ext/util_spec.c
    MacRuby/trunk/spec/frozen/optional/capi/regexp_spec.rb
    MacRuby/trunk/spec/frozen/optional/capi/util_spec.rb

Modified: MacRuby/trunk/spec/frozen/core/array/cycle_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/cycle_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/cycle_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -2,14 +2,14 @@
   ruby_version_is '1.8.7' do
     it "returns nil and does nothing for non positive n or empty arrays" do
       [1,2,3].cycle(0){ throw "ball"}.should be_nil
-      [].cycle(0){ throw "ball"}.should be_nil
+      [].cycle(6){ throw "ball"}.should be_nil
     end
 
     it "cycle as many times as requested" do
       [1,2,3].cycle(2).to_a.should == [1,2,3,1,2,3]
     end
 
-    it "loop indefinitely if no n" do
+    it "cycles indefinitely if called without argument" do
       bomb = 10
       [1,2,3].cycle do
         bomb -= 1
@@ -18,6 +18,37 @@
       bomb.should == 0
     end
 
+    it "cycles indefinitely if argument is nil" do
+      bomb = 10
+      [1,2,3].cycle(nil) do
+        bomb -= 1
+        break 42 if bomb <= 0
+      end.should == 42
+      bomb.should == 0
+    end
+
+    it "doesn't rescue StopIteration" do
+      lambda {
+        [1,2,3].cycle do
+          raise StopIteration
+        end
+      }.should raise_error(StopIteration)
+      lambda {
+        [1,2,3].cycle(2) do
+          raise StopIteration
+        end
+      }.should raise_error(StopIteration)
+    end
+
+    it "raises a TypeError if passed a non-Numeric and non-nil argument" do
+      lambda {
+        [1,2,3].cycle("4"){}
+      }.should raise_error(TypeError)
+      lambda {
+        [1,2,3].cycle(false){}
+      }.should raise_error(TypeError)
+    end
+
     it "yields successive elements of the array repeatedly" do
       b = []
       [1,2,3].cycle do |elem|

Modified: MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/delete_if_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -39,12 +39,18 @@
     it "raises a TypeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.delete_if {} }.should raise_error(TypeError)
     end
+    it "raises a TypeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(TypeError)
+    end
   end
 
   ruby_version_is '1.9' do
     it "raises a RuntimeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.delete_if {} }.should raise_error(RuntimeError)
     end
+    it "raises a RuntimeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(RuntimeError)
+    end
   end
 
   it "keeps tainted status" do

Modified: MacRuby/trunk/spec/frozen/core/array/fill_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/fill_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/fill_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -47,12 +47,18 @@
     it "raises a TypeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.fill('x') }.should raise_error(TypeError)
     end
+    it "raises a TypeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(TypeError)
+    end
   end
 
   ruby_version_is '1.9' do
     it "raises a RuntimeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.fill('x') }.should raise_error(RuntimeError)
     end
+    it "raises a RuntimeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(RuntimeError)
+    end
   end
 
   it "raises an ArgumentError if 4 or more arguments are passed when no block given" do

Modified: MacRuby/trunk/spec/frozen/core/array/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/fixtures/classes.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/fixtures/classes.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -35,6 +35,12 @@
     frozen_array
   end
 
+  def self.empty_frozen_array
+    frozen_array = []
+    frozen_array.freeze
+    frozen_array
+  end
+
   def self.recursive_array
     a = [1, 'two', 3.0]
     5.times { a << a }

Modified: MacRuby/trunk/spec/frozen/core/array/flatten_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/flatten_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/flatten_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -206,6 +206,7 @@
     # see [ruby-core:23663]
     it "raises a RuntimeError on frozen arrays when the array would not be modified" do
       lambda { ArraySpecs.frozen_array.flatten! }.should raise_error(RuntimeError)
+      lambda { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(RuntimeError)
     end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/array/pop_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/pop_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/pop_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -42,6 +42,9 @@
     it "raises a TypeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.pop }.should raise_error(TypeError)
     end
+    it "raises a TypeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.pop }.should raise_error(TypeError)
+    end
   end
 
   ruby_version_is '1.9' do
@@ -49,6 +52,10 @@
       lambda { ArraySpecs.frozen_array.pop }.should raise_error(RuntimeError)
     end
 
+    it "raises a RuntimeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.pop }.should raise_error(RuntimeError)
+    end
+
     it "keeps untrusted status" do
       a = [1, 2].untrust
       a.pop

Modified: MacRuby/trunk/spec/frozen/core/array/reject_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/reject_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/reject_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -100,12 +100,18 @@
     it "raises a TypeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.reject! {} }.should raise_error(TypeError)
     end
+    it "raises a TypeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(TypeError)
+    end
   end
 
   ruby_version_is "1.9" do
     it "raises a RuntimeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.reject! {} }.should raise_error(RuntimeError)
     end
+    it "raises a RuntimeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(RuntimeError)
+    end
   end
   
   it_behaves_like :enumeratorize, :reject!

Modified: MacRuby/trunk/spec/frozen/core/array/shift_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/shift_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/shift_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -34,12 +34,18 @@
     it "raises a TypeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.shift }.should raise_error(TypeError)
     end
+    it "raises a TypeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.shift }.should raise_error(TypeError)
+    end
   end
 
   ruby_version_is "1.9" do
     it "raises a RuntimeError on a frozen array" do
       lambda { ArraySpecs.frozen_array.shift }.should raise_error(RuntimeError)
     end
+    it "raises a RuntimeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.shift }.should raise_error(RuntimeError)
+    end
   end
   
   ruby_version_is '' ... '1.8.7' do

Modified: MacRuby/trunk/spec/frozen/core/array/shuffle_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/shuffle_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/shuffle_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -45,13 +45,15 @@
 
     ruby_version_is ""..."1.9" do
       it "raises a TypeError on a frozen array" do
-        lambda { ArraySpecs.frozen_array.reverse! }.should raise_error(TypeError)
+        lambda { ArraySpecs.frozen_array.shuffle! }.should raise_error(TypeError)
+        lambda { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(TypeError)
       end
     end
 
     ruby_version_is "1.9" do
       it "raises a RuntimeError on a frozen array" do
         lambda { ArraySpecs.frozen_array.shuffle! }.should raise_error(RuntimeError)
+        lambda { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(RuntimeError)
       end
     end
   end

Modified: MacRuby/trunk/spec/frozen/core/array/sort_by_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/sort_by_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/sort_by_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -24,23 +24,12 @@
       a.should be_kind_of(Array)
     end
 
-    ruby_version_is '' ... '1.9' do
-      it "raises a TypeError on a frozen array" do
-        lambda { ArraySpecs.frozen_array.sort_by! {} }.should raise_error(TypeError)
-      end
-
-      it "temporarily freezes self and recovers after sorted" do
-        a = [1, 2, 3]
-        a.sort_by! { |x,y| a.frozen?.should == true; x <=> y }
-        a.frozen?.should == false
-      end
+    it "raises a RuntimeError on a frozen array" do
+      lambda { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(RuntimeError)
     end
 
-    ruby_version_is '1.9' do
-      it "raises a RuntimeError on a frozen array" do
-        lambda { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(RuntimeError)
-      end
-
+    it "raises a RuntimeError on an empty frozen array" do
+      lambda { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(RuntimeError)
     end
 
     it "returns the specified value when it would break in the given block" do

Modified: MacRuby/trunk/spec/frozen/core/array/uniq_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/array/uniq_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/array/uniq_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -137,7 +137,12 @@
     # see [ruby-core:23666]
     it "raises a RuntimeError on a frozen array when the array would not be modified" do
       lambda { ArraySpecs.frozen_array.uniq!}.should raise_error(RuntimeError)
+      lambda { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(RuntimeError)
     end
+
+    it "doesn't yield to the block on a frozen array" do
+      lambda { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should raise_error(RuntimeError)
+    end
   end
 
 end

Modified: MacRuby/trunk/spec/frozen/core/enumerable/shared/find.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/enumerable/shared/find.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/enumerable/shared/find.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -3,6 +3,7 @@
   before :each do
     @elements = [2, 4, 6, 8, 10]
     @numerous = EnumerableSpecs::Numerous.new(*@elements)
+    @empty = []
   end
   
   it "passes each entry in enum to block while block when block is false" do
@@ -40,6 +41,11 @@
     @numerous.send(@method, fail_proc) {|e| false }.should == "cheeseburgers"
   end
   
+  it "calls the ifnone proc when there are no elements" do
+    fail_proc = lambda { "yay" }
+    @empty.send(@method, fail_proc) {|e| true}.should == "yay"
+  end
+  
   ruby_version_is "" ... "1.8.7" do
     it "raises a LocalJumpError if no block given" do
       lambda { @numerous.send(@method) }.should raise_error(LocalJumpError)

Modified: MacRuby/trunk/spec/frozen/core/env/shared/value.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/env/shared/value.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/env/shared/value.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -8,4 +8,11 @@
   it "returns false if ENV doesn't have the value" do
     ENV.send(@method, "this_value_should_never_exist").should == false
   end
+  
+  platform_is :windows do
+    it "looks up values case-insensitively" do
+      ENV["FOO"] = "bar"
+      ENV.send(@method, "Foo").should == "bar"
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/file/stat/inspect_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/file/stat/inspect_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/file/stat/inspect_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -10,13 +10,10 @@
   after :each do
     rm_r @file
   end
-  
+
   it "produces a nicely formatted description of a File::Stat object" do
-    st = File.stat(@file)  
-    #p "#<File::Stat dev=0x#{st.dev.to_s(16)}, ino=#{st.ino}, mode=#{sprintf("%06s", st.mode.to_s(8))}, nlink=#{st.nlink}, uid=#{st.uid}, gid=#{st.gid}, rdev=0x#{st.rdev.to_s(16)}, size=#{st.size}, blksize=#{st.blksize}, blocks=#{st.blocks}, atime=#{st.atime}, mtime=#{st.mtime}, ctime=#{st.ctime}>"
-    st.inspect.should == "#<File::Stat dev=0x#{st.dev.to_s(16)}, ino=#{st.ino}, mode=#{sprintf("%07d", st.mode.to_s(8).to_i)}, nlink=#{st.nlink}, uid=#{st.uid}, gid=#{st.gid}, rdev=0x#{st.rdev.to_s(16)}, size=#{st.size}, blksize=#{st.blksize}, blocks=#{st.blocks}, atime=#{st.atime}, mtime=#{st.mtime}, ctime=#{st.ctime}>"
-    
+    st = File.stat(@file)
+    expected = "#<File::Stat dev=0x#{st.dev.to_s(16)}, ino=#{st.ino}, mode=#{sprintf("%07o", st.mode)}, nlink=#{st.nlink}, uid=#{st.uid}, gid=#{st.gid}, rdev=0x#{st.rdev.to_s(16)}, size=#{st.size}, blksize=#{st.blksize}, blocks=#{st.blocks}, atime=#{st.atime}, mtime=#{st.mtime}, ctime=#{st.ctime}>"
+    st.inspect.should == expected
   end
-
-
 end

Modified: MacRuby/trunk/spec/frozen/core/float/round_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/float/round_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/float/round_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -6,5 +6,6 @@
     0.4.round.should == 0
     -2.8.round.should == -3
     0.0.round.should == 0
+    0.49999999999999994.round.should == 0 # see http://jira.codehaus.org/browse/JRUBY-5048
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/io/foreach_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -9,6 +9,17 @@
     ScratchPad.record []
   end
 
+  ruby_version_is "1.9" do
+    before :each do
+      Encoding.default_external = Encoding::UTF_8
+      @orig_exteenc = Encoding.default_external
+    end
+
+    after :each do
+      Encoding.default_external = @orig_exteenc
+    end
+  end
+
   it "raises TypeError if the first parameter is nil" do
     lambda { IO.foreach(nil) {} }.should raise_error(TypeError)
   end

Modified: MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/io/readlines_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -11,6 +11,17 @@
     @io.close unless @io.closed?
   end
 
+  ruby_version_is "1.9" do
+    before :each do
+      Encoding.default_external = Encoding::UTF_8
+      @orig_exteenc = Encoding.default_external
+    end
+
+    after :each do
+      Encoding.default_external = @orig_exteenc
+    end
+  end
+
   it "raises an IOError if the stream is closed" do
     @io.close
     lambda { @io.readlines }.should raise_error(IOError)

Modified: MacRuby/trunk/spec/frozen/core/kernel/require_relative_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/require_relative_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/kernel/require_relative_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -1,7 +1,153 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../../../fixtures/code_loading', __FILE__)
 
 ruby_version_is "1.9" do
-  describe "Kernel.require_relative" do
+  describe "Kernel#require_relative" do
     it "needs to be reviewed for spec completeness"
+
+    before :each do
+      CodeLoadingSpecs.spec_setup
+      @dir = "../../fixtures/code"
+      @abs_dir = File.expand_path(@dir, File.dirname(__FILE__))
+      @path = "#{@dir}/load_fixture.rb"
+      @abs_path = File.expand_path(@path, File.dirname(__FILE__))
+    end
+
+    after :each do
+      CodeLoadingSpecs.spec_cleanup
+    end
+
+    it "loads a path relative to the current file" do
+      require_relative(@path).should be_true
+      ScratchPad.recorded.should == [:loaded]
+    end
+
+    it "loads a file defining many methods" do
+      require_relative("#{@dir}/methods_fixture.rb").should be_true
+      ScratchPad.recorded.should == [:loaded]
+    end
+
+    it "raises a LoadError if the file does not exist" do
+      lambda { require_relative("#{@dir}/nonexistent.rb") }.should raise_error(LoadError)
+      ScratchPad.recorded.should == []
+    end
+
+    it "calls #to_str on non-String objects" do
+      name = mock("load_fixture.rb mock")
+      name.should_receive(:to_str).and_return(@path)
+      require_relative(name).should be_true
+      ScratchPad.recorded.should == [:loaded]
+    end
+
+    it "raises a TypeError if argument does not respond to #to_str" do
+      lambda { require_relative(nil) }.should raise_error(TypeError)
+      lambda { require_relative(42) }.should raise_error(TypeError)
+      lambda {
+        require_relative([@path, at path])
+      }.should raise_error(TypeError)
+    end
+
+    it "raises a TypeError if passed an object that has #to_s but not #to_str" do
+      name = mock("load_fixture.rb mock")
+      name.stub!(:to_s).and_return(@path)
+      lambda { require_relative(name) }.should raise_error(TypeError)
+    end
+
+    it "raises a TypeError if #to_str does not return a String" do
+      name = mock("#to_str returns nil")
+      name.should_receive(:to_str).at_least(1).times.and_return(nil)
+      lambda { require_relative(name) }.should raise_error(TypeError)
+    end
+
+    it "calls #to_path on non-String objects" do
+      name = mock("load_fixture.rb mock")
+      name.should_receive(:to_path).and_return(@path)
+      require_relative(name).should be_true
+      ScratchPad.recorded.should == [:loaded]
+    end
+
+    it "calls #to_str on non-String objects returned by #to_path" do
+      name = mock("load_fixture.rb mock")
+      to_path = mock("load_fixture_rb #to_path mock")
+      name.should_receive(:to_path).and_return(to_path)
+      to_path.should_receive(:to_str).and_return(@path)
+      require_relative(name).should be_true
+      ScratchPad.recorded.should == [:loaded]
+    end
+
+    describe "(file extensions)" do
+      it "loads a .rb extensioned file when passed a non-extensioned path" do
+        require_relative("#{@dir}/load_fixture").should be_true
+        ScratchPad.recorded.should == [:loaded]
+      end
+
+      it "loads a .rb extensioned file when a C-extension file of the same name is loaded" do
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.bundle"
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.dylib"
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.so"
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.dll"
+        require_relative(@path).should be_true
+        ScratchPad.recorded.should == [:loaded]
+      end
+
+      it "does not load a C-extension file if a .rb extensioned file is already loaded" do
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.rb"
+        require_relative("#{@dir}/load_fixture").should be_false
+        ScratchPad.recorded.should == []
+      end
+
+      it "loads a .rb extensioned file when passed a non-.rb extensioned path" do
+        require_relative("#{@dir}/load_fixture.ext").should be_true
+        ScratchPad.recorded.should == [:loaded]
+        $LOADED_FEATURES.should include "#{@abs_dir}/load_fixture.ext.rb"
+      end
+
+      it "loads a .rb extensioned file when a complex-extensioned C-extension file of the same name is loaded" do
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.bundle"
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.dylib"
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.so"
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.dll"
+        require_relative("#{@dir}/load_fixture.ext").should be_true
+        ScratchPad.recorded.should == [:loaded]
+        $LOADED_FEATURES.should include "#{@abs_dir}/load_fixture.ext.rb"
+      end
+
+      it "does not load a C-extension file if a complex-extensioned .rb file is already loaded" do
+        $LOADED_FEATURES << "#{@abs_dir}/load_fixture.ext.rb"
+        require_relative("#{@dir}/load_fixture.ext").should be_false
+        ScratchPad.recorded.should == []
+      end
+    end
+
+    describe "($LOAD_FEATURES)" do
+      it "stores an absolute path" do
+        require_relative(@path).should be_true
+        $LOADED_FEATURES.should == [@abs_path]
+      end
+
+      it "does not store the path if the load fails" do
+        lambda { require_relative("#{@dir}/raise_fixture.rb") }.should raise_error(RuntimeError)
+        $LOADED_FEATURES.should == []
+      end
+
+      it "does not load an absolute path that is already stored" do
+        $LOADED_FEATURES << @abs_path
+        require_relative(@path).should be_false
+        ScratchPad.recorded.should == []
+      end
+
+      it "adds the suffix of the resolved filename" do
+        require_relative("#{@dir}/load_fixture").should be_true
+        $LOADED_FEATURES.should == ["#{@abs_dir}/load_fixture.rb"]
+      end
+
+      it "loads a path for a file already loaded with a relative path" do
+        $LOAD_PATH << s = File.expand_path(@dir)
+        $LOADED_FEATURES << "load_fixture.rb" << "load_fixture"
+        require_relative(@path).should be_true
+        $LOADED_FEATURES.should include(@abs_path)
+        ScratchPad.recorded.should == [:loaded]
+      end
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/core/module/class_exec_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/class_exec_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/module/class_exec_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -1,7 +1,7 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/class_exec', __FILE__)
 
-ruby_version_is "1.9" do
-  describe "Module#class_exec" do
-    it "needs to be reviewed for spec completeness"
-  end
+describe "Module#class_exec" do
+  it_behaves_like :module_class_exec, :class_exec
 end

Modified: MacRuby/trunk/spec/frozen/core/module/module_exec_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/module_exec_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/module/module_exec_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -1,7 +1,7 @@
 require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+require File.expand_path('../shared/class_exec', __FILE__)
 
-ruby_version_is "1.9" do
-  describe "Module#module_exec" do
-    it "needs to be reviewed for spec completeness"
-  end
+describe "Module#class_exec" do
+  it_behaves_like :module_class_exec, :module_exec
 end

Added: MacRuby/trunk/spec/frozen/core/module/shared/class_exec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/module/shared/class_exec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/core/module/shared/class_exec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -0,0 +1,24 @@
+describe :module_class_exec, :shared => true do
+  it "does not add defined methods to other classes" do
+    FalseClass.class_exec do
+      def foo
+        'foo'
+      end
+    end
+    lambda {42.foo}.should raise_error(NoMethodError)
+  end
+
+  it "defines method in the receiver's scope" do
+    ModuleSpecs::Subclass.send(@method) { def foo; end }
+    ModuleSpecs::Subclass.new.respond_to?(:foo).should == true
+  end
+  
+  it "evaluates a given block in the context of self" do
+    ModuleSpecs::Subclass.send(@method) { self }.should == ModuleSpecs::Subclass
+    ModuleSpecs::Subclass.new.send(@method) { 1 + 1 }.should == 2
+  end
+  
+  it "raises an LocalJumpError when no block is given" do
+    lambda { ModuleSpecs::Subclass.send(@method) }.should raise_error(LocalJumpError)
+  end
+end

Modified: MacRuby/trunk/spec/frozen/core/numeric/step_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/numeric/step_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/numeric/step_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -64,7 +64,7 @@
     values.should == [@obj, @obj, @obj]
   end
   
-  it "decrements self (using #-) until self < stop when step < 0" do
+  it "decrements self (using #+) until self < stop when step < 0" do
     values = []
     
     @stop = mock("Stop value")
@@ -150,6 +150,33 @@
   end
 end
 
+describe "Numeric#step with [stop, +infinity]" do
+  ruby_bug "#781", "1.8.7" do
+    it "yields once if self < stop" do
+      result = []
+      42.step(100, 1.0/0.0)              { |x| result << x }
+      42.step(1.0/0.0, 1.0/0.0)          { |x| result << x }
+      result.should == [42, 42]
+    end
+
+    it "yields once when self equals stop" do
+      result = []
+      42.step(42, 1.0/0.0)               { |x| result << x }
+      (1.0/0.0).step(1.0/0.0, 1.0/0.0)   { |x| result << x }
+      result.should == [42, 1.0/0.0]
+    end
+  end
+
+  ruby_bug "#3945", "1.9.2" do
+    it "does not yield when self > stop" do
+      result = []
+      100.step(42, 1.0/0.0)              { |x| result << x }
+      42.step(-1.0/0.0, 1.0/0.0)         { |x| result << x }
+      result.should == []
+    end
+  end
+end
+
 describe "Numeric#step with [stop, +step] when self, stop or step is a Float" do
   it "yields while increasing self by step until stop is reached" do
     result = []
@@ -170,6 +197,33 @@
   end
 end
 
+describe "Numeric#step with [stop, -infinity]" do
+  ruby_bug "#3945", "1.9.2" do
+    it "yields once if self > stop" do
+      result = []
+      42.step(6, -1.0/0.0)               { |x| result << x }
+      42.step(-1.0/0.0, -1.0/0.0)        { |x| result << x }
+      result.should == [42, 42]
+    end
+
+    it "yields once when self equals stop" do
+      result = []
+      42.step(42, -1.0/0.0)              { |x| result << x }
+      (1.0/0.0).step(1.0/0.0, -1.0/0.0)  { |x| result << x }
+      result.should == [42, 1.0/0.0]
+    end
+  end
+
+  ruby_bug "#781", "1.8.7" do
+    it "does not yield when self > stop" do
+      result = []
+      42.step(100, -1.0/0.0)             { |x| result << x }
+      42.step(1.0/0.0, -1.0/0.0)         { |x| result << x }
+      result.should == []
+    end
+  end
+end
+
 describe "Numeric#step with [stop, -step] when self, stop or step is a Float" do
   it "yields while decreasing self by step until stop is reached" do
     result = []

Modified: MacRuby/trunk/spec/frozen/core/object/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/object/new_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/object/new_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -5,12 +5,20 @@
     Object.new.should be_kind_of(Object)
   end
 
-  ruby_version_is "1.9" do # Ref: [redmine:2451]
+  ruby_version_is "1.9.1".."1.9.2" do # Ref: [redmine:2451]
     it "accepts any number of arguments" do
       lambda {
         Object.new("This", "makes it easier", "to call super", "from other constructors")
       }.should_not raise_error
     end
   end
+
+  ruby_version_is "1.9.3" do # Ref: [redmine:2451]
+    it "doesn't accept arguments" do
+      lambda {
+        Object.new("This", "makes it easier", "to call super", "from other constructors")
+      }.should raise_error
+    end
+  end
 end
 

Modified: MacRuby/trunk/spec/frozen/core/proc/new_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/proc/new_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/proc/new_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -6,7 +6,47 @@
     Proc.new { }.call.should == nil
     Proc.new { "hello" }.call.should == "hello"
   end
+  
+  describe "called on a subclass of Proc" do
+    before :each do
+      @subclass = Class.new(Proc) do
+        attr_reader :ok
+        def initialize
+          @ok = true
+          super
+        end
+      end
+    end
+    
+    it "returns an instance of the subclass" do
+      proc = @subclass.new {"hello"}
+      
+      proc.class.should == @subclass
+      proc.call.should == "hello"
+      proc.ok.should == true
+    end
+    
+    # JRUBY-5026
+    describe "using a reified block parameter" do
+      it "returns an instance of the subclass" do
+        cls = Class.new do
+          def self.subclass=(subclass)
+            @subclass = subclass
+          end
+          def self.foo(&block)
+            @subclass.new(&block)
+          end
+        end
+        cls.subclass = @subclass
+        proc = cls.foo {"hello"}
 
+        proc.class.should == @subclass
+        proc.call.should == "hello"
+        proc.ok.should == true
+      end
+    end
+  end
+
   # This raises a ThreadError on 1.8 HEAD. Reported as bug #1707
   it "raises a LocalJumpError when context of the block no longer exists" do
     def some_method

Modified: MacRuby/trunk/spec/frozen/core/random/rand_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/random/rand_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/random/rand_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -198,10 +198,9 @@
       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)
-      end.should_not raise_error      
+    it "considers Integers as Floats if one end point is a float" do
+      Random.new(42).rand(0.0..1).should be_kind_of(Float)
+      Random.new(42).rand(0..1.0).should be_kind_of(Float)
     end
 
     it "raises an ArgumentError when the startpoint lacks #+ and #- methods" do

Modified: MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/string/inspect_spec_disabled.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -3,6 +3,17 @@
 require File.expand_path('../fixtures/classes.rb', __FILE__)
 
 describe "String#inspect" do
+  ruby_version_is "1.9" do
+    before :each do
+      Encoding.default_external = Encoding::UTF_8
+      @orig_exteenc = Encoding.default_external
+    end
+
+    after :each do
+      Encoding.default_external = @orig_exteenc
+    end
+  end
+
   it "taints the result if self is tainted" do
     "foo".taint.inspect.tainted?.should == true
     "foo\n".taint.inspect.tainted?.should == true

Modified: MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/string/to_f_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -12,6 +12,8 @@
 
    ".5".to_f.should == 0.5
    ".5e1".to_f.should == 5.0
+   "5e".to_f.should == 5.0
+   "5E".to_f.should == 5.0
   end
 
   it "treats special float value strings as characters" do

Modified: MacRuby/trunk/spec/frozen/core/time/_dump_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/time/_dump_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/time/_dump_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -43,5 +43,11 @@
            @t.usec
     low.should == @s.unpack("VV").last
   end
+  
+  it "dumps like MRI's marshaled time format" do
+    t = Time.utc(2000, 1, 15, 20, 1, 1, 203).localtime
+  
+    t._dump.should == "\364\001\031\200\313\000\020\004"
+  end
 end
 

Modified: MacRuby/trunk/spec/frozen/core/time/_load_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/time/_load_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/core/time/_load_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -32,6 +32,24 @@
 
     Time._load([high, low].pack("VV")).should == t
   end
+  
+  ruby_version_is ''...'1.9' do
+    it "loads MRI's marshaled time format" do
+      t = Marshal.load("\004\bu:\tTime\r\320\246\e\200\320\001\r\347")
+      t.utc
+    
+      t.to_s.should == "Fri Oct 22 16:57:48 UTC 2010"
+    end
+  end
+  
+  ruby_version_is '1.9' do
+    it "loads MRI's marshaled time format" do
+      t = Marshal.load("\004\bu:\tTime\r\320\246\e\200\320\001\r\347")
+      t.utc
+
+      t.to_s.should == "2010-10-22 16:57:48 UTC"
+    end
+  end
 end
 
 describe "Time._load" do

Modified: MacRuby/trunk/spec/frozen/language/defined_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/defined_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/language/defined_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -1263,4 +1263,10 @@
       DefinedSpecs::Super.new.define_method_block_args.should == "super"
     end
   end
+  
+  describe "within an included module's method" do
+    it "returns 'super' when a superclass method exists in the including hierarchy" do
+      DefinedSpecs::Child.new.defined_super.should == "super"
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/language/fixtures/defined.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/fixtures/defined.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/language/fixtures/defined.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -102,10 +102,16 @@
 
   module Mixin
     MixinConstant = 42
+    
+    def defined_super
+      defined? super()
+    end
   end
 
   class Parent
     ParentConstant = 42
+    
+    def defined_super; end
   end
 
   class Child < Parent
@@ -124,6 +130,10 @@
     def self.module_constant_defined
       defined? MixinConstant
     end
+    
+    def defined_super
+      super
+    end
   end
 
   class Superclass

Modified: MacRuby/trunk/spec/frozen/library/bigdecimal/mode_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/bigdecimal/mode_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/library/bigdecimal/mode_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -24,23 +24,42 @@
     end
   end
 
-  ruby_version_is "1.9" do
+  ruby_version_is "1.9" ... "1.9.3" do
     it "returns Infinity when too big" do
       BigDecimal("1E11111111111111111111").should == BigDecimal("Infinity")
       (BigDecimal("1E11111111111")*BigDecimal("1E11111111111")).should ==
         BigDecimal("Infinity")
     end
+
+    it "raise an exception if the flag is true" do
+      BigDecimal::mode(BigDecimal::EXCEPTION_NaN, true)
+      lambda { BigDecimal("NaN").add(BigDecimal("1"),0) }.should raise_error(FloatDomainError)
+      BigDecimal::mode(BigDecimal::EXCEPTION_INFINITY, true)
+      lambda { BigDecimal("0").add(BigDecimal("Infinity"),0) }.should raise_error(FloatDomainError)
+      BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE, true)
+      lambda { BigDecimal("1").quo(BigDecimal("0")) }.should raise_error(FloatDomainError)
+      BigDecimal::mode(BigDecimal::EXCEPTION_OVERFLOW, true)
+      lambda { BigDecimal("1E11111111111111111111") }.should raise_error(FloatDomainError)
+      lambda { (BigDecimal("1E11111111111")*BigDecimal("1E11111111111")) }.should raise_error(FloatDomainError)
+    end
   end
 
-  it "raise an exception if the flag is true" do
-    BigDecimal::mode(BigDecimal::EXCEPTION_NaN, true)
-    lambda { BigDecimal("NaN").add(BigDecimal("1"),0) }.should raise_error(FloatDomainError)
-    BigDecimal::mode(BigDecimal::EXCEPTION_INFINITY, true)
-    lambda { BigDecimal("0").add(BigDecimal("Infinity"),0) }.should raise_error(FloatDomainError)
-    BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE, true)
-    lambda { BigDecimal("1").quo(BigDecimal("0")) }.should raise_error(FloatDomainError)
-    BigDecimal::mode(BigDecimal::EXCEPTION_OVERFLOW, true)
-    lambda { BigDecimal("1E11111111111111111111") }.should raise_error(FloatDomainError)
-    lambda { (BigDecimal("1E11111111111")*BigDecimal("1E11111111111")) }.should raise_error(FloatDomainError)
+  ruby_version_is "1.9.3" do
+    it "returns Infinity when too big" do
+      BigDecimal("1E11111111111111111111").should == BigDecimal("Infinity")
+      (BigDecimal("1E1000000000000000000")**10).should == BigDecimal("Infinity")
+    end
+
+    it "raise an exception if the flag is true" do
+      BigDecimal::mode(BigDecimal::EXCEPTION_NaN, true)
+      lambda { BigDecimal("NaN").add(BigDecimal("1"),0) }.should raise_error(FloatDomainError)
+      BigDecimal::mode(BigDecimal::EXCEPTION_INFINITY, true)
+      lambda { BigDecimal("0").add(BigDecimal("Infinity"),0) }.should raise_error(FloatDomainError)
+      BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE, true)
+      lambda { BigDecimal("1").quo(BigDecimal("0")) }.should raise_error(FloatDomainError)
+      BigDecimal::mode(BigDecimal::EXCEPTION_OVERFLOW, true)
+      lambda { BigDecimal("1E11111111111111111111") }.should raise_error(FloatDomainError)
+      lambda { (BigDecimal("1E1000000000000000000")**10) }.should raise_error(FloatDomainError)
+    end
   end
 end

Modified: MacRuby/trunk/spec/frozen/library/openstruct/delete_field_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/library/openstruct/delete_field_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/library/openstruct/delete_field_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -11,9 +11,19 @@
     @os.send(:table)[:name].should be_nil
   end
   
-  it "does not remove the accessor methods" do
-    @os.delete_field(:name)
-    @os.respond_to?(:name).should be_true
-    @os.respond_to?(:name=).should be_true
+  ruby_version_is ""..."1.9.3" do
+    it "does not remove the accessor methods" do
+      @os.delete_field(:name)
+      @os.respond_to?(:name).should be_true
+      @os.respond_to?(:name=).should be_true
+    end
   end
+  
+  ruby_version_is "1.9.3" do
+    it "does remove the accessor methods" do
+      @os.delete_field(:name)
+      @os.respond_to?(:name).should be_false
+      @os.respond_to?(:name=).should be_false
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/optional/capi/array_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/array_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/array_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -17,8 +17,28 @@
     it "returns an empty array" do
       @s.rb_ary_new2(5).should == []
     end
+
+    ruby_version_is ""..."1.9" do
+      it "returns an array which can be assigned to from C" do
+        ary = @s.rb_ary_new2(5)
+        @s.rb_ary_new2_assign(ary, :set, 5)
+        ary.should == [:set] * 5
+      end
+    end
   end
 
+  describe "rb_ary_new3" do
+    it "returns an array with the passed cardinality and varargs" do
+      @s.rb_ary_new3(1,2,3).should == [1,2,3]
+    end
+  end
+
+  describe "rb_ary_new4" do
+    it "returns returns an array with the passed values" do
+      @s.rb_ary_new4(1,2,3).should == [1,2,3]
+    end
+  end
+
   describe "rb_ary_push" do
     it "adds an element to the array" do
       @s.rb_ary_push([], 4).should == [4]
@@ -257,4 +277,12 @@
       ary.should == [1, 2, 3, 4]
     end
   end
+
+  describe "rb_ary_delete_at" do
+    it "removes an element from an array at the specified index" do
+      ary = [1, 2, 3, 4]
+      @s.rb_ary_delete_at(ary, ary.size - 1).should == 4
+      ary.should == [1, 2, 3]
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/optional/capi/class_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/class_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/class_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -137,6 +137,18 @@
     end
   end
 
+  describe "rb_class_name" do
+    it "returns the class name" do
+      @s.rb_class2name(CApiClassSpecs).should == "CApiClassSpecs"
+    end
+  end
+
+  describe "rb_path2class" do
+    it "returns the class" do
+      @s.rb_path2class("CApiClassSpecs::Sub").should == CApiClassSpecs::Sub
+    end
+  end
+
   describe "rb_cvar_defined" do
     it "returns false when the class variable is not defined" do
       @s.rb_cvar_defined(CApiClassSpecs::CVars, "@@nocvar").should be_false

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/array_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/array_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/array_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -105,6 +105,12 @@
 }
 #endif
 
+#ifdef HAVE_RB_ARY_DELETE_AT
+static VALUE array_spec_rb_ary_delete_at(VALUE self, VALUE array, VALUE index) {
+  return rb_ary_delete_at(array, NUM2LONG(index));
+}
+#endif
+
 #ifdef HAVE_RB_ARY_DUP
 static VALUE array_spec_rb_ary_dup(VALUE self, VALUE array) {
   return rb_ary_dup(array);
@@ -141,8 +147,32 @@
 static VALUE array_spec_rb_ary_new2(VALUE self, VALUE length) {
   return rb_ary_new2(NUM2LONG(length));
 }
+
+#ifdef HAVE_RARRAY
+static VALUE array_spec_rb_ary_new2_assign(VALUE self, VALUE ary, VALUE content, VALUE length) {
+  int i;
+  for (i = 0; i < NUM2INT(length); i++) {
+    RARRAY(ary)->ptr[i] = content;
+  }
+  RARRAY(ary)->len = i;
+  return ary;
+}
 #endif
+#endif
 
+#ifdef HAVE_RB_ARY_NEW3
+static VALUE array_spec_rb_ary_new3(VALUE self, VALUE first, VALUE second, VALUE third) {
+  return rb_ary_new3(3, first, second, third);
+}
+#endif
+
+#ifdef HAVE_RB_ARY_NEW4
+static VALUE array_spec_rb_ary_new4(VALUE self, VALUE first, VALUE second, VALUE third) {
+  VALUE values[3] = {first, second, third};
+  return rb_ary_new4(3, values);
+}
+#endif
+
 #ifdef HAVE_RB_ARY_POP
 static VALUE array_spec_rb_ary_pop(VALUE self, VALUE array) {
   return rb_ary_pop(array);
@@ -234,6 +264,10 @@
   rb_define_method(cls, "rb_ary_delete", array_spec_rb_ary_delete, 2);
 #endif
 
+#ifdef HAVE_RB_ARY_DELETE_AT
+  rb_define_method(cls, "rb_ary_delete_at", array_spec_rb_ary_delete_at, 2);
+#endif
+
 #ifdef HAVE_RB_ARY_DUP
   rb_define_method(cls, "rb_ary_dup", array_spec_rb_ary_dup, 1);
 #endif
@@ -256,8 +290,19 @@
 
 #ifdef HAVE_RB_ARY_NEW2
   rb_define_method(cls, "rb_ary_new2", array_spec_rb_ary_new2, 1);
+#ifdef HAVE_RARRAY
+  rb_define_method(cls, "rb_ary_new2_assign", array_spec_rb_ary_new2_assign, 3);
 #endif
+#endif
 
+#ifdef HAVE_RB_ARY_NEW3
+  rb_define_method(cls, "rb_ary_new3", array_spec_rb_ary_new3, 3);
+#endif
+
+#ifdef HAVE_RB_ARY_NEW4
+  rb_define_method(cls, "rb_ary_new4", array_spec_rb_ary_new4, 3);
+#endif
+
 #ifdef HAVE_RB_ARY_POP
   rb_define_method(cls, "rb_ary_pop", array_spec_rb_ary_pop, 1);
 #endif

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/class_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/class_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/class_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -19,12 +19,24 @@
 }
 #endif
 
+#ifdef HAVE_RB_CLASS_NAME
+static VALUE class_spec_rbclass_name(VALUE self, VALUE klass) {
+  return rb_class_name(klass);
+}
+#endif
+
 #ifdef HAVE_RB_CLASS2NAME
 static VALUE class_spec_rbclass2name(VALUE self, VALUE klass) {
   return rb_str_new2( rb_class2name(klass) );
 }
 #endif
 
+#ifdef HAVE_RB_PATH2CLASS
+static VALUE class_spec_rb_path2class(VALUE self, VALUE path) {
+  return rb_path2class(RSTRING_PTR(path));
+}
+#endif
+
 #ifdef HAVE_RB_CLASS_INHERITED
 static VALUE class_spec_rb_class_inherited(VALUE self, VALUE super, VALUE klass) {
   if(super == Qfalse) {
@@ -135,10 +147,18 @@
   rb_define_method(cls, "define_call_super_method", class_spec_define_call_super_method, 2);
 #endif
 
+#ifdef HAVE_RB_CLASS_NAME
+  rb_define_method(cls, "rb_class_name", class_spec_rbclass_name, 1);
+#endif
+
 #ifdef HAVE_RB_CLASS2NAME
   rb_define_method(cls, "rb_class2name", class_spec_rbclass2name, 1);
 #endif
 
+#ifdef HAVE_RB_PATH2CLASS
+  rb_define_method(cls, "rb_path2class", class_spec_rb_path2class, 1);
+#endif
+
 #ifdef HAVE_RB_CLASS_INHERITED
   rb_define_method(cls, "rb_class_inherited", class_spec_rb_class_inherited, 2);
 #endif

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/io_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/io_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/io_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -1,22 +1,133 @@
 #include "ruby.h"
 #include "rubyspec.h"
+#ifdef RUBY_VERSION_IS_1_8
+#include "rubyio.h"
+#else
+#include "ruby/io.h"
+#endif
+#include <fcntl.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#ifdef RUBY_VERSION_IS_LT_1_8_7
+#define rb_io_t OpenFile
+#endif
+
+static int set_non_blocking(int fd) {
+  int flags;
+#if defined(O_NONBLOCK)
+  if (-1 == (flags = fcntl(fd, F_GETFL, 0)))
+    flags = 0;
+  return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+#else
+  flags = 1;
+  return ioctl(fd, FIOBIO, &flags);
+#endif
+}
+
+#ifdef HAVE_GET_OPEN_FILE
+static int io_spec_get_fd(VALUE io) {
+  rb_io_t* fp;
+  GetOpenFile(io, fp);
+#ifdef RUBY_VERSION_IS_1_9
+  return fp->fd;
+#else
+  return fileno(fp->f);
+#endif
+}
+
+VALUE io_spec_GetOpenFile_fd(VALUE self, VALUE io) {
+  return INT2NUM(io_spec_get_fd(io));
+}
+#endif
+
 #ifdef HAVE_RB_IO_WRITE
 VALUE io_spec_rb_io_write(VALUE self, VALUE io, VALUE str) {
   return rb_io_write(io, str);
 }
 #endif
 
+#ifdef HAVE_RB_IO_CHECK_READABLE
+VALUE io_spec_rb_io_check_readable(VALUE self, VALUE io) {
+  rb_io_t* fp;
+  GetOpenFile(io, fp);
+  rb_io_check_readable(fp);
+  return Qnil;
+}
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_WRITABLE
+VALUE io_spec_rb_io_check_writable(VALUE self, VALUE io) {
+  rb_io_t* fp;
+  GetOpenFile(io, fp);
+  rb_io_check_writable(fp);
+  return Qnil;
+}
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_CLOSED
+VALUE io_spec_rb_io_check_closed(VALUE self, VALUE io) {
+  rb_io_t* fp;
+  GetOpenFile(io, fp);
+  rb_io_check_closed(fp);
+  return Qnil;
+}
+#endif
+
+#ifdef HAVE_RB_IO_WAIT_READABLE
+VALUE io_spec_rb_io_wait_readable(VALUE self, VALUE io) {
+  int fd = io_spec_get_fd(io);
+  set_non_blocking(fd);
+  char buf[256];
+  int ret;
+
+  ret = read(fd, buf, 256);
+  if (ret < 1)
+    return rb_io_wait_readable(fd) ? Qtrue : Qfalse;
+  else
+    return Qnil;
+}
+#endif
+
+#ifdef HAVE_RB_IO_WAIT_WRITABLE
+VALUE io_spec_rb_io_wait_writable(VALUE self, VALUE io) {
+  return rb_io_wait_writable(io_spec_get_fd(io));
+}
+#endif
+
 void Init_io_spec() {
   VALUE cls = rb_define_class("CApiIOSpecs", rb_cObject);
 
+#ifdef HAVE_GET_OPEN_FILE
+  rb_define_method(cls, "GetOpenFile_fd", io_spec_GetOpenFile_fd, 1);
+#endif
+
 #ifdef HAVE_RB_IO_WRITE
   rb_define_method(cls, "rb_io_write", io_spec_rb_io_write, 2);
 #endif
+
+#ifdef HAVE_RB_IO_CHECK_READABLE
+  rb_define_method(cls, "rb_io_check_readable", io_spec_rb_io_check_readable, 1);
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_WRITABLE
+  rb_define_method(cls, "rb_io_check_writable", io_spec_rb_io_check_writable, 1);
+#endif
+
+#ifdef HAVE_RB_IO_CHECK_CLOSED
+  rb_define_method(cls, "rb_io_check_closed", io_spec_rb_io_check_closed, 1);
+#endif
+
+#ifdef HAVE_RB_IO_WAIT_READABLE
+  rb_define_method(cls, "rb_io_wait_readable", io_spec_rb_io_wait_readable, 1);
+#endif
+
+#ifdef HAVE_RB_IO_WAIT_WRITABLE
+  rb_define_method(cls, "rb_io_wait_writable", io_spec_rb_io_wait_writable, 1);
+#endif
+
 }
 
 #ifdef __cplusplus

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/jruby.h
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/jruby.h	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/jruby.h	2010-12-06 22:05:47 UTC (rev 4984)
@@ -2,5 +2,7 @@
 #define RUBYSPEC_CAPI_JRUBY_H
 
 /* #undef any HAVE_ defines that JRuby does not have. */
+#undef HAVE_RB_DEFINE_HOOKED_VARIABLE
+#undef HAVE_RB_DEFINE_VARIABLE
 
 #endif

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/kernel_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/kernel_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/kernel_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -121,6 +121,12 @@
 }
 #endif
 
+#ifdef HAVE_RB_YIELD_SPLAT
+static VALUE kernel_spec_rb_yield_splat(VALUE self, VALUE ary) {
+  return rb_yield_splat(ary);
+}
+#endif
+
 #ifdef HAVE_RB_YIELD_VALUES
 static VALUE kernel_spec_rb_yield_values(VALUE self, VALUE obj1, VALUE obj2) {
   return rb_yield_values(2, obj1, obj2);
@@ -178,6 +184,10 @@
 #ifdef HAVE_RB_YIELD_VALUES
   rb_define_method(cls, "rb_yield_values", kernel_spec_rb_yield_values, 2);
 #endif
+
+#ifdef HAVE_RB_YIELD_SPLAT
+  rb_define_method(cls, "rb_yield_splat", kernel_spec_rb_yield_splat, 1);
+#endif
 }
 
 #ifdef __cplusplus

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/module_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/module_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/module_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -132,6 +132,13 @@
 }
 #endif
 
+#ifdef HAVE_RB_UNDEF
+static VALUE module_specs_rb_undef(VALUE self, VALUE cls, VALUE symbol_name) {
+  rb_undef(cls, SYM2ID(symbol_name));
+  return Qnil;
+}
+#endif
+
 #ifdef HAVE_RB_CLASS2NAME
 static VALUE module_specs_rbclass2name(VALUE self, VALUE klass) {
   return rb_str_new2(rb_class2name(klass));
@@ -220,6 +227,10 @@
   rb_define_method(cls, "rb_undef_method", module_specs_rb_undef_method, 2);
 #endif
 
+#ifdef HAVE_RB_UNDEF
+  rb_define_method(cls, "rb_undef", module_specs_rb_undef, 2);
+#endif
+
 #ifdef HAVE_RB_CLASS2NAME
   rb_define_method(cls, "rb_class2name", module_specs_rbclass2name, 1);
 #endif

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/object_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/object_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/object_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -226,6 +226,42 @@
 }
 #endif
 
+#ifdef HAVE_RB_OBJ_INSTANCE_EVAL
+static VALUE object_spec_rb_obj_instance_eval(VALUE self, VALUE obj) {
+  return rb_obj_instance_eval(0, NULL, obj);
+}
+#endif
+
+#ifdef HAVE_RB_IV_GET
+static VALUE object_spec_rb_iv_get(VALUE self, VALUE obj, VALUE name) {
+  return rb_iv_get(obj, RSTRING_PTR(name));
+}
+#endif
+
+#ifdef HAVE_RB_IV_SET
+static VALUE object_spec_rb_iv_set(VALUE self, VALUE obj, VALUE name, VALUE value) {
+  return rb_iv_set(obj, RSTRING_PTR(name), value);
+}
+#endif
+
+#ifdef HAVE_RB_IVAR_GET
+static VALUE object_spec_rb_ivar_get(VALUE self, VALUE obj, VALUE sym_name) {
+  return rb_ivar_get(obj, SYM2ID(sym_name));
+}
+#endif
+
+#ifdef HAVE_RB_IVAR_SET
+static VALUE object_spec_rb_ivar_set(VALUE self, VALUE obj, VALUE sym_name, VALUE value) {
+  return rb_ivar_set(obj, SYM2ID(sym_name), value);
+}
+#endif
+
+#ifdef HAVE_RB_IVAR_DEFINED
+static VALUE object_spec_rb_ivar_defined(VALUE self, VALUE obj, VALUE sym_name) {
+  return rb_ivar_defined(obj, SYM2ID(sym_name));
+}
+#endif
+
 void Init_object_spec() {
   VALUE cls;
   cls = rb_define_class("CApiObjectSpecs", rb_cObject);
@@ -349,6 +385,31 @@
 #ifdef HAVE_RB_TO_INT
   rb_define_method(cls, "rb_to_int", object_spec_rb_to_int, 1);
 #endif
+
+#ifdef HAVE_RB_OBJ_INSTANCE_EVAL
+  rb_define_method(cls, "rb_obj_instance_eval", object_spec_rb_obj_instance_eval, 1);
+#endif
+
+#ifdef HAVE_RB_IV_GET
+  rb_define_method(cls, "rb_iv_get", object_spec_rb_iv_get, 2);
+#endif
+
+#ifdef HAVE_RB_IV_SET
+  rb_define_method(cls, "rb_iv_set", object_spec_rb_iv_set, 3);
+#endif
+
+#ifdef HAVE_RB_IVAR_GET
+  rb_define_method(cls, "rb_ivar_get", object_spec_rb_ivar_get, 2);
+#endif
+
+#ifdef HAVE_RB_IVAR_SET
+  rb_define_method(cls, "rb_ivar_set", object_spec_rb_ivar_set, 3);
+#endif
+
+#ifdef HAVE_RB_IVAR_DEFINED
+  rb_define_method(cls, "rb_ivar_defined", object_spec_rb_ivar_defined, 2);
+#endif
+
 }
 
 #ifdef __cplusplus

Added: MacRuby/trunk/spec/frozen/optional/capi/ext/regexp_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/regexp_spec.c	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/regexp_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -0,0 +1,41 @@
+#include "ruby.h"
+#include "rubyspec.h"
+#include "re.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_RB_REG_OPTIONS
+VALUE regexp_spec_rb_reg_options(VALUE self, VALUE regexp) {
+  return INT2FIX(rb_reg_options(regexp));
+}
+#endif
+
+#ifdef HAVE_RB_REG_REGCOMP
+VALUE regexp_spec_rb_reg_regcomp(VALUE self, VALUE str) {
+  return rb_reg_regcomp(str);
+}
+#endif
+
+VALUE regexp_spec_match(VALUE self, VALUE regexp, VALUE str) {
+  return rb_funcall(regexp, rb_intern("match"), 1, str);
+}
+
+void Init_regexp_spec() {
+  VALUE cls = rb_define_class("CApiRegexpSpecs", rb_cObject);
+
+  rb_define_method(cls, "match", regexp_spec_match, 2);
+
+#ifdef HAVE_RB_REG_OPTIONS
+  rb_define_method(cls, "rb_reg_options", regexp_spec_rb_reg_options, 1);
+#endif
+
+#ifdef HAVE_RB_REG_REGCOMP
+  rb_define_method(cls, "rb_reg_regcomp", regexp_spec_rb_reg_regcomp, 1);
+#endif
+}
+
+#ifdef __cplusplus
+}
+#endif

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/rubyspec.h
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/rubyspec.h	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/rubyspec.h	2010-12-06 22:05:47 UTC (rev 4984)
@@ -9,12 +9,15 @@
 #define HAVE_RB_ARY_AREF                   1
 #define HAVE_RB_ARY_CLEAR                  1
 #define HAVE_RB_ARY_DELETE                 1
+#define HAVE_RB_ARY_DELETE_AT              1
 #define HAVE_RB_ARY_DUP                    1
 #define HAVE_RB_ARY_ENTRY                  1
 #define HAVE_RB_ARY_INCLUDES               1
 #define HAVE_RB_ARY_JOIN                   1
 #define HAVE_RB_ARY_NEW                    1
 #define HAVE_RB_ARY_NEW2                   1
+#define HAVE_RB_ARY_NEW3                   1
+#define HAVE_RB_ARY_NEW4                   1
 #define HAVE_RB_ARY_POP                    1
 #define HAVE_RB_ARY_PUSH                   1
 #define HAVE_RB_ARY_REVERSE                1
@@ -35,7 +38,9 @@
 
 /* Class */
 #define HAVE_RB_CALL_SUPER                 1
+#define HAVE_RB_CLASS_NAME                 1
 #define HAVE_RB_CLASS2NAME                 1
+#define HAVE_RB_PATH2CLASS                 1
 #define HAVE_RB_CLASS_INHERITED            1
 #define HAVE_RB_CLASS_NEW                  1
 #define HAVE_RB_CLASS_NEW_INSTANCE         1
@@ -140,7 +145,13 @@
 #define HAVE_RB_HASH_SIZE                  1
 
 /* IO */
+#define HAVE_GET_OPEN_FILE                 1
 #define HAVE_RB_IO_WRITE                   1
+#define HAVE_RB_IO_CHECK_READABLE          1
+#define HAVE_RB_IO_CHECK_WRITABLE          1
+#define HAVE_RB_IO_CHECK_CLOSED            1
+#define HAVE_RB_IO_WAIT_READABLE           1
+#define HAVE_RB_IO_WAIT_WRITABLE           1
 
 /* Kernel */
 #define HAVE_RB_BLOCK_GIVEN_P              1
@@ -155,6 +166,7 @@
 #define HAVE_RB_WARN                       1
 #define HAVE_RB_YIELD                      1
 #define HAVE_RB_YIELD_VALUES               1
+#define HAVE_RB_YIELD_SPLAT                1
 /* GC */
 #define HAVE_RB_GC_REGISTER_ADDRESS        1
 
@@ -177,6 +189,7 @@
 #define HAVE_RB_DEFINE_PROTECTED_METHOD    1
 #define HAVE_RB_DEFINE_SINGLETON_METHOD    1
 #define HAVE_RB_UNDEF_METHOD               1
+#define HAVE_RB_UNDEF                      1
 
 /* Numeric */
 #define HAVE_NUM2CHR                       1
@@ -216,6 +229,12 @@
 #define HAVE_RB_TO_INT                     1
 #define HAVE_RTEST                         1
 #define HAVE_TYPE                          1
+#define HAVE_RB_OBJ_INSTANCE_EVAL          1
+#define HAVE_RB_IV_GET                     1
+#define HAVE_RB_IV_SET                     1
+#define HAVE_RB_IVAR_GET                   1
+#define HAVE_RB_IVAR_SET                   1
+#define HAVE_RB_IVAR_DEFINED               1
 
 /* Proc */
 #define HAVE_RB_PROC_NEW                   1
@@ -223,6 +242,10 @@
 /* Range */
 #define HAVE_RB_RANGE_NEW                  1
 
+/* Regexp */
+#define HAVE_RB_REG_OPTIONS                1
+#define HAVE_RB_REG_REGCOMP                1
+
 /* Safe */
 #define HAVE_RB_SAFE_LEVEL                 1
 #define HAVE_RB_SECURE                     1
@@ -244,6 +267,7 @@
 #define HAVE_RB_STR_NEW                    1
 #define HAVE_RB_STR_NEW2                   1
 #define HAVE_RB_STR_NEW3                   1
+#define HAVE_RB_STR_BUF_NEW                1
 #define HAVE_RB_STR_PLUS                   1
 #define HAVE_RB_STR_PTR                    1
 #define HAVE_RB_STR_PTR_READONLY           1
@@ -261,6 +285,8 @@
 #define HAVE_RB_STRUCT_DEFINE              1
 
 /* Symbol */
+#define HAVE_RB_INTERN                     1
+#define HAVE_RB_ID2NAME                    1
 #define HAVE_RB_IS_CLASS_ID                1
 #define HAVE_RB_IS_CONST_ID                1
 #define HAVE_RB_IS_INSTANCE_ID             1
@@ -276,6 +302,9 @@
 /* Time */
 #define HAVE_RB_TIME_NEW                   1
 
+/* Util */
+#define HAVE_RB_SCAN_ARGS                  1
+
 /* Define convenience macros similar to the RubySpec guards to assist
  * with version incompatibilities.
  */

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/string_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/string_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/string_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -120,6 +120,20 @@
 }
 #endif
 
+#ifdef HAVE_RB_STR_BUF_NEW
+VALUE string_spec_rb_str_buf_new(VALUE self, VALUE capacity) {
+  return rb_str_buf_new(NUM2INT(capacity));
+}
+
+#ifdef HAVE_RSTRING
+VALUE string_spec_rb_str_buf_RSTRING_ptr_write(VALUE self, VALUE str, VALUE text) {
+  strcpy(RSTRING(str)->ptr, RSTRING_PTR(text));
+  RSTRING(str)->len = RSTRING_LEN(text);
+  return Qnil;
+}
+#endif
+#endif
+
 #ifdef HAVE_RB_STR_PLUS
 VALUE string_spec_rb_str_plus(VALUE self, VALUE str1, VALUE str2) {
   return rb_str_plus(str1, str2);
@@ -410,6 +424,14 @@
   rb_define_method(cls, "rb_str_new3", string_spec_rb_str_new3, 1);
 #endif
 
+#ifdef HAVE_RB_STR_BUF_NEW
+  rb_define_method(cls, "rb_str_buf_new", string_spec_rb_str_buf_new, 1);
+#ifdef HAVE_RSTRING
+  rb_define_method(cls, "rb_str_buf_RSTRING_ptr_write", string_spec_rb_str_buf_RSTRING_ptr_write, 2);
+#endif
+#endif
+
+
 #ifdef HAVE_RB_STR_PLUS
   rb_define_method(cls, "rb_str_plus", string_spec_rb_str_plus, 2);
 #endif

Modified: MacRuby/trunk/spec/frozen/optional/capi/ext/symbol_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/symbol_spec.c	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/symbol_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -5,6 +5,24 @@
 extern "C" {
 #endif
 
+#ifdef HAVE_RB_INTERN
+VALUE symbol_spec_rb_intern(VALUE self, VALUE string) {
+  return ID2SYM(rb_intern(RSTRING_PTR(string)));
+}
+
+VALUE symbol_spec_rb_intern_c_compare(VALUE self, VALUE string, VALUE sym) {
+  ID symbol = rb_intern(RSTRING_PTR(string));
+  return (SYM2ID(sym) == symbol) ? Qtrue : Qfalse;
+}
+#endif
+
+#ifdef HAVE_RB_ID2NAME
+VALUE symbol_spec_rb_id2name(VALUE self, VALUE symbol) {
+  char* c_str = rb_id2name(SYM2ID(symbol));
+  return rb_str_new(c_str, strlen(c_str));
+}
+#endif
+
 #ifdef HAVE_RB_IS_CLASS_ID
 VALUE symbol_spec_rb_is_class_id(VALUE self, VALUE sym) {
   return rb_is_class_id(SYM2ID(sym)) ? Qtrue : Qfalse;
@@ -27,6 +45,15 @@
   VALUE cls;
   cls = rb_define_class("CApiSymbolSpecs", rb_cObject);
 
+#ifdef HAVE_RB_INTERN
+  rb_define_method(cls, "rb_intern", symbol_spec_rb_intern, 1);
+  rb_define_method(cls, "rb_intern_c_compare", symbol_spec_rb_intern_c_compare, 2);
+#endif
+
+#ifdef HAVE_RB_ID2NAME
+  rb_define_method(cls, "rb_id2name", symbol_spec_rb_id2name, 1);
+#endif
+
 #ifdef HAVE_RB_IS_CLASS_ID
   rb_define_method(cls, "rb_is_class_id", symbol_spec_rb_is_class_id, 1);
 #endif

Added: MacRuby/trunk/spec/frozen/optional/capi/ext/util_spec.c
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/ext/util_spec.c	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/optional/capi/ext/util_spec.c	2010-12-06 22:05:47 UTC (rev 4984)
@@ -0,0 +1,41 @@
+#include "ruby.h"
+#include "rubyspec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_RB_SCAN_ARGS
+VALUE util_spec_rb_scan_args(VALUE self, VALUE _argv, VALUE spec, VALUE additional_ret_args) {
+  int i, argc;
+  int argv_len = RARRAY_LEN(_argv);
+  VALUE argv[4]; // argument array for rb_scan_args
+  VALUE args[4]; // return array for rb_scan_args
+  VALUE return_array = rb_ary_new();
+
+  VALUE reverse_argv = rb_ary_reverse(rb_ary_dup(_argv));
+  for (i = 0; i < argv_len; i++) {
+    argv[i] = rb_ary_pop(reverse_argv);
+  }
+
+  rb_scan_args(argv_len, argv, RSTRING_PTR(spec), &args[0], &args[1], &args[2], &args[3]);
+
+  argc = argv_len + NUM2INT(additional_ret_args);
+  for (i = 0; i < argc; i++) {
+    rb_ary_push(return_array, args[i]);
+  }
+  return return_array;
+}
+#endif
+
+void Init_util_spec() {
+  VALUE cls = rb_define_class("CApiUtilSpecs", rb_cObject);
+
+#ifdef HAVE_RB_SCAN_ARGS
+  rb_define_method(cls, "rb_scan_args", util_spec_rb_scan_args, 3);
+#endif
+}
+
+#ifdef __cplusplus
+}
+#endif

Modified: MacRuby/trunk/spec/frozen/optional/capi/globals_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/globals_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/globals_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -23,7 +23,7 @@
     @f.rb_f_global_variables.should == Kernel.global_variables
   end
 
-  not_supported_on :rubinius do
+  not_supported_on :rubinius, :jruby do
     it "rb_define_variable should define a new global variable" do
       @f.rb_define_variable("my_gvar", "ABC")
       $my_gvar.should == "ABC"
@@ -38,7 +38,7 @@
     lambda { $ro_gvar = 10 }.should raise_error(NameError)
   end
 
-  not_supported_on :rubinius do
+  not_supported_on :rubinius, :jruby do
     it "rb_define_hooked_variable should define a C hooked global variable" do
       @f.rb_define_hooked_variable_2x("$hooked_gvar")
       $hooked_gvar = 2

Modified: MacRuby/trunk/spec/frozen/optional/capi/io_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/io_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/io_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -5,6 +5,7 @@
 describe "C-API IO function" do
   before :each do
     @o = CApiIOSpecs.new
+    @read_end, @write_end = IO.pipe
   end
 
   describe "rb_io_write" do
@@ -14,4 +15,65 @@
       @o.rb_io_write(io, "test").should == :written
     end
   end
+
+  describe "rb_io_check_readable" do
+    it "raises an IOError if the io isn't opened for reading" do
+      lambda { @o.rb_io_check_readable(@write_end) }.should raise_error(IOError)
+    end
+
+    it "raises no error if the io is opened for reading" do
+      lambda { @o.rb_io_check_readable(@read_end) }.should_not raise_error(IOError)
+    end
+  end
+
+  describe "rb_io_check_writable" do
+    it "raises no error if the io is opened for writing" do
+      lambda { @o.rb_io_check_writable(@write_end) }.should_not raise_error(IOError)
+    end
+
+    it "raises an IOError if the io is not opened for reading" do
+      lambda { @o.rb_io_check_writable(@read_end) }.should raise_error(IOError)
+    end
+  end
+
+  describe "rb_io_check_closed" do
+    it "raises an error only if the io is closed" do
+      lambda { @o.rb_io_check_writable(@write_end) }.should_not raise_error(IOError)
+      @write_end.close
+      lambda { @o.rb_io_check_writable(@write_end) }.should raise_error(IOError)
+    end
+  end
+
+  describe "rb_io_wait_writeable" do
+    it "raises and IOError if passed a closed stream" do
+      @write_end.close
+      lambda { @o.rb_io_wait_writable(@write_end) }.should raise_error(IOError)
+    end
+  end
+
+  describe "rb_io_wait_readable" do
+    it "blocks until the io is readable" do
+      @write_end.write("foo")
+      @o.rb_io_wait_readable(@read_end).should == nil # read went fine
+      Thread.new(@write_end) {|w| sleep 0.1; w.write("foo") }
+      @o.rb_io_wait_readable(@read_end).should == true # no data immediately available, but incoming
+      @write_end.close
+      @read_end.read
+      @o.rb_io_wait_readable(@read_end).should == false # no data available and input closed
+    end
+
+    it "raises and IOError if passed a closed stream" do
+      @read_end.close
+      lambda { @o.rb_io_wait_readable(@read_end) }.should raise_error(IOError)
+    end
+  end
+
+  describe "GetOpenFile" do
+    it "allows access to the system fileno" do
+      @o.GetOpenFile_fd($stdin).should == 0
+      @o.GetOpenFile_fd($stdout).should == 1
+      @o.GetOpenFile_fd($stderr).should == 2
+      @o.GetOpenFile_fd(@read_end).should == @read_end.fileno
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/optional/capi/kernel_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/kernel_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/kernel_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -88,11 +88,9 @@
 
   describe "rb_sys_fail" do
     it "raises an exception from the value of errno" do
-      # If errno = 1 is no EPERM on a platform, we can change the
-      # expected exception class to be more generic
       lambda do
         @s.rb_sys_fail("additional info")
-      end.should raise_error(Errno::EPERM, /additional info/)
+      end.should raise_error(SystemCallError, /additional info/)
     end
   end
 
@@ -128,6 +126,22 @@
     end
   end
 
+  describe "rb_yield_splat" do
+    it "yields with passed array's contents" do
+      ret = nil
+      @s.rb_yield_splat([1, 2]) { |x, y| ret = x + y }
+      ret.should == 3
+    end
+
+    it "returns the result from block evaluation" do
+      @s.rb_yield_splat([1, 2]) { |x, y| x + y }.should == 3
+    end
+
+    it "raises LocalJumpError when no block is given" do
+      lambda { @s.rb_yield_splat([1, 2]) }.should raise_error(LocalJumpError)
+    end
+  end
+
   describe "rb_rescue" do
     before :each do
       @proc = lambda { |x| x }

Modified: MacRuby/trunk/spec/frozen/optional/capi/module_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/module_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/module_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -277,6 +277,20 @@
     end
   end
 
+  describe "rb_undef" do
+    it "undef'ines a method on a class" do
+      cls = Class.new do
+        def ruby_test_method
+          :ruby_test_method
+        end
+      end
+
+      cls.new.ruby_test_method.should == :ruby_test_method
+      @m.rb_undef cls, :ruby_test_method
+      cls.should_not have_instance_method(:ruby_test_method)
+    end
+  end
+
   describe "rb_class2name" do
     it "returns the module name" do
       @m.rb_class2name(CApiModuleSpecs::M).should == "CApiModuleSpecs::M"

Modified: MacRuby/trunk/spec/frozen/optional/capi/object_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/object_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/object_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -250,6 +250,15 @@
     end
   end
 
+  describe "rb_obj_instance_eval" do
+    it "evaluates the block in the object context, that includes private methods" do
+      obj = ObjectTest
+      lambda do
+        @o.rb_obj_instance_eval(obj) { include Kernel }
+      end.should_not raise_error(NoMethodError)
+    end
+  end
+
   extended_on :rubinius do
     describe "rb_obj_frozen_p" do
       it "returns true if object passed to it is frozen" do
@@ -354,4 +363,54 @@
       lambda { @o.rb_to_int("1") }.should raise_error(TypeError)
     end
   end
+
+  describe "instance variable access" do
+    before do
+      @test = ObjectTest.new
+    end
+
+    describe "rb_iv_get" do
+      it "returns the instance variable on an object" do
+        @o.rb_iv_get(@test, "@foo").should == @test.instance_eval { @foo }
+      end
+
+      it "returns nil if the instance variable has not been initialized" do
+        @o.rb_iv_get(@test, "@bar").should == nil
+      end
+    end
+
+    describe "rb_iv_set" do
+      it "sets and returns the instance variable on an object" do
+        @o.rb_iv_set(@test, "@foo", 42).should == 42
+        @test.instance_eval { @foo }.should == 42
+      end
+    end
+
+    describe "rb_ivar_get" do
+      it "returns the instance variable on an object" do
+        @o.rb_ivar_get(@test, :@foo).should == @test.instance_eval { @foo }
+      end
+
+      it "returns nil if the instance variable has not been initialized" do
+        @o.rb_ivar_get(@test, :@bar).should == nil
+      end
+    end
+
+    describe "rb_ivar_set" do
+      it "sets and returns the instance variable on an object" do
+        @o.rb_ivar_set(@test, :@foo, 42).should == 42
+        @test.instance_eval { @foo }.should == 42
+      end
+    end
+
+    describe "rb_ivar_defined" do
+      it "returns true if the instance variable is defined" do
+        @o.rb_ivar_defined(@test, :@foo).should == true
+      end
+
+      it "returns false if the instance variable is not defined" do
+        @o.rb_ivar_defined(@test, :@bar).should == false
+      end
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/optional/capi/range_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/range_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/range_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -33,10 +33,14 @@
     it "raises an ArgumentError when the given start and end can't be compared by using #<=>" do
       lambda { @s.rb_range_new(1, mock('x'))         }.should raise_error(ArgumentError)
       lambda { @s.rb_range_new(mock('x'), mock('y')) }.should raise_error(ArgumentError)
+    end
 
-      b = mock('x')
-      (a = mock('nil')).should_receive(:method_missing).with(:<=>, b).and_return(nil)
-      lambda { @s.rb_range_new(a, b) }.should raise_error(ArgumentError)
+    ruby_version_is ""..."1.9" do
+      it "raises an ArgumentError when the given start uses method_missing and end is mock" do
+        b = mock('x')
+        (a = mock('nil')).should_receive(:method_missing).with(:<=>, b).and_return(nil)
+        lambda { @s.rb_range_new(a, b) }.should raise_error(ArgumentError)
+      end
     end
   end
 end

Added: MacRuby/trunk/spec/frozen/optional/capi/regexp_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/regexp_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/optional/capi/regexp_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -0,0 +1,33 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+load_extension('regexp')
+
+describe "C-API Regex functions" do
+  before :each do
+    @o = CApiRegexpSpecs.new
+  end
+
+  describe "rb_reg_options" do
+    it "returns the options used to create the regexp" do
+      @o.rb_reg_options(/42/im).should == //im.options
+      @o.rb_reg_options(/42/i).should == //i.options
+      @o.rb_reg_options(/42/m).should == //m.options
+    end
+  end
+
+  describe "rb_reg_regcomp" do
+    it "creates a valid regexp from a string" do
+      regexp = /\b([A-Z0-9._%+-]+)\.{2,4}/
+      @o.rb_reg_regcomp(regexp.source).should == regexp
+    end
+  end
+
+  it "allows matching in C, properly setting the back references" do
+    mail_regexp = /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,4})\b/i
+    name = "john.doe"
+    domain = "example.com"
+    @o.match(mail_regexp, "#{name}@#{domain}")
+    $1.should == name
+    $2.should == domain
+  end
+end

Modified: MacRuby/trunk/spec/frozen/optional/capi/spec_helper.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/spec_helper.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/spec_helper.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -15,12 +15,6 @@
 CAPI_RUBY_SIGNATURE = "#{RUBY_NAME}-#{RUBY_VERSION}"
 
 def compile_extension(path, name)
-  ext       = File.join(path, "#{name}_spec")
-  source    = "#{ext}.c"
-  obj       = "#{ext}.o"
-  lib       = "#{ext}.#{RbConfig::CONFIG['DLEXT']}"
-  signature = "#{ext}.sig"
-
   # TODO use rakelib/ext_helper.rb?
   arch_hdrdir = nil
   ruby_hdrdir = nil
@@ -34,10 +28,19 @@
     else
       hdrdir = RbConfig::CONFIG["archdir"]
     end
+  elsif RUBY_NAME == 'jruby'
+    require 'mkmf'
+    hdrdir = $hdrdir
   else
     raise "Don't know how to build C extensions with #{RUBY_NAME}"
   end
 
+  ext       = File.join(path, "#{name}_spec")
+  source    = "#{ext}.c"
+  obj       = "#{ext}.o"
+  lib       = "#{ext}.#{Config::CONFIG['DLEXT']}"
+  signature = "#{ext}.sig"
+
   ruby_header     = File.join(hdrdir, "ruby.h")
   rubyspec_header = File.join(path, "rubyspec.h")
   mri_header      = File.join(path, "mri.h")

Modified: MacRuby/trunk/spec/frozen/optional/capi/string_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/string_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/string_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -51,6 +51,21 @@
     end
   end
 
+  describe "rb_str_buf_new" do
+    it "returns an empty string" do
+      @s.rb_str_buf_new(10).should == ""
+    end
+
+    ruby_version_is ""..."1.9" do
+      it "returns a string which can be assigned to from C" do
+        str = "hello"
+        buf = @s.rb_str_buf_new(str.size)
+        @s.rb_str_buf_RSTRING_ptr_write(buf, str)
+        buf.should == str
+      end
+    end
+  end
+
   describe "rb_str_dup" do
     it "returns a copy of the string" do
       str1 = "hi"

Modified: MacRuby/trunk/spec/frozen/optional/capi/symbol_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/symbol_spec.rb	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/optional/capi/symbol_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -7,6 +7,19 @@
     @s = CApiSymbolSpecs.new
   end
 
+  describe "rb_intern" do
+    it "converts a string to a symbol, uniquely" do
+      @s.rb_intern("test_symbol").should === :test_symbol
+      @s.rb_intern_c_compare("test_symbol", :test_symbol).should == true
+    end
+  end
+
+  describe "rb_id2name" do
+    it "converts a symbol to a C char array" do
+      @s.rb_id2name(:test_symbol).should === "test_symbol"
+    end
+  end
+
   describe "rb_is_const_id" do
     it "returns true given a const-like symbol" do
       @s.rb_is_const_id(:Foo).should == true

Added: MacRuby/trunk/spec/frozen/optional/capi/util_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/optional/capi/util_spec.rb	                        (rev 0)
+++ MacRuby/trunk/spec/frozen/optional/capi/util_spec.rb	2010-12-06 22:05:47 UTC (rev 4984)
@@ -0,0 +1,65 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+load_extension('util')
+
+describe "C-API Util function" do
+  before :each do
+    @o = CApiUtilSpecs.new
+  end
+
+  describe "rb_scan_args" do
+    it "should assign all required arguments" do
+      arguments = [1,2,3]
+      ary = @o.rb_scan_args(arguments, "3", 0)
+      ary.should == arguments
+    end
+
+    it "should assign all required and all passed optional arguments" do
+      arguments = [:required, :optional]
+      ary = @o.rb_scan_args(arguments, "11", 0)
+      ary.should == arguments
+      ary = @o.rb_scan_args(arguments, "02", 0)
+      ary.should == arguments
+      ary = @o.rb_scan_args(arguments, "12", 1)
+      ary.should == arguments + [nil]
+      ary = @o.rb_scan_args([], "02", 2)
+      ary.should == [nil, nil]
+    end
+
+    it "should assign all required and all optional arguments and splat the rest" do
+      arguments = [:required, :optional, 1, 2]
+      ary = @o.rb_scan_args(arguments, "11*", 1)
+      ary[0..1].should == arguments[0..1]
+      ary[2].should == arguments[2..3]
+
+      arguments = [:required, :optional]
+      ary = @o.rb_scan_args(arguments, "11*", 1)
+      ary[0..1].should == arguments[0..1]
+      ary[2].should == []
+    end
+
+    it "should assign all arguments and a possible block" do
+      arguments = [:required, :optional, 1, 2]
+      block = lambda { 1 }
+
+      ary = @o.rb_scan_args(arguments, "11*&", 2, &block)
+      ary[0..1].should == arguments[0..1]
+      ary[2].should == arguments[2..3]
+      ary[3].should == block
+
+      arguments = [:required, :optional]
+      ary = @o.rb_scan_args(arguments, "11*&", 2, &block)
+      ary[0..1].should == arguments[0..1]
+      ary[2].should == []
+      ary[3].should == block
+
+      ary = @o.rb_scan_args(arguments, "11&", 1, &block)
+      ary[0..1].should == arguments
+      ary[2].should == block
+
+      ary = @o.rb_scan_args(arguments, "11&", 1)
+      ary[0..1].should == arguments
+      ary[2].should == nil
+    end
+  end
+end

Modified: MacRuby/trunk/spec/frozen/upstream
===================================================================
--- MacRuby/trunk/spec/frozen/upstream	2010-12-06 11:40:46 UTC (rev 4983)
+++ MacRuby/trunk/spec/frozen/upstream	2010-12-06 22:05:47 UTC (rev 4984)
@@ -1 +1 @@
-0bbe4d3ddcb78c5c1bf12821acfe167f868715e9
\ No newline at end of file
+d7ff2bee090df4b254f7fcaa70bef6f0e6081dff
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101206/a1f25532/attachment-0001.html>


More information about the macruby-changes mailing list