[macruby-changes] [1129] MacRuby/branches/experimental/spec/frozen/language
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 24 03:32:13 PDT 2009
Revision: 1129
http://trac.macosforge.org/projects/ruby/changeset/1129
Author: eloy.de.enige at gmail.com
Date: 2009-03-24 03:32:12 -0700 (Tue, 24 Mar 2009)
Log Message:
-----------
Added 2 "case" examples: check left-to-right execution order of "when" clause, check multiple splats in "when" clause (1.9 only).
Modified Paths:
--------------
MacRuby/branches/experimental/spec/frozen/language/case_spec.rb
MacRuby/branches/experimental/spec/frozen/language/versions/case_1.9.rb
Modified: MacRuby/branches/experimental/spec/frozen/language/case_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/case_spec.rb 2009-03-24 10:32:02 UTC (rev 1128)
+++ MacRuby/branches/experimental/spec/frozen/language/case_spec.rb 2009-03-24 10:32:12 UTC (rev 1129)
@@ -15,6 +15,18 @@
end.should == true
end
+ it "evaluates the body of the when clause in left-to-right order if it's an array expression" do
+ @calls = []
+ def foo; @calls << :foo; end
+ def bar; @calls << :bar; end
+
+ case true
+ when foo, bar;
+ end
+
+ @calls.should == [:foo, :bar]
+ end
+
it "evaluates the body of the when clause whose range expression includes the case target expression" do
case 5
when 21..30; false
Modified: MacRuby/branches/experimental/spec/frozen/language/versions/case_1.9.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/versions/case_1.9.rb 2009-03-24 10:32:02 UTC (rev 1128)
+++ MacRuby/branches/experimental/spec/frozen/language/versions/case_1.9.rb 2009-03-24 10:32:12 UTC (rev 1129)
@@ -1 +1,20 @@
-# TODO
\ No newline at end of file
+describe "The 'case'-construct" do
+ it "takes multiple expanded arrays" do
+ a1 = ['f', 'o', 'o']
+ a2 = ['b', 'a', 'r']
+
+ case 'f'
+ when *a1, *['x', 'y', 'z']
+ "foo"
+ when *a2, *['x', 'y', 'z']
+ "bar"
+ end.should == "foo"
+
+ case 'b'
+ when *a1, *['x', 'y', 'z']
+ "foo"
+ when *a2, *['x', 'y', 'z']
+ "bar"
+ end.should == "bar"
+ end
+end
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090324/581696fa/attachment-0001.html>
More information about the macruby-changes
mailing list