Permalink
Browse files

Revert frozen object helper

  • Loading branch information...
1 parent 6b01736 commit 5e9a7918e543df5ae2301468cfe1d1b22de02b6d @jfirebaugh jfirebaugh committed Mar 15, 2012
@@ -30,11 +30,23 @@
end
end
- it "causes mutative calls to raise an error" do
- o = Class.new do
- def mutate; @foo = 1; end
- end.new
- o.freeze
- lambda {o.mutate}.should raise_error(frozen_object_error_class)
+ ruby_version_is "" ... "1.9" do
+ it "causes mutative calls to raise TypeError" do
+ o = Class.new do
+ def mutate; @foo = 1; end
+ end.new
+ o.freeze
+ lambda {o.mutate}.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "causes mutative calls to raise RuntimeError" do
+ o = Class.new do
+ def mutate; @foo = 1; end
+ end.new
+ o.freeze
+ lambda {o.mutate}.should raise_error(RuntimeError)
+ end
end
end
@@ -34,9 +34,18 @@
lambda { @class.make_alias :ni, :san }.should raise_error(NameError)
end
- it "fails if frozen" do
- @class.freeze
- lambda { @class.make_alias :uno, :public_one }.should raise_error(frozen_object_error_class)
+ ruby_version_is ""..."1.9" do
+ it "raises TypeError if frozen" do
+ @class.freeze
+ lambda { @class.make_alias :uno, :public_one }.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "raises RuntimeError if frozen" do
+ @class.freeze
+ lambda { @class.make_alias :uno, :public_one }.should raise_error(RuntimeError)
+ end
end
it "converts the names using #to_str" do
@@ -96,10 +96,20 @@ class DefineMethodSpecClass
}.should raise_error(ArgumentError)
end
- it "raises an error if frozen" do
- lambda {
- Class.new { freeze; define_method(:foo) {} }
- }.should raise_error(frozen_object_error_class)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if frozen" do
+ lambda {
+ Class.new { freeze; define_method(:foo) {} }
+ }.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if frozen" do
+ lambda {
+ Class.new { freeze; define_method(:foo) {} }
+ }.should raise_error(RuntimeError)
+ end
end
it "accepts a Method (still bound)" do
@@ -2,19 +2,39 @@
require File.expand_path('../fixtures/classes', __FILE__)
describe "Module#freeze" do
- it "prevents further modifications to self" do
- m = Module.new.freeze
- m.frozen?.should == true
+ ruby_version_is ""..."1.9" do
+ it "prevents further modifications to self" do
+ m = Module.new.freeze
+ m.frozen?.should == true
- # Does not raise
- class << m; end
+ # Does not raise
+ class << m; end
- lambda {
- class << m
- def test() "test" end
- end
- }.should raise_error(frozen_object_error_class)
+ lambda {
+ class << m
+ def test() "test" end
+ end
+ }.should raise_error(TypeError)
- lambda { def m.test() "test" end }.should raise_error(frozen_object_error_class)
+ lambda { def m.test() "test" end }.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "prevents further modifications to self" do
+ m = Module.new.freeze
+ m.frozen?.should == true
+
+ # Does not raise
+ class << m; end
+
+ lambda {
+ class << m
+ def test() "test" end
+ end
+ }.should raise_error(RuntimeError)
+
+ lambda { def m.test() "test" end }.should raise_error(RuntimeError)
+ end
end
end
@@ -55,9 +55,19 @@ class Third < ModuleSpecs::Second
}.should raise_error(NameError)
end
- it "raises an error when frozen" do
- c = Class.new { def method_to_remove; end }
- c.freeze
- lambda { c.send(:remove_method, :method_to_remove) }.should raise_error(frozen_object_error_class)
+ ruby_version_is ""..."1.9" do
+ it "raises TypeError when frozen" do
+ c = Class.new { def method_to_remove; end }
+ c.freeze
+ lambda { c.send(:remove_method, :method_to_remove) }.should raise_error(TypeError)
+ end
+ end
+
+ ruby_version_is "1.9" do
+ it "raises RuntimeError when frozen" do
+ c = Class.new { def method_to_remove; end }
+ c.freeze
+ lambda { c.send(:remove_method, :method_to_remove) }.should raise_error(RuntimeError)
+ end
end
end

0 comments on commit 5e9a791

Please sign in to comment.