Skip to content

Commit

Permalink
Move specs to core/kernel/clone_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
wenderjean committed Oct 15, 2021
1 parent 5a2835a commit 6951ee5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
23 changes: 23 additions & 0 deletions core/kernel/clone_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative '../../spec_helper'
require_relative 'fixtures/classes'
require_relative 'shared/dup_clone'
require 'set'

describe "Kernel#clone" do
it_behaves_like :kernel_dup_clone, :clone
Expand Down Expand Up @@ -125,4 +126,26 @@ def bar
o.tainted?.should be_true
end
end

ruby_version_is ''...'3.0' do
it "raises FrozenError when trying to add items in the new Set" do
set1 = Set[1, 2]
set1.freeze
set2 = set1.clone(freeze: false)

# versions previous to 3.0 used to freeze the internal hash for the new object even when
# using freeze: false
-> { set2.add 3 }.should raise_error(FrozenError)
end
end

ruby_version_is '3.0' do
it 'does not raise FrozenError when trying to add items in the new Set' do
set1 = Set[1, 2]
set1.freeze
set2 = set1.clone(freeze: false)

-> { set2.add 3 }.should_not raise_error(FrozenError)
end
end
end
17 changes: 0 additions & 17 deletions library/set/clone_spec.rb

This file was deleted.

0 comments on commit 6951ee5

Please sign in to comment.