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

source_changes at macosforge.org source_changes at macosforge.org
Mon Mar 23 06:24:00 PDT 2009


Revision: 1101
          http://trac.macosforge.org/projects/ruby/changeset/1101
Author:   eloy.de.enige at gmail.com
Date:     2009-03-23 06:24:00 -0700 (Mon, 23 Mar 2009)
Log Message:
-----------
Moved 1.8 specific if examples into if_1.8.rb and added a 1.9 example.

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

Added Paths:
-----------
    MacRuby/branches/experimental/spec/frozen/language/versions/if_1.8.rb
    MacRuby/branches/experimental/spec/frozen/language/versions/if_1.9.rb

Modified: MacRuby/branches/experimental/spec/frozen/language/if_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/if_spec.rb	2009-03-23 13:12:38 UTC (rev 1100)
+++ MacRuby/branches/experimental/spec/frozen/language/if_spec.rb	2009-03-23 13:24:00 UTC (rev 1101)
@@ -130,13 +130,6 @@
     end.should == 123
   end
 
-  it "allows starting then-body on the same line if colon is used" do
-    if true: 123
-    else
-      456
-    end.should == 123
-  end
-
   it "allows starting else-body on the same line" do
     if false
       123
@@ -144,12 +137,6 @@
     end.should == 456
   end
 
-  it "allows both then- and else-bodies start on the same line (with colon after expression)" do
-    if false: 123
-    else 456
-    end.should == 456
-  end
-
   it "evaluates subsequent elsif statements and execute body of first matching" do
     if false
       123
@@ -174,14 +161,6 @@
     end.should == 456
   end
 
-  it "allows ':' after expression when then-body is on the next line" do
-    if true:
-      123
-    end.should == 123
-
-    if true; 123; end.should == 123
-  end
-
   it "allows 'then' after expression when then-body is on the next line" do
     if true then
       123
@@ -190,13 +169,6 @@
     if true then ; 123; end.should == 123
   end
 
-  it "allows then-body on the same line separated with ':'" do
-    if true: 123
-    end.should == 123
-
-    if true: 123; end.should == 123
-  end
-
   it "allows then-body on the same line separated with 'then'" do
     if true then 123
     end.should == 123
@@ -204,13 +176,6 @@
     if true then 123; end.should == 123
   end
 
-  it "returns nil when then-body on the same line separated with ':' and expression is false" do
-    if false: 123
-    end.should == nil
-
-    if false: 123; end.should == nil
-  end
-
   it "returns nil when then-body on the same line separated with 'then' and expression is false" do
     if false then 123
     end.should == nil
@@ -218,13 +183,6 @@
     if false then 123; end.should == nil
   end
 
-  it "returns nil when then-body separated by ':' is empty and expression is true" do
-    if true:
-    end.should == nil
-
-    if true: ; end.should == nil
-  end
-
   it "returns nil when then-body separated by 'then' is empty and expression is true" do
     if true then
     end.should == nil
@@ -232,13 +190,6 @@
     if true then ; end.should == nil
   end
 
-  it "returns nil when then-body separated by ':', expression is false and no else part" do
-    if false:
-    end.should == nil
-
-    if false: ; end.should == nil
-  end
-
   it "returns nil when then-body separated by 'then', expression is false and no else part" do
     if false then
     end.should == nil
@@ -246,14 +197,6 @@
     if false then ; end.should == nil
   end
 
-  it "evaluates then-body when then-body separated by ':', expression is true and else part is present" do
-    if true: 123
-    else 456
-    end.should == 123
-
-    if true: 123; else 456; end.should == 123
-  end
-
   it "evaluates then-body when then-body separated by 'then', expression is true and else part is present" do
     if true then 123
     else 456
@@ -262,14 +205,6 @@
     if true then 123; else 456; end.should == 123
   end
 
-  it "evaluates else-body when then-body separated by ':' and expression is false" do
-    if false: 123
-    else 456
-    end.should == 456
-
-    if false: 123; else 456; end.should == 456
-  end
-
   it "evaluates else-body when then-body separated by 'then' and expression is false" do
     if false then 123
     else 456
@@ -277,16 +212,6 @@
 
     if false then 123; else 456; end.should == 456
   end
-
-  it "allows elsif-body at the same line separated by ':' or 'then'" do
-    if false then 123
-    elsif false: 234
-    elsif true then 345
-    elsif true: 456
-    end.should == 345
-
-    if false: 123; elsif false then 234; elsif true: 345; elsif true then 456; end.should == 345
-  end
 end
 
 describe "The postfix if form" do
@@ -350,3 +275,5 @@
     b.should == 126
   end
 end
+
+language_version __FILE__, "if"
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/language/versions/if_1.8.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/versions/if_1.8.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/language/versions/if_1.8.rb	2009-03-23 13:24:00 UTC (rev 1101)
@@ -0,0 +1,76 @@
+describe "The if expression" do
+  it "allows starting then-body on the same line if colon is used" do
+    if true: 123
+    else
+      456
+    end.should == 123
+  end
+
+  it "allows both then- and else-bodies start on the same line (with colon after expression)" do
+    if false: 123
+    else 456
+    end.should == 456
+  end
+
+  it "allows ':' after expression when then-body is on the next line" do
+    if true:
+      123
+    end.should == 123
+
+    if true; 123; end.should == 123
+  end
+
+  it "allows then-body on the same line separated with ':'" do
+    if true: 123
+    end.should == 123
+
+    if true: 123; end.should == 123
+  end
+
+  it "returns nil when then-body on the same line separated with ':' and expression is false" do
+    if false: 123
+    end.should == nil
+
+    if false: 123; end.should == nil
+  end
+
+  it "returns nil when then-body separated by ':' is empty and expression is true" do
+    if true:
+    end.should == nil
+
+    if true: ; end.should == nil
+  end
+
+  it "returns nil when then-body separated by ':', expression is false and no else part" do
+    if false:
+    end.should == nil
+
+    if false: ; end.should == nil
+  end
+
+  it "evaluates then-body when then-body separated by ':', expression is true and else part is present" do
+    if true: 123
+    else 456
+    end.should == 123
+
+    if true: 123; else 456; end.should == 123
+  end
+
+  it "evaluates else-body when then-body separated by ':' and expression is false" do
+    if false: 123
+    else 456
+    end.should == 456
+
+    if false: 123; else 456; end.should == 456
+  end
+
+  it "allows elsif-body at the same line separated by ':' or 'then'" do
+    if false then 123
+    elsif false: 234
+    elsif true then 345
+    elsif true: 456
+    end.should == 345
+
+    if false: 123; elsif false then 234; elsif true: 345; elsif true then 456; end.should == 345
+  end
+end
\ No newline at end of file

Added: MacRuby/branches/experimental/spec/frozen/language/versions/if_1.9.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/versions/if_1.9.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/language/versions/if_1.9.rb	2009-03-23 13:24:00 UTC (rev 1101)
@@ -0,0 +1,5 @@
+describe "The if expression" do
+  it "raises a SyntaxError if a colon is used" do
+    lambda { eval "if true: 1; end" }.should raise_error(SyntaxError)
+  end
+end
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090323/bade3238/attachment-0001.html>


More information about the macruby-changes mailing list