parent
dfa51ccffb
commit
ac870ecc13
@ -0,0 +1,37 @@
|
||||
From 74784e8f7889c3b8f0bb337f04b050e79a3df34a Mon Sep 17 00:00:00 2001
|
||||
From: Ryunosuke SATO <tricknotes.rs@gmail.com>
|
||||
Date: Tue, 14 Oct 2014 23:02:28 +0900
|
||||
Subject: [PATCH] Handle error about frozen object in Ruby 2.2
|
||||
|
||||
This kind of error message seems to be updated in Ruby 2.2.
|
||||
|
||||
For example, the following code throws an error that has different
|
||||
error message with Ruby version:
|
||||
```
|
||||
"".freeze.instance_eval do
|
||||
def hi
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
In Ruby 2.1.3:
|
||||
> RuntimeError: can't modify frozen Class
|
||||
|
||||
In Ruby 2.2.0-preview1:
|
||||
> RuntimeError: can't modify frozen object
|
||||
---
|
||||
lib/pry/exceptions.rb | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/lib/pry/exceptions.rb b/lib/pry/exceptions.rb
|
||||
index 0204d84..080b72e 100644
|
||||
--- a/lib/pry/exceptions.rb
|
||||
+++ b/lib/pry/exceptions.rb
|
||||
@@ -52,6 +52,7 @@ module FrozenObjectException
|
||||
def self.===(exception)
|
||||
["can't modify frozen class/module",
|
||||
"can't modify frozen Class",
|
||||
+ "can't modify frozen object",
|
||||
].include?(exception.message)
|
||||
end
|
||||
end
|
@ -0,0 +1,61 @@
|
||||
From 0807328bcfd1585b0f668c269dd232505fab8a2c Mon Sep 17 00:00:00 2001
|
||||
From: John Mair <jrmair@gmail.com>
|
||||
Date: Mon, 16 Feb 2015 21:10:00 +0100
|
||||
Subject: [PATCH] Rename helper spec: singleton_class(arg) -> eigenclass(arg)
|
||||
|
||||
It was causing the most ridiculous non-sensical test failures, possibly a bug in Ruby itself, but this patch fixes it
|
||||
---
|
||||
spec/method_spec.rb | 14 ++++++++------
|
||||
1 file changed, 8 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/spec/method_spec.rb b/spec/method_spec.rb
|
||||
index 980c555..8e38b6d 100644
|
||||
--- a/spec/method_spec.rb
|
||||
+++ b/spec/method_spec.rb
|
||||
@@ -389,7 +389,7 @@ class Lower < Low; extend N; end
|
||||
class Bottom < Lower; extend O; end
|
||||
end
|
||||
|
||||
- def singleton_class(obj); class << obj; self; end; end
|
||||
+ def eigen_class(obj); class << obj; self; end; end
|
||||
|
||||
it "should look at a class and then its superclass" do
|
||||
Pry::Method.instance_resolution_order(LS::Next).should == [LS::Next] + Pry::Method.instance_resolution_order(LS::Top)
|
||||
@@ -409,7 +409,7 @@ def singleton_class(obj); class << obj; self; end; end
|
||||
|
||||
it "should include the singleton class of objects" do
|
||||
obj = LS::Low.new
|
||||
- Pry::Method.resolution_order(obj).should == [singleton_class(obj)] + Pry::Method.instance_resolution_order(LS::Low)
|
||||
+ Pry::Method.resolution_order(obj).should == [eigen_class(obj)] + Pry::Method.instance_resolution_order(LS::Low)
|
||||
end
|
||||
|
||||
it "should not include singleton classes of numbers" do
|
||||
@@ -417,11 +417,11 @@ def singleton_class(obj); class << obj; self; end; end
|
||||
end
|
||||
|
||||
it "should include singleton classes for classes" do
|
||||
- Pry::Method.resolution_order(LS::Low).should == [singleton_class(LS::Low)] + Pry::Method.resolution_order(LS::Next)
|
||||
+ Pry::Method.resolution_order(LS::Low).should == [eigen_class(LS::Low)] + Pry::Method.resolution_order(LS::Next)
|
||||
end
|
||||
|
||||
it "should include modules included into singleton classes" do
|
||||
- Pry::Method.resolution_order(LS::Lower).should == [singleton_class(LS::Lower), LS::N, LS::M] + Pry::Method.resolution_order(LS::Low)
|
||||
+ Pry::Method.resolution_order(LS::Lower).should == [eigen_class(LS::Lower), LS::N, LS::M] + Pry::Method.resolution_order(LS::Low)
|
||||
end
|
||||
|
||||
it "should include modules at most once" do
|
||||
@@ -429,12 +429,12 @@ def singleton_class(obj); class << obj; self; end; end
|
||||
end
|
||||
|
||||
it "should include modules at the point which they would be reached" do
|
||||
- Pry::Method.resolution_order(LS::Bottom).should == [singleton_class(LS::Bottom), LS::O] + (Pry::Method.resolution_order(LS::Lower))
|
||||
+ Pry::Method.resolution_order(LS::Bottom).should == [eigen_class(LS::Bottom), LS::O] + (Pry::Method.resolution_order(LS::Lower))
|
||||
end
|
||||
|
||||
it "should include the Pry::Method.instance_resolution_order of Class after the singleton classes" do
|
||||
Pry::Method.resolution_order(LS::Top).should ==
|
||||
- [singleton_class(LS::Top), singleton_class(Object), singleton_class(BasicObject),
|
||||
+ [eigen_class(LS::Top), eigen_class(Object), eigen_class(BasicObject),
|
||||
*Pry::Method.instance_resolution_order(Class)]
|
||||
end
|
||||
end
|
Loading…
Reference in new issue