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

source_changes at macosforge.org source_changes at macosforge.org
Sun Mar 28 14:11:11 PDT 2010


Revision: 3885
          http://trac.macosforge.org/projects/ruby/changeset/3885
Author:   eloy.de.enige at gmail.com
Date:     2010-03-28 14:11:09 -0700 (Sun, 28 Mar 2010)
Log Message:
-----------
Updated RubySpec to 9940f1d4cc02e606fca503dca8c0c49e6219a0a9

Modified Paths:
--------------
    MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb
    MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb
    MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb
    MacRuby/trunk/spec/frozen/language/variables_spec.rb
    MacRuby/trunk/spec/frozen/upstream

Modified: MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb	2010-03-28 20:08:49 UTC (rev 3884)
+++ MacRuby/trunk/spec/frozen/core/dir/chdir_spec.rb	2010-03-28 21:11:09 UTC (rev 3885)
@@ -56,10 +56,10 @@
       Dir.chdir(obj)
     end
 
-    it "prefers #to_str over #to_path" do
+    it "prefers #to_path over #to_str" do
       obj = Class.new do
-        def to_path; DirSpecs.mock_dir; end
-        def to_str;  Dir.pwd; end
+        def to_path; Dir.pwd; end
+        def to_str;  DirSpecs.mock_dir; end
       end
       Dir.chdir(obj.new)
       Dir.pwd.should == @original

Modified: MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb	2010-03-28 20:08:49 UTC (rev 3884)
+++ MacRuby/trunk/spec/frozen/core/kernel/caller_spec.rb	2010-03-28 21:11:09 UTC (rev 3885)
@@ -151,4 +151,12 @@
 
 describe "Kernel.caller" do
   it "needs to be reviewed for spec completeness"
+
+  ruby_bug("redmine:3011", "1.8.7") do
+    it "returns one entry per call, even for recursive methods" do
+      two   = CallerSpecs::recurse(2)
+      three = CallerSpecs::recurse(3)
+      (three.size - two.size).should == 1
+    end
+  end
 end

Modified: MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb	2010-03-28 20:08:49 UTC (rev 3884)
+++ MacRuby/trunk/spec/frozen/core/kernel/fixtures/classes.rb	2010-03-28 21:11:09 UTC (rev 3885)
@@ -304,6 +304,13 @@
   end
 end
 
+module CallerSpecs
+  def self.recurse(n)
+    return caller if n <= 0
+    recurse(n-1)
+  end
+end
+
 # for Kernel#sleep to have Channel in it's specs
 # TODO: switch directly to queue for both Kernel#sleep and Thread specs?
 unless defined? Channel

Modified: MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb
===================================================================
--- MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb	2010-03-28 20:08:49 UTC (rev 3884)
+++ MacRuby/trunk/spec/frozen/core/kernel/shared/require.rb	2010-03-28 21:11:09 UTC (rev 3885)
@@ -108,10 +108,11 @@
         ScratchPad.recorded.should == [:loaded]
       end
 
-      it "does not call #to_path on a String" do
+      it "calls #to_path on a String" do
         path = File.expand_path "load_fixture.rb", CODE_LOADING_DIR
-        path.should_not_receive(:to_path)
-        @object.send(@method, path).should be_true
+        str = mock("load_fixture.rb mock")
+        str.should_receive(:to_path).and_return(path)
+        @object.send(@method, str).should be_true
         ScratchPad.recorded.should == [:loaded]
       end
 

Modified: MacRuby/trunk/spec/frozen/language/variables_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/variables_spec.rb	2010-03-28 20:08:49 UTC (rev 3884)
+++ MacRuby/trunk/spec/frozen/language/variables_spec.rb	2010-03-28 21:11:09 UTC (rev 3885)
@@ -596,7 +596,7 @@
   end
 end
 
-describe "Operator assignment 'var op= expr'" do
+describe "Unconditional operator assignment 'var op= expr'" do
   it "is equivalent to 'var = var op expr'" do
     x = 13
     (x += 5).should == 18
@@ -652,7 +652,11 @@
     x = 5
     (x >>= 1).should == 2
     x.should == 2
+  end
+end
 
+describe "Conditional operator assignment 'var op= expr'" do
+  it "assigns the lhs if its truthiness is false for ||, true for &&" do
     x = nil
     (x ||= 17).should == 17
     x.should == 17
@@ -671,7 +675,17 @@
     x.should == false
   end
 
-  it "uses short-circuit arg evaluation for operators ||= and &&=" do
+  it "may not assign at all, depending on the truthiness of lhs" do
+    Object.new.instance_eval do
+      @falsey = false
+      @truthy = true
+      freeze
+      lambda{ @truthy ||= 42 }.should_not raise_error
+      lambda{ @falsey &&= 42 }.should_not raise_error
+    end
+  end
+
+  it "uses short-circuit arg evaluation" do
     x = 8
     y = VariablesSpecs::OpAsgn.new
     (x ||= y.do_side_effect).should == 8
@@ -687,7 +701,7 @@
   end
 end
 
-describe "Operator assignment 'obj.meth op= expr'" do
+describe "Unconditional operator assignment 'obj.meth op= expr'" do
   it "is equivalent to 'obj.meth = obj.meth op expr'" do
     @x = VariablesSpecs::OpAsgn.new
     @x.a = 13
@@ -742,9 +756,14 @@
     @x.a = 5
     (@x.a >>= 1).should == 2
     @x.a.should == 2
+  end
+end
 
+describe "Conditional operator assignment 'obj.meth op= expr'" do
+  it "is equivalent to 'obj.meth op obj.meth = expr'" do
+    @x = VariablesSpecs::OpAsgn.new
     @x.a = nil
-     (@x.a ||= 17).should == 17
+    (@x.a ||= 17).should == 17
     @x.a.should == 17
     (@x.a ||= 2).should == 17
     @x.a.should == 17
@@ -761,7 +780,18 @@
     @x.a.should == false
   end
 
-  it "uses short-circuit arg evaluation for operators ||= and &&=" do
+  it "may not assign at all, depending on the truthiness of lhs" do
+    m = mock("object")
+    m.should_receive(:foo).and_return(:truthy)
+    m.should_not_receive(:foo=)
+    m.foo ||= 42
+
+    m.should_receive(:bar).and_return(false)
+    m.should_not_receive(:bar=)
+    m.bar &&= 42
+  end
+
+  it "uses short-circuit arg evaluation" do
     x = 8
     y = VariablesSpecs::OpAsgn.new
     (x ||= y.do_side_effect).should == 8
@@ -775,7 +805,9 @@
     (x ||= y.do_side_effect).should == 5
     y.side_effect.should == true
   end
+end
 
+describe "Operator assignment 'obj.meth op= expr'" do
   it "evaluates lhs one time" do
     x = VariablesSpecs::OpAsgn.new
     x.a = 5
@@ -848,7 +880,7 @@
   end
 end
 
-describe "Operator assignment 'obj[idx] op= expr'" do
+describe "Unconditional operator assignment 'obj[idx] op= expr'" do
   it "is equivalent to 'obj[idx] = obj[idx] op expr'" do
     x = [2,13,7]
     (x[1] += 5).should == 18
@@ -902,7 +934,11 @@
     x = [nil,5,8]
     (x[1] >>= 1).should == 2
     x.should == [nil,2,8]
+  end
+end
 
+describe "Conditional operator assignment 'obj[idx] op= expr'" do
+  it "is equivalent to 'obj[idx] op obj[idx] = expr'" do
     x = [1,nil,12]
     (x[1] ||= 17).should == 17
     x.should == [1,17,12]
@@ -920,7 +956,19 @@
     x.should == [false, false, false]
   end
 
-  it "uses short-circuit arg evaluation for operators ||= and &&=" do
+  it "may not assign at all, depending on the truthiness of lhs" do
+    m = mock("object")
+    m.should_receive(:[]).and_return(:truthy)
+    m.should_not_receive(:[]=)
+    m[:foo] ||= 42
+
+    m = mock("object")
+    m.should_receive(:[]).and_return(false)
+    m.should_not_receive(:[]=)
+    m[:bar] &&= 42
+  end
+
+  it "uses short-circuit arg evaluation" do
     x = 8
     y = VariablesSpecs::OpAsgn.new
     (x ||= y.do_side_effect).should == 8
@@ -934,7 +982,9 @@
     (x ||= y.do_side_effect).should == 5
     y.side_effect.should == true
   end
+end
 
+describe "Operator assignment 'obj[idx] op= expr'" do
   it "handles complex index (idx) arguments" do
     x = [1,2,3,4]
     (x[0,2] += [5]).should == [1,2,5]

Modified: MacRuby/trunk/spec/frozen/upstream
===================================================================
--- MacRuby/trunk/spec/frozen/upstream	2010-03-28 20:08:49 UTC (rev 3884)
+++ MacRuby/trunk/spec/frozen/upstream	2010-03-28 21:11:09 UTC (rev 3885)
@@ -1 +1 @@
-4b2ea70bcbb0973dc81ef6fac0c42c1971d9acd6
\ No newline at end of file
+9940f1d4cc02e606fca503dca8c0c49e6219a0a9
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100328/f26a7458/attachment-0001.html>


More information about the macruby-changes mailing list