[macruby-changes] [1376] MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb
source_changes at macosforge.org
source_changes at macosforge.org
Sun Apr 5 23:08:08 PDT 2009
Revision: 1376
http://trac.macosforge.org/projects/ruby/changeset/1376
Author: lsansonetti at apple.com
Date: 2009-04-05 23:08:06 -0700 (Sun, 05 Apr 2009)
Log Message:
-----------
ported to 1.9 behaviors
Modified Paths:
--------------
MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb
Modified: MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb 2009-04-06 02:07:37 UTC (rev 1375)
+++ MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb 2009-04-06 06:08:06 UTC (rev 1376)
@@ -1,24 +1,44 @@
require File.dirname(__FILE__) + '/../spec_helper'
-describe "The catch keyword" do
- it "only allows symbols and strings" do
- lambda { catch(:foo) {} }.should_not raise_error
- lambda { catch("foo") {} }.should_not raise_error
- lambda { catch 1 }.should raise_error(ArgumentError)
- lambda { catch Object.new }.should raise_error(TypeError)
+describe "The catch keyword" do
+
+ ruby_version_is "" ... "1.9" do
+ it "only allows symbols and strings" do
+ lambda { catch(:foo) {} }.should_not raise_error
+ lambda { catch("foo") {} }.should_not raise_error
+ lambda { catch 1 }.should raise_error(ArgumentError)
+ lambda { catch Object.new }.should raise_error(TypeError)
+ end
end
+ ruby_version_is "1.9" do
+ it "allows any object" do
+ lambda { catch(:foo) {} }.should_not raise_error
+ lambda { catch("foo") {} }.should_not raise_error
+ lambda { catch(1) {} }.should_not raise_error
+ lambda { catch(Object.new) {} }.should_not raise_error
+ end
+ end
+
it "returns the last value of the block if it nothing is thrown" do
catch(:exit) do
:noexit
end.should == :noexit
end
- it "matches strings as symbols" do
- lambda { catch("exit") { throw :exit } }.should_not raise_error
- lambda { catch("exit") { throw "exit" } }.should_not raise_error
+ ruby_version_is "" ... "1.9" do
+ it "matches strings as symbols" do
+ lambda { catch("exit") { throw :exit } }.should_not raise_error
+ lambda { catch("exit") { throw "exit" } }.should_not raise_error
+ end
end
+ ruby_version_is "1.9" do
+ it "does not match strings as symbols" do
+ lambda { catch("exit") { throw :exit } }.should raise_error(ArgumentError)
+ end
+ end
+
it "requires a block" do
lambda { catch :foo }.should raise_error(LocalJumpError)
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090405/acf7878f/attachment.html>
More information about the macruby-changes
mailing list