[macruby-changes] [1073] MacRuby/branches/experimental/spec/frozen/language

source_changes at macosforge.org source_changes at macosforge.org
Sun Mar 22 17:35:19 PDT 2009


Revision: 1073
          http://trac.macosforge.org/projects/ruby/changeset/1073
Author:   eloy.de.enige at gmail.com
Date:     2009-03-22 17:35:19 -0700 (Sun, 22 Mar 2009)
Log Message:
-----------
Moved some case specs into a 1.8 version specific file. And make use of a semi-colon instead of a colon for examples where it doesn't matter as a colon is no longer supported on 1.9.

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/language/case_spec.rb

Added Paths:
-----------
    MacRuby/branches/experimental/spec/frozen/language/versions/case_1.8.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-23 00:16:37 UTC (rev 1072)
+++ MacRuby/branches/experimental/spec/frozen/language/case_spec.rb	2009-03-23 00:35:19 UTC (rev 1073)
@@ -3,22 +3,22 @@
 describe "The 'case'-construct" do
   it "evaluates the body of the when clause matching the case target expression" do
     case 1
-      when 2: false
-      when 1: true
+      when 2; false
+      when 1; true
     end.should == true
   end
 
   it "evaluates the body of the when clause whose array expression includes the case target expression" do
     case 2
-      when 3, 4: false
-      when 1, 2: true
+      when 3, 4; false
+      when 1, 2; true
     end.should == true
   end
 
   it "evaluates the body of the when clause whose range expression includes the case target expression" do
     case 5
-      when 21..30: false
-      when 1..20: true
+      when 21..30; false
+      when 1..20; true
     end.should == true
   end
 
@@ -31,16 +31,16 @@
   
   it "evaluates the 'else'-body when no other expression matches" do
     case "c"
-      when "a": 'foo'
-      when "b": 'bar'
+      when "a"; 'foo'
+      when "b"; 'bar'
       else 'zzz'
     end.should == 'zzz'
   end
   
   it "returns nil when no expression matches and 'else'-body is empty" do
     case "c"
-      when "a": "a"
-      when "b": "b"
+      when "a"; "a"
+      when "b"; "b"
       else
     end.should == nil
   end
@@ -56,27 +56,13 @@
     end.should == 2
   end
 
-  it "returns the statement following ':'" do
-    case "a"
-      when "a": 'foo'
-      when "b": 'bar'
-    end.should == 'foo'
-  end
-    
   it "returns the statement following 'then'" do
     case "a"
       when "a" then 'foo'
       when "b" then 'bar'
     end.should == 'foo'
   end
-    
-  it "allows mixing ':' and 'then'" do
-    case "b"
-      when "a": 'foo'
-      when "b" then 'bar'
-    end.should == 'bar'
-  end
-    
+
   it "tests classes with case equality" do
     case "a"
       when String
@@ -85,14 +71,14 @@
         'bar'
     end.should == 'foo'
   end
-  
+
   it "tests with matching regexps" do
     case "hello"
-      when /abc/: false
-      when /^hell/: true
+      when /abc/; false
+      when /^hell/; true
     end.should == true
   end
-  
+
   it "does not test with equality when given classes" do
     case :symbol.class
       when Symbol
@@ -246,42 +232,42 @@
 
 describe "The 'case'-construct with no target expression" do
   it "evaluates the body of the first clause when at least one of its condition expressions is true" do
-      case
-        when true, false: 'foo'
-      end.should == 'foo'
-    end
-    
+    case
+      when true, false; 'foo'
+    end.should == 'foo'
+  end
+
   it "evaluates the body of the first when clause that is not false/nil" do
     case
-      when false: 'foo'
-      when 2: 'bar'
-      when 1 == 1: 'baz'
+      when false; 'foo'
+      when 2; 'bar'
+      when 1 == 1; 'baz'
     end.should == 'bar'
-  
+
     case
-      when false: 'foo'
-      when nil: 'foo'
-      when 1 == 1: 'bar'
+      when false; 'foo'
+      when nil; 'foo'
+      when 1 == 1; 'bar'
     end.should == 'bar'
   end
-      
+
   it "evaluates the body of the else clause if all when clauses are false/nil" do
     case
-      when false: 'foo'
-      when nil: 'foo'
-      when 1 == 2: 'bar'
+      when false; 'foo'
+      when nil; 'foo'
+      when 1 == 2; 'bar'
       else 'baz'
     end.should == 'baz'
   end
-  
+
   it "evaluates multiple conditional expressions as a boolean disjunction" do
     case
-      when true, false: 'foo'
+      when true, false; 'foo'
       else 'bar'
     end.should == 'foo'
 
     case
-      when false, true: 'foo'
+      when false, true; 'foo'
       else 'bar'
     end.should == 'foo'
   end
@@ -307,3 +293,5 @@
     end.should == 'good'
   end
 end
+
+language_version __FILE__, "case"
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/language/versions/case_1.8.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/versions/case_1.8.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/language/versions/case_1.8.rb	2009-03-23 00:35:19 UTC (rev 1073)
@@ -0,0 +1,15 @@
+describe "The 'case'-construct" do
+  it "returns the statement following ':'" do
+    case "a"
+      when "a": 'foo'
+      when "b": 'bar'
+    end.should == 'foo'
+  end
+
+  it "allows mixing ':' and 'then'" do
+    case "b"
+      when "a": 'foo'
+      when "b" then 'bar'
+    end.should == 'bar'
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/language/versions/case_1.9.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/versions/case_1.9.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/language/versions/case_1.9.rb	2009-03-23 00:35:19 UTC (rev 1073)
@@ -0,0 +1 @@
+# TODO
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090322/c8c0dae6/attachment.html>


More information about the macruby-changes mailing list