[macruby-changes] [1377] MacRuby/branches/experimental/spec/frozen/language/throw_spec.rb

source_changes at macosforge.org source_changes at macosforge.org
Sun Apr 5 23:15:03 PDT 2009


Revision: 1377
          http://trac.macosforge.org/projects/ruby/changeset/1377
Author:   lsansonetti at apple.com
Date:     2009-04-05 23:15:03 -0700 (Sun, 05 Apr 2009)
Log Message:
-----------
ported to 1.9 behaviors

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

Modified: MacRuby/branches/experimental/spec/frozen/language/throw_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/throw_spec.rb	2009-04-06 06:08:06 UTC (rev 1376)
+++ MacRuby/branches/experimental/spec/frozen/language/throw_spec.rb	2009-04-06 06:15:03 UTC (rev 1377)
@@ -27,16 +27,33 @@
     msg.should == nil
   end
 
-  it "only allows symbols and strings as it's argument" do
-    lambda { throw 1 }.should raise_error(ArgumentError)    
-    lambda { throw Object.new }.should raise_error(TypeError)    
+  ruby_version_is "" ... "1.9" do
+    it "only allows symbols and strings as its argument" do
+      lambda { throw 1 }.should raise_error(ArgumentError)    
+      lambda { throw Object.new }.should raise_error(TypeError)    
+    end
   end
 
-  it "converts strings to a symbol" do
-    lambda { catch(:exit) { throw "exit" } }.should_not raise_error
-    a = "exit"
-    lambda { catch(:exit) { throw a } }.should_not raise_error
+  ruby_version_is "1.9" do
+    it "only any object as its argument" do
+      lambda { catch(1) { throw 1 } }.should_not raise_error
+      lambda { o = Object.new; catch(o) { throw o } }.should_not raise_error
+    end
   end
+
+  ruby_version_is "" ... "1.9" do
+    it "converts strings to a symbol" do
+      lambda { catch(:exit) { throw "exit" } }.should_not raise_error
+      a = "exit"
+      lambda { catch(:exit) { throw a } }.should_not raise_error
+    end
+  end
+
+  ruby_version_is "1.9" do
+    it "does not convert strings to a symbol" do
+      lambda { catch(:exit) { throw "exit" } }.should raise_error(ArgumentError)
+    end
+  end
     
   it "unwinds stack from within a method" do
     def throw_method(handler,val)
@@ -52,19 +69,42 @@
     c = lambda { throw :foo, :msg }
     catch(:foo) { c.call }.should == :msg
   end
+
+  ruby_version_is "" ... "1.9" do 
+    it "raises a NameError if outside of scope of a matching catch" do    
+      lambda { throw :test,5 }.should raise_error(NameError)
+      lambda { catch(:different) { throw :test,5 } }.should raise_error(NameError)
+    end
+  end
+
+  ruby_version_is "1.9" do 
+    it "raises an ArgumentError if outside of scope of a matching catch" do    
+      lambda { throw :test,5 }.should raise_error(ArgumentError)
+      lambda { catch(:different) { throw :test,5 } }.should raise_error(ArgumentError)
+    end
+  end
+
+  ruby_version_is "" ... "1.9" do 
+    it "raises a ThreadError if used to exit a thread" do
+      lambda {
+        catch(:what) do
+          Thread.new do
+            throw :what
+          end.join
+        end
+      }.should raise_error(ThreadError)
+    end
+  end
   
-  it "raises a name error if outside of scope of a matching catch" do    
-    lambda { throw :test,5 }.should raise_error(NameError)
-    lambda { catch(:different) { throw :test,5 } }.should raise_error(NameError)
+  ruby_version_is "1.9" do 
+    it "raises a ArgumentError if used to exit a thread" do
+      lambda {
+        catch(:what) do
+          Thread.new do
+            throw :what
+          end.join
+        end
+      }.should raise_error(ArgumentError)
+    end
   end
-
-  it "raises a ThreadError if used to exit a thread" do
-    lambda {
-      catch(:what) do
-        Thread.new do
-          throw :what
-        end.join
-      end
-    }.should raise_error(ThreadError)
-  end    
 end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090405/7748e5f8/attachment-0001.html>


More information about the macruby-changes mailing list