[macruby-changes] [1381] MacRuby/branches/experimental/spec/frozen
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 6 01:16:37 PDT 2009
Revision: 1381
http://trac.macosforge.org/projects/ruby/changeset/1381
Author: eloy.de.enige at gmail.com
Date: 2009-04-06 01:16:37 -0700 (Mon, 06 Apr 2009)
Log Message:
-----------
Updated 1.9 catch specs and added a few more.
Modified Paths:
--------------
MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb
MacRuby/branches/experimental/spec/frozen/tags/macruby/language/catch_tags.txt
Modified: MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb 2009-04-06 08:14:34 UTC (rev 1380)
+++ MacRuby/branches/experimental/spec/frozen/language/catch_spec.rb 2009-04-06 08:16:37 UTC (rev 1381)
@@ -1,13 +1,12 @@
require File.dirname(__FILE__) + '/../spec_helper'
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)
+ lambda { catch(1) {} }.should raise_error(ArgumentError)
+ lambda { catch(Object.new) {} }.should raise_error(TypeError)
end
end
@@ -21,22 +20,31 @@
end
it "returns the last value of the block if it nothing is thrown" do
- catch(:exit) do
+ catch(:exit) do
:noexit
end.should == :noexit
end
-
+
ruby_version_is "" ... "1.9" do
it "matches strings as symbols" do
lambda { catch("exit") { throw :exit } }.should_not raise_error
+ end
+
+ it "matches strings with strings that contain the same characters" do
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
+ it "does not match objects that are not exactly the same" do
lambda { catch("exit") { throw :exit } }.should raise_error(ArgumentError)
+ lambda { catch("exit") { throw "exit" } }.should raise_error(ArgumentError)
end
+
+ it "catches objects that are exactly the same" do
+ lambda { catch(:exit) { throw :exit } }.should_not raise_error
+ lambda { exit = "exit"; catch(exit) { throw exit } }.should_not raise_error
+ end
end
it "requires a block" do
@@ -72,5 +80,5 @@
i << :a_exit
i.should == [:a,:b,:b_exit,:a_exit]
- end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/language/catch_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/language/catch_tags.txt 2009-04-06 08:14:34 UTC (rev 1380)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/language/catch_tags.txt 2009-04-06 08:16:37 UTC (rev 1381)
@@ -1,5 +1,4 @@
-fails:The catch keyword only allows symbols and strings
fails:The catch keyword returns the last value of the block if it nothing is thrown
-fails:The catch keyword requires a block
+fails:The catch keyword does not match objects that are not exactly the same
fails:The catch keyword supports nesting
fails:The catch keyword supports nesting with the same name
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090406/5dfc62a1/attachment.html>
More information about the macruby-changes
mailing list