[macruby-changes] [1044] MacRuby/branches/experimental/test_roxor.rb

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 20 23:49:27 PDT 2009


Revision: 1044
          http://trac.macosforge.org/projects/ruby/changeset/1044
Author:   vincent.isambart at gmail.com
Date:     2009-03-20 23:49:26 -0700 (Fri, 20 Mar 2009)
Log Message:
-----------
added a test for the what seems to cause the infinite loop in mspec
and also other tests (most do not pass yet) for block parameters

Modified Paths:
--------------
    MacRuby/branches/experimental/test_roxor.rb

Modified: MacRuby/branches/experimental/test_roxor.rb
===================================================================
--- MacRuby/branches/experimental/test_roxor.rb	2009-03-21 05:25:26 UTC (rev 1043)
+++ MacRuby/branches/experimental/test_roxor.rb	2009-03-21 06:49:26 UTC (rev 1044)
@@ -684,6 +684,12 @@
   assert ":ok", "def foo(*args, &block); :ok; end; p foo"
   assert ":ok", "def foo(x, *args, &block); x; end; p foo(:ok)"
   
+  assert ":ok", %{
+    def foo(&block) p(block ? :ko : :ok) end
+    def bar(&block) block.call() end
+    bar { foo }
+  }
+  
   assert "[1, nil, :c]", "def f(a, b = :b, c = :c) [a, b, c] end; p f(1, nil)"
   assert "[1, :b, :c, 2]\n[1, 2, :c, 3]\n[1, 2, 3, 4]", %{
     def f(a, b = :b, c = :c, d) [a, b, c, d] end
@@ -816,6 +822,30 @@
     def foo; yield([1, 2]); end
     foo { |*rest| p rest }
   }
+  assert "[1, [2]]", %q{
+    def foo; yield([1, 2]); end
+    foo { |a, *rest| p [a, rest] }
+  }
+  assert "[[1, 2], []]", %q{
+    def foo; yield([1, 2]); end
+    foo { |a = 42, *rest| p [a, rest] }
+  }
+  assert "[1, 2, []]", %q{
+    def foo; yield([1, 2]); end
+    foo { |a = 42, *rest, b| p [a, b, rest] }
+  }
+  assert "[1, 2, []]", %q{
+    def foo; yield([1, 2]); end
+    foo { |a, b = 42, *rest| p [a, b, rest] }
+  }
+  assert "[[1, 2], 42, []]", %q{
+    def foo; yield([1, 2]); end
+    foo { |a = 42, b = 42, *rest| p [a, b, rest] }
+  }
+  assert "[[1, 2], []]", %q{
+    def foo; yield([1, 2]); end
+    foo { |a = 42, *rest| p [a, rest] }
+  }
 
   assert ":ok", "def foo; p :ok if block_given?;     end; foo {}"
   assert ":ok", "def foo; p :ok unless block_given?; end; foo"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090320/21ede107/attachment.html>


More information about the macruby-changes mailing list