[macruby-changes] [1130] MacRuby/branches/experimental/spec/frozen/language/versions/method_1 .9.rb

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 24 03:53:58 PDT 2009


Revision: 1130
          http://trac.macosforge.org/projects/ruby/changeset/1130
Author:   eloy.de.enige at gmail.com
Date:     2009-03-24 03:53:58 -0700 (Tue, 24 Mar 2009)
Log Message:
-----------
Added Ruby 1.9 only "method" examples for arguments grouped in parentheses.

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/language/versions/method_1.9.rb

Modified: MacRuby/branches/experimental/spec/frozen/language/versions/method_1.9.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/versions/method_1.9.rb	2009-03-24 10:32:12 UTC (rev 1129)
+++ MacRuby/branches/experimental/spec/frozen/language/versions/method_1.9.rb	2009-03-24 10:53:58 UTC (rev 1130)
@@ -108,4 +108,30 @@
     fooP0R(*a,*a,*a).should == 9
     fooP0R(0,*a,4,*5,6,7,*c,-1).should == 11
   end
+
+  it "expands an array to arguments grouped in parentheses" do
+    def fooP1((a,b)); a+b; end
+
+    fooP1([40,2]).should == 42
+  end
+
+  it "expands an array to arguments grouped in parentheses and ignores any rest arguments in the array" do
+    def fooP1((a,b)); a+b; end
+
+    fooP1([40,2,84]).should == 42
+  end
+
+  it "expands an array to arguments grouped in parentheses and sets not specified arguments to nil" do
+    def fooP1((a,b)); [a,b]; end
+
+    fooP1([42]).should == [42, nil]
+  end
+
+  it "expands an array to arguments grouped in parentheses which in turn takes rest arguments" do
+    def fooP1((a,b,*c,d,e)); [a,b,c,d,e]; end
+
+    fooP1([1, 2, 3]).should == [1, 2, [], 3, nil]
+    fooP1([1, 2, 3, 4]).should == [1, 2, [], 3, 4]
+    fooP1([1, 2, 3, 4, 5]).should == [1, 2, [3], 4, 5]
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090324/cb579e2e/attachment.html>


More information about the macruby-changes mailing list