Skip to content

Commit

Permalink
Add specs for Kernel#clone(freeze: nil)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Oct 22, 2021
1 parent 6f86559 commit ad90975
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/ruby/core/kernel/clone_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,30 @@ def klass.allocate
end
end

describe "with freeze: nil" do
ruby_version_is ""..."3.0" do
it "raises ArgumentError" do
-> { @obj.clone(freeze: nil) }.should raise_error(ArgumentError, /unexpected value for freeze: NilClass/)
end
end

ruby_version_is "3.0" do
it "copies frozen state from the original" do
o2 = @obj.clone(freeze: nil)
@obj.freeze
o3 = @obj.clone(freeze: nil)

o2.should_not.frozen?
o3.should.frozen?
end

it "copies frozen?" do
o = "".freeze.clone(freeze: nil)
o.frozen?.should be_true
end
end
end

describe "with freeze: true" do
it 'makes a frozen copy if the original is frozen' do
@obj.freeze
Expand Down

0 comments on commit ad90975

Please sign in to comment.