summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-09-25 18:05:55 +0900
committerKoichi Sasada <ko1@atdot.net>2020-09-25 22:16:55 +0900
commit0096d2b895395df5ab8696d3b6d444dc1b7730b6 (patch)
tree21aa9c7e0eab7304433d05b6bce6f5b26f5e1d95 /spec/ruby
parentf4328d7f5d035b5a292d00ad21e79818b9220d8b (diff)
freeze all Range objects.v3_0_0_preview1
Matz want to try to freeze all Range objects. [Feature #15504]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3583
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/marshal/dump_spec.rb2
-rw-r--r--spec/ruby/core/range/initialize_spec.rb9
2 files changed, 8 insertions, 3 deletions
diff --git a/spec/ruby/core/marshal/dump_spec.rb b/spec/ruby/core/marshal/dump_spec.rb
index 4ffc586364..30f1b7513b 100644
--- a/spec/ruby/core/marshal/dump_spec.rb
+++ b/spec/ruby/core/marshal/dump_spec.rb
@@ -419,7 +419,7 @@ describe "Marshal.dump" do
load.should == range
load.instance_variable_get(:@foo).should == 42
end
- end
+ end unless (1...3).frozen? # Ruby 3.0 -
describe "with a Time" do
before :each do
diff --git a/spec/ruby/core/range/initialize_spec.rb b/spec/ruby/core/range/initialize_spec.rb
index 8caf12baa2..d2826a5ba5 100644
--- a/spec/ruby/core/range/initialize_spec.rb
+++ b/spec/ruby/core/range/initialize_spec.rb
@@ -28,8 +28,13 @@ describe "Range#initialize" do
end
it "raises a NameError if called on an already initialized Range" do
- -> { (0..1).send(:initialize, 1, 3) }.should raise_error(NameError)
- -> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(NameError)
+ if (0..1).frozen? # Ruby 3.0-
+ -> { (0..1).send(:initialize, 1, 3) }.should raise_error(FrozenError)
+ -> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(FrozenError)
+ else
+ -> { (0..1).send(:initialize, 1, 3) }.should raise_error(NameError)
+ -> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(NameError)
+ end
end
it "raises an ArgumentError if arguments don't respond to <=>" do