зеркало из https://github.com/github/ruby.git
Use FrozenError instead of frozen_error_class
This commit is contained in:
Родитель
151f8be40d
Коммит
3a2073e61b
|
@ -3,7 +3,6 @@ require 'mspec/helpers/argv'
|
|||
require 'mspec/helpers/datetime'
|
||||
require 'mspec/helpers/fixture'
|
||||
require 'mspec/helpers/flunk'
|
||||
require 'mspec/helpers/frozen_error_class'
|
||||
require 'mspec/helpers/fs'
|
||||
require 'mspec/helpers/io'
|
||||
require 'mspec/helpers/mock_to_path'
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
require 'mspec/guards/version'
|
||||
|
||||
# This helper makes it easy to write version independent
|
||||
# specs for frozen objects.
|
||||
unless respond_to? :frozen_error_class, true
|
||||
ruby_version_is "2.5" do
|
||||
def frozen_error_class
|
||||
FrozenError
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
def frozen_error_class
|
||||
RuntimeError
|
||||
end
|
||||
end
|
||||
end
|
|
@ -30,8 +30,8 @@ describe "Array#<<" do
|
|||
a.should == [:foo]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array << 5 }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array << 5 }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ describe "Array#clear" do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
a = [1]
|
||||
a.freeze
|
||||
-> { a.clear }.should raise_error(frozen_error_class)
|
||||
-> { a.clear }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,7 +75,7 @@ describe "Array#compact!" do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.compact! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.compact! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,13 +32,13 @@ describe "Array#concat" do
|
|||
[].concat(obj).should == [5, 6, 7]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when Array is frozen and modification occurs" do
|
||||
-> { ArraySpecs.frozen_array.concat [1] }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when Array is frozen and modification occurs" do
|
||||
-> { ArraySpecs.frozen_array.concat [1] }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} when Array is frozen and no modification occurs" do
|
||||
-> { ArraySpecs.frozen_array.concat([]) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when Array is frozen and no modification occurs" do
|
||||
-> { ArraySpecs.frozen_array.concat([]) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.7' do
|
||||
|
|
|
@ -35,8 +35,8 @@ describe "Array#delete_at" do
|
|||
a.delete_at(-2).should == 1
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { [1,2,3].freeze.delete_at(0) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { [1,2,3].freeze.delete_at(0) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.7' do
|
||||
|
|
|
@ -39,12 +39,12 @@ describe "Array#delete_if" do
|
|||
@a.freeze.delete_if.should be_an_instance_of(Enumerator)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.delete_if {} }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.delete_if {} }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.7' do
|
||||
|
|
|
@ -40,8 +40,8 @@ describe "Array#delete" do
|
|||
[1, 2, 3].freeze.delete(0).should == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { [1, 2, 3].freeze.delete(1) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { [1, 2, 3].freeze.delete(1) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.7' do
|
||||
|
|
|
@ -94,8 +94,8 @@ describe "Array#[]=" do
|
|||
|
||||
it "checks frozen before attempting to coerce arguments" do
|
||||
a = [1,2,3,4].freeze
|
||||
-> {a[:foo] = 1}.should raise_error(frozen_error_class)
|
||||
-> {a[:foo, :bar] = 1}.should raise_error(frozen_error_class)
|
||||
-> {a[:foo] = 1}.should raise_error(FrozenError)
|
||||
-> {a[:foo, :bar] = 1}.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "sets elements in the range arguments when passed ranges" do
|
||||
|
@ -236,8 +236,8 @@ describe "Array#[]=" do
|
|||
ary.should == [5, 6, 7]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array[0, 0] = [] }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array[0, 0] = [] }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,12 +43,12 @@ describe "Array#fill" do
|
|||
[nil, nil, nil, nil].fill { |i| i * 2 }.should == [0, 2, 4, 6]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.fill('x') }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.fill('x') }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if 4 or more arguments are passed when no block given" do
|
||||
|
|
|
@ -272,15 +272,15 @@ describe "Array#flatten!" do
|
|||
ary.should == [1, 2, 3]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array is modified" do
|
||||
it "raises a FrozenError on frozen arrays when the array is modified" do
|
||||
nested_ary = [1, 2, []]
|
||||
nested_ary.freeze
|
||||
-> { nested_ary.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { nested_ary.flatten! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23663]
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on frozen arrays when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.flatten! }.should raise_error(FrozenError)
|
||||
-> { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,13 +32,13 @@ describe "Array#initialize" do
|
|||
end.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on frozen arrays" do
|
||||
it "raises a FrozenError on frozen arrays" do
|
||||
-> do
|
||||
ArraySpecs.frozen_array.send :initialize
|
||||
end.should raise_error(frozen_error_class)
|
||||
end.should raise_error(FrozenError)
|
||||
-> do
|
||||
ArraySpecs.frozen_array.send :initialize, ArraySpecs.frozen_array
|
||||
end.should raise_error(frozen_error_class)
|
||||
end.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "calls #to_ary to convert the value to an array, even if it's private" do
|
||||
|
|
|
@ -67,12 +67,12 @@ describe "Array#insert" do
|
|||
-> { [].insert() }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array is modified" do
|
||||
-> { ArraySpecs.frozen_array.insert(0, 'x') }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on frozen arrays when the array is modified" do
|
||||
-> { ArraySpecs.frozen_array.insert(0, 'x') }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.insert(0) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on frozen arrays when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.insert(0) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,12 +40,12 @@ describe "Array#pop" do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.pop }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.pop }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.pop }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.pop }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.7' do
|
||||
|
@ -158,9 +158,9 @@ describe "Array#pop" do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.pop(2) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.pop(0) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.pop(2) }.should raise_error(FrozenError)
|
||||
-> { ArraySpecs.frozen_array.pop(0) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
ruby_version_is ''...'2.7' do
|
||||
|
|
|
@ -103,12 +103,12 @@ describe "Array#reject!" do
|
|||
ArraySpecs.frozen_array.reject!.should be_an_instance_of(Enumerator)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.reject! {} }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.reject! {} }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not truncate the array is the block raises an exception" do
|
||||
|
|
|
@ -36,7 +36,7 @@ describe "Array#reverse!" do
|
|||
array.reverse!.should == [array, array, array, array, array, 3.0, 'two', 1]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.reverse! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.reverse! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -121,9 +121,9 @@ describe "Array#rotate!" do
|
|||
a.should == []
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { [1, 2, 3].freeze.rotate!(0) }.should raise_error(frozen_error_class)
|
||||
-> { [1].freeze.rotate!(42) }.should raise_error(frozen_error_class)
|
||||
-> { [].freeze.rotate! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { [1, 2, 3].freeze.rotate!(0) }.should raise_error(FrozenError)
|
||||
-> { [1].freeze.rotate!(42) }.should raise_error(FrozenError)
|
||||
-> { [].freeze.rotate! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -114,22 +114,22 @@ describe :array_collect_b, shared: true do
|
|||
end
|
||||
|
||||
describe "when frozen" do
|
||||
it "raises a #{frozen_error_class}" do
|
||||
-> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError" do
|
||||
-> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when empty" do
|
||||
-> { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when empty" do
|
||||
-> { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when calling #each on the returned Enumerator" do
|
||||
it "raises a FrozenError when calling #each on the returned Enumerator" do
|
||||
enumerator = ArraySpecs.frozen_array.send(@method)
|
||||
-> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
|
||||
-> { enumerator.each {|x| x } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when calling #each on the returned Enumerator when empty" do
|
||||
it "raises a FrozenError when calling #each on the returned Enumerator when empty" do
|
||||
enumerator = ArraySpecs.empty_frozen_array.send(@method)
|
||||
-> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
|
||||
-> { enumerator.each {|x| x } }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ describe :keep_if, shared: true do
|
|||
@frozen.should == @origin
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class}" do
|
||||
-> { @frozen.send(@method) { true } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError" do
|
||||
-> { @frozen.send(@method) { true } }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,8 +52,8 @@ describe :keep_if, shared: true do
|
|||
@frozen.should == @origin
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class}" do
|
||||
-> { @frozen.send(@method) { false } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError" do
|
||||
-> { @frozen.send(@method) { false } }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,8 +26,8 @@ describe :array_push, shared: true do
|
|||
array.send(@method, :last).should == [1, 'two', 3.0, array, array, array, array, array, :last]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(FrozenError)
|
||||
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,9 +52,9 @@ describe :array_replace, shared: true do
|
|||
[].send(@method, ArraySpecs::ToAryArray[5, 6, 7]).should == [5, 6, 7]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> {
|
||||
ArraySpecs.frozen_array.send(@method, ArraySpecs.frozen_array)
|
||||
}.should raise_error(frozen_error_class)
|
||||
}.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,12 +35,12 @@ describe :array_unshift, shared: true do
|
|||
array[0..5].should == [:new, 1, 'two', 3.0, array, array]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array when the array is modified" do
|
||||
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array when the array is modified" do
|
||||
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen array when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,11 +30,11 @@ describe "Array#shift" do
|
|||
array[0..2].should == ['two', 3.0, array]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.shift }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.shift }.should raise_error(FrozenError)
|
||||
end
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.shift }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.shift }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
describe "passed a number n as an argument" do
|
||||
|
|
|
@ -89,8 +89,8 @@ describe "Array#shuffle!" do
|
|||
a.should equal(original)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.shuffle! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.shuffle! }.should raise_error(FrozenError)
|
||||
-> { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -150,8 +150,8 @@ describe "Array#slice!" do
|
|||
a.should == [1, 2]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
|
|
|
@ -23,12 +23,12 @@ describe "Array#sort_by!" do
|
|||
a.should be_an_instance_of(Array)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty frozen array" do
|
||||
-> { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "returns the specified value when it would break in the given block" do
|
||||
|
|
|
@ -233,8 +233,8 @@ describe "Array#sort!" do
|
|||
a.sort!{ -1 }.should be_an_instance_of(Array)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.sort! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.sort! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "returns the specified value when it would break in the given block" do
|
||||
|
|
|
@ -220,20 +220,20 @@ describe "Array#uniq!" do
|
|||
[ "a", "b", "c" ].uniq!.should == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array when the array is modified" do
|
||||
it "raises a FrozenError on a frozen array when the array is modified" do
|
||||
dup_ary = [1, 1, 2]
|
||||
dup_ary.freeze
|
||||
-> { dup_ary.uniq! }.should raise_error(frozen_error_class)
|
||||
-> { dup_ary.uniq! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen array when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.uniq!}.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen array when the array would not be modified" do
|
||||
-> { ArraySpecs.frozen_array.uniq!}.should raise_error(FrozenError)
|
||||
-> { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "doesn't yield to the block on a frozen array" do
|
||||
-> { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.uniq!{ raise RangeError, "shouldn't yield"}}.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "compares elements based on the value returned from the block" do
|
||||
|
|
|
@ -25,8 +25,8 @@ describe "Hash#clear" do
|
|||
h.default_proc.should_not == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.clear }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.empty_frozen_hash.clear }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.clear }.should raise_error(FrozenError)
|
||||
-> { HashSpecs.empty_frozen_hash.clear }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,8 +51,8 @@ describe "Hash#compact!" do
|
|||
@hash.freeze
|
||||
end
|
||||
|
||||
it "keeps pairs and raises a #{frozen_error_class}" do
|
||||
->{ @hash.compact! }.should raise_error(frozen_error_class)
|
||||
it "keeps pairs and raises a FrozenError" do
|
||||
->{ @hash.compact! }.should raise_error(FrozenError)
|
||||
@hash.should == @initial_pairs
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,9 +80,9 @@ describe "Hash#compare_by_identity" do
|
|||
@h[o].should == :o
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on frozen hashes" do
|
||||
it "raises a FrozenError on frozen hashes" do
|
||||
@h = @h.freeze
|
||||
-> { @h.compare_by_identity }.should raise_error(frozen_error_class)
|
||||
-> { @h.compare_by_identity }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# Behaviour confirmed in bug #1871
|
||||
|
|
|
@ -73,8 +73,8 @@ describe "Hash#default_proc=" do
|
|||
end.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
-> { {}.freeze.default_proc = Proc.new {} }.should raise_error(frozen_error_class)
|
||||
-> { {}.freeze.default_proc = nil }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
-> { {}.freeze.default_proc = Proc.new {} }.should raise_error(FrozenError)
|
||||
-> { {}.freeze.default_proc = nil }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,8 +39,8 @@ describe "Hash#default=" do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.default = nil }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.empty_frozen_hash.default = nil }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.default = nil }.should raise_error(FrozenError)
|
||||
-> { HashSpecs.empty_frozen_hash.default = nil }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,9 +34,9 @@ describe "Hash#delete_if" do
|
|||
each_pairs.should == delete_pairs
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.delete_if { false } }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.empty_frozen_hash.delete_if { true } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.delete_if { false } }.should raise_error(FrozenError)
|
||||
-> { HashSpecs.empty_frozen_hash.delete_if { true } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it_behaves_like :hash_iteration_no_block, :delete_if
|
||||
|
|
|
@ -37,8 +37,8 @@ describe "Hash#delete" do
|
|||
{ key => 5 }.delete(key).should == 5
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.delete("foo") }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.empty_frozen_hash.delete("foo") }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.delete("foo") }.should raise_error(FrozenError)
|
||||
-> { HashSpecs.empty_frozen_hash.delete("foo") }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,17 +45,17 @@ describe "Hash#initialize" do
|
|||
h.send(:initialize).should equal(h)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
block = -> { HashSpecs.frozen_hash.instance_eval { initialize() }}
|
||||
block.should raise_error(frozen_error_class)
|
||||
block.should raise_error(FrozenError)
|
||||
|
||||
block = -> { HashSpecs.frozen_hash.instance_eval { initialize(nil) } }
|
||||
block.should raise_error(frozen_error_class)
|
||||
block.should raise_error(FrozenError)
|
||||
|
||||
block = -> { HashSpecs.frozen_hash.instance_eval { initialize(5) } }
|
||||
block.should raise_error(frozen_error_class)
|
||||
block.should raise_error(FrozenError)
|
||||
|
||||
block = -> { HashSpecs.frozen_hash.instance_eval { initialize { 5 } } }
|
||||
block.should raise_error(frozen_error_class)
|
||||
block.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,9 +27,9 @@ describe "Hash#keep_if" do
|
|||
h.keep_if { true }.should equal(h)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.keep_if { true } }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.empty_frozen_hash.keep_if { false } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.keep_if { true } }.should raise_error(FrozenError)
|
||||
-> { HashSpecs.empty_frozen_hash.keep_if { false } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it_behaves_like :hash_iteration_no_block, :keep_if
|
||||
|
|
|
@ -59,8 +59,8 @@ describe "Hash#rehash" do
|
|||
h.keys.should == [a]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.rehash }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.empty_frozen_hash.rehash }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.rehash }.should raise_error(FrozenError)
|
||||
-> { HashSpecs.empty_frozen_hash.rehash }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -89,12 +89,12 @@ describe "Hash#reject!" do
|
|||
reject_bang_pairs.should == delete_if_pairs
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance that is modified" do
|
||||
-> { HashSpecs.empty_frozen_hash.reject! { true } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance that is modified" do
|
||||
-> { HashSpecs.empty_frozen_hash.reject! { true } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance that would not be modified" do
|
||||
-> { HashSpecs.frozen_hash.reject! { false } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance that would not be modified" do
|
||||
-> { HashSpecs.frozen_hash.reject! { false } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it_behaves_like :hash_iteration_no_block, :reject!
|
||||
|
|
|
@ -37,15 +37,15 @@ describe :hash_replace, shared: true do
|
|||
hash_a.default.should == hash_b.default
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance that would not be modified" do
|
||||
it "raises a FrozenError if called on a frozen instance that would not be modified" do
|
||||
-> do
|
||||
HashSpecs.frozen_hash.send(@method, HashSpecs.frozen_hash)
|
||||
end.should raise_error(frozen_error_class)
|
||||
end.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance that is modified" do
|
||||
it "raises a FrozenError if called on a frozen instance that is modified" do
|
||||
-> do
|
||||
HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash)
|
||||
end.should raise_error(frozen_error_class)
|
||||
end.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,12 +74,12 @@ describe :hash_select!, shared: true do
|
|||
{ a: 1 }.send(@method) { |k,v| v <= 1 }.should == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on an empty frozen instance" do
|
||||
-> { HashSpecs.empty_frozen_hash.send(@method) { false } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on an empty frozen instance" do
|
||||
-> { HashSpecs.empty_frozen_hash.send(@method) { false } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance that would not be modified" do
|
||||
-> { HashSpecs.frozen_hash.send(@method) { true } }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance that would not be modified" do
|
||||
-> { HashSpecs.frozen_hash.send(@method) { true } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it_should_behave_like :hash_iteration_no_block
|
||||
|
|
|
@ -86,8 +86,8 @@ describe :hash_store, shared: true do
|
|||
h.keys.last.should_not equal(key2)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.send(@method, 1, 2) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.send(@method, 1, 2) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not raise an exception if changing the value of an existing key during iteration" do
|
||||
|
|
|
@ -34,10 +34,10 @@ describe :hash_update, shared: true do
|
|||
merge_bang_pairs.should == merge_pairs
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> do
|
||||
HashSpecs.frozen_hash.send(@method, 1 => 2)
|
||||
end.should raise_error(frozen_error_class)
|
||||
end.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "checks frozen status before coercing an object with #to_hash" do
|
||||
|
@ -47,14 +47,14 @@ describe :hash_update, shared: true do
|
|||
def obj.to_hash() raise Exception, "should not receive #to_hash" end
|
||||
obj.freeze
|
||||
|
||||
-> { HashSpecs.frozen_hash.send(@method, obj) }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.frozen_hash.send(@method, obj) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see redmine #1571
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
-> do
|
||||
HashSpecs.frozen_hash.send(@method, HashSpecs.empty_frozen_hash)
|
||||
end.should raise_error(frozen_error_class)
|
||||
end.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not raise an exception if changing the value of an existing key during iteration" do
|
||||
|
|
|
@ -57,9 +57,9 @@ describe "Hash#shift" do
|
|||
h.should == {:c => 3}
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.shift }.should raise_error(frozen_error_class)
|
||||
-> { HashSpecs.empty_frozen_hash.shift }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if called on a frozen instance" do
|
||||
-> { HashSpecs.frozen_hash.shift }.should raise_error(FrozenError)
|
||||
-> { HashSpecs.empty_frozen_hash.shift }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "works when the hash is at capacity" do
|
||||
|
|
|
@ -113,12 +113,12 @@ ruby_version_is "2.5" do
|
|||
@hash.freeze
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty hash" do
|
||||
->{ {}.freeze.transform_keys!(&:upcase) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty hash" do
|
||||
->{ {}.freeze.transform_keys!(&:upcase) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "keeps pairs and raises a #{frozen_error_class}" do
|
||||
->{ @hash.transform_keys!(&:upcase) }.should raise_error(frozen_error_class)
|
||||
it "keeps pairs and raises a FrozenError" do
|
||||
->{ @hash.transform_keys!(&:upcase) }.should raise_error(FrozenError)
|
||||
@hash.should == @initial_pairs
|
||||
end
|
||||
|
||||
|
|
|
@ -79,12 +79,12 @@ describe "Hash#transform_values!" do
|
|||
@hash.freeze
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty hash" do
|
||||
->{ {}.freeze.transform_values!(&:succ) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on an empty hash" do
|
||||
->{ {}.freeze.transform_values!(&:succ) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "keeps pairs and raises a #{frozen_error_class}" do
|
||||
->{ @hash.transform_values!(&:succ) }.should raise_error(frozen_error_class)
|
||||
it "keeps pairs and raises a FrozenError" do
|
||||
->{ @hash.transform_values!(&:succ) }.should raise_error(FrozenError)
|
||||
@hash.should == @initial_pairs
|
||||
end
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ describe "Kernel#autoload" do
|
|||
end
|
||||
|
||||
describe "when Object is frozen" do
|
||||
it "raises a #{frozen_error_class} before defining the constant" do
|
||||
ruby_exe(fixture(__FILE__, "autoload_frozen.rb")).should == "#{frozen_error_class} - nil"
|
||||
it "raises a FrozenError before defining the constant" do
|
||||
ruby_exe(fixture(__FILE__, "autoload_frozen.rb")).should == "FrozenError - nil"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ describe "Kernel#extend" do
|
|||
-> { @frozen.extend }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class}" do
|
||||
-> { @frozen.extend @module }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError" do
|
||||
-> { @frozen.extend @module }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -82,12 +82,12 @@ describe "Kernel#instance_variable_set" do
|
|||
@frozen.ivar.should equal(:origin)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed replacement is identical to stored object" do
|
||||
-> { @frozen.instance_variable_set(:@ivar, :origin) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when passed replacement is identical to stored object" do
|
||||
-> { @frozen.instance_variable_set(:@ivar, :origin) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed replacement is different from stored object" do
|
||||
-> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when passed replacement is different from stored object" do
|
||||
-> { @frozen.instance_variable_set(:@ivar, :replacement) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,9 +14,9 @@ describe "Kernel#taint" do
|
|||
o.tainted?.should == true
|
||||
end
|
||||
|
||||
it "raises #{frozen_error_class} on an untainted, frozen object" do
|
||||
it "raises FrozenError on an untainted, frozen object" do
|
||||
o = Object.new.freeze
|
||||
-> { o.taint }.should raise_error(frozen_error_class)
|
||||
-> { o.taint }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not raise an error on a tainted, frozen object" do
|
||||
|
|
|
@ -14,9 +14,9 @@ describe "Kernel#trust" do
|
|||
o.untrusted?.should == false
|
||||
end
|
||||
|
||||
it "raises #{frozen_error_class} on an untrusted, frozen object" do
|
||||
it "raises FrozenError on an untrusted, frozen object" do
|
||||
o = Object.new.untrust.freeze
|
||||
-> { o.trust }.should raise_error(frozen_error_class)
|
||||
-> { o.trust }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not raise an error on a trusted, frozen object" do
|
||||
|
|
|
@ -14,9 +14,9 @@ describe "Kernel#untaint" do
|
|||
o.tainted?.should == false
|
||||
end
|
||||
|
||||
it "raises #{frozen_error_class} on a tainted, frozen object" do
|
||||
it "raises FrozenError on a tainted, frozen object" do
|
||||
o = Object.new.taint.freeze
|
||||
-> { o.untaint }.should raise_error(frozen_error_class)
|
||||
-> { o.untaint }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not raise an error on an untainted, frozen object" do
|
||||
|
|
|
@ -14,9 +14,9 @@ describe "Kernel#untrust" do
|
|||
o.untrusted?.should == true
|
||||
end
|
||||
|
||||
it "raises #{frozen_error_class} on a trusted, frozen object" do
|
||||
it "raises FrozenError on a trusted, frozen object" do
|
||||
o = Object.new.freeze
|
||||
-> { o.untrust }.should raise_error(frozen_error_class)
|
||||
-> { o.untrust }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not raise an error on an untrusted, frozen object" do
|
||||
|
|
|
@ -61,9 +61,9 @@ describe "Module#alias_method" do
|
|||
}
|
||||
end
|
||||
|
||||
it "raises #{frozen_error_class} if frozen" do
|
||||
it "raises FrozenError if frozen" do
|
||||
@class.freeze
|
||||
-> { @class.make_alias :uno, :public_one }.should raise_error(frozen_error_class)
|
||||
-> { @class.make_alias :uno, :public_one }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "converts the names using #to_str" do
|
||||
|
|
|
@ -67,8 +67,8 @@ describe "Module#append_features" do
|
|||
@other = Module.new.freeze
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} before appending self" do
|
||||
-> { @receiver.send(:append_features, @other) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError before appending self" do
|
||||
-> { @receiver.send(:append_features, @other) }.should raise_error(FrozenError)
|
||||
@other.ancestors.should_not include(@receiver)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -737,9 +737,9 @@ describe "Module#autoload" do
|
|||
end
|
||||
|
||||
describe "on a frozen module" do
|
||||
it "raises a #{frozen_error_class} before setting the name" do
|
||||
it "raises a FrozenError before setting the name" do
|
||||
frozen_module = Module.new.freeze
|
||||
-> { frozen_module.autoload :Foo, @non_existent }.should raise_error(frozen_error_class)
|
||||
-> { frozen_module.autoload :Foo, @non_existent }.should raise_error(FrozenError)
|
||||
frozen_module.should_not have_constant(:Foo)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,13 +25,13 @@ describe "Module#class_variable_set" do
|
|||
c.send(:class_variable_get, "@@mvar").should == :new_mvar
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
-> {
|
||||
Class.new.freeze.send(:class_variable_set, :@@test, "test")
|
||||
}.should raise_error(frozen_error_class)
|
||||
}.should raise_error(FrozenError)
|
||||
-> {
|
||||
Module.new.freeze.send(:class_variable_set, :@@test, "test")
|
||||
}.should raise_error(frozen_error_class)
|
||||
}.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a NameError when the given name is not allowed" do
|
||||
|
|
|
@ -125,8 +125,8 @@ describe "Module#const_set" do
|
|||
@name = :Foo
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} before setting the name" do
|
||||
-> { @frozen.const_set @name, nil }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError before setting the name" do
|
||||
-> { @frozen.const_set @name, nil }.should raise_error(FrozenError)
|
||||
@frozen.should_not have_constant(@name)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -245,10 +245,10 @@ describe "Module#define_method" do
|
|||
-> { obj.proc_style_test :arg }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if frozen" do
|
||||
it "raises a FrozenError if frozen" do
|
||||
-> {
|
||||
Class.new { freeze; define_method(:foo) {} }
|
||||
}.should raise_error(frozen_error_class)
|
||||
}.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "accepts a Method (still bound)" do
|
||||
|
|
|
@ -97,12 +97,12 @@ describe "Module#remove_method" do
|
|||
@frozen = @module.dup.freeze
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed a name" do
|
||||
-> { @frozen.send :remove_method, :method_to_remove }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when passed a name" do
|
||||
-> { @frozen.send :remove_method, :method_to_remove }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed a missing name" do
|
||||
-> { @frozen.send :remove_method, :not_exist }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when passed a missing name" do
|
||||
-> { @frozen.send :remove_method, :not_exist }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed a not name" do
|
||||
|
|
|
@ -97,12 +97,12 @@ describe "Module#undef_method" do
|
|||
@frozen = @module.dup.freeze
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed a name" do
|
||||
-> { @frozen.send :undef_method, :method_to_undef }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when passed a name" do
|
||||
-> { @frozen.send :undef_method, :method_to_undef }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed a missing name" do
|
||||
-> { @frozen.send :undef_method, :not_exist }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when passed a missing name" do
|
||||
-> { @frozen.send :undef_method, :not_exist }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed a not name" do
|
||||
|
|
|
@ -196,10 +196,10 @@ describe "String#capitalize!" do
|
|||
"H".capitalize!.should == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
["", "Hello", "hello"].each do |a|
|
||||
a.freeze
|
||||
-> { a.capitalize! }.should raise_error(frozen_error_class)
|
||||
-> { a.capitalize! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -336,19 +336,19 @@ describe "String#chomp!" do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance when it is modified" do
|
||||
it "raises a FrozenError on a frozen instance when it is modified" do
|
||||
a = "string\n\r"
|
||||
a.freeze
|
||||
|
||||
-> { a.chomp! }.should raise_error(frozen_error_class)
|
||||
-> { a.chomp! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen instance when it would not be modified" do
|
||||
it "raises a FrozenError on a frozen instance when it would not be modified" do
|
||||
a = "string\n\r"
|
||||
a.freeze
|
||||
-> { a.chomp!(nil) }.should raise_error(frozen_error_class)
|
||||
-> { a.chomp!("x") }.should raise_error(frozen_error_class)
|
||||
-> { a.chomp!(nil) }.should raise_error(FrozenError)
|
||||
-> { a.chomp!("x") }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -113,14 +113,14 @@ describe "String#chop!" do
|
|||
"".chop!.should be_nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
-> { "string\n\r".freeze.chop! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> { "string\n\r".freeze.chop! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
a = ""
|
||||
a.freeze
|
||||
-> { a.chop! }.should raise_error(frozen_error_class)
|
||||
-> { a.chop! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,9 +29,9 @@ describe "String#clear" do
|
|||
s.should == ""
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
@s.freeze
|
||||
-> { @s.clear }.should raise_error(frozen_error_class)
|
||||
-> { "".freeze.clear }.should raise_error(frozen_error_class)
|
||||
-> { @s.clear }.should raise_error(FrozenError)
|
||||
-> { "".freeze.clear }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,10 +74,10 @@ ruby_version_is '2.5' do
|
|||
'hello'.delete_prefix!(o).should == 'o'
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
-> { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(frozen_error_class)
|
||||
-> { 'hello'.freeze.delete_prefix!('') }.should raise_error(frozen_error_class)
|
||||
-> { ''.freeze.delete_prefix!('') }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
-> { 'hello'.freeze.delete_prefix!('hell') }.should raise_error(FrozenError)
|
||||
-> { 'hello'.freeze.delete_prefix!('') }.should raise_error(FrozenError)
|
||||
-> { ''.freeze.delete_prefix!('') }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -111,11 +111,11 @@ describe "String#delete!" do
|
|||
a.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
a = "hello"
|
||||
a.freeze
|
||||
|
||||
-> { a.delete!("") }.should raise_error(frozen_error_class)
|
||||
-> { a.delete!("aeiou", "^e") }.should raise_error(frozen_error_class)
|
||||
-> { a.delete!("") }.should raise_error(FrozenError)
|
||||
-> { a.delete!("aeiou", "^e") }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,10 +74,10 @@ ruby_version_is '2.5' do
|
|||
'hello'.delete_suffix!(o).should == 'h'
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
-> { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(frozen_error_class)
|
||||
-> { 'hello'.freeze.delete_suffix!('') }.should raise_error(frozen_error_class)
|
||||
-> { ''.freeze.delete_suffix!('') }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
-> { 'hello'.freeze.delete_suffix!('ello') }.should raise_error(FrozenError)
|
||||
-> { 'hello'.freeze.delete_suffix!('') }.should raise_error(FrozenError)
|
||||
-> { ''.freeze.delete_suffix!('') }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -183,9 +183,9 @@ describe "String#downcase!" do
|
|||
a.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
-> { "HeLlo".freeze.downcase! }.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.downcase! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
-> { "HeLlo".freeze.downcase! }.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.downcase! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "sets the result String encoding to the source String encoding" do
|
||||
|
|
|
@ -52,11 +52,11 @@ describe "String#[]= with Fixnum index" do
|
|||
str.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
a = "hello"
|
||||
a.freeze
|
||||
|
||||
-> { a[0] = "bam" }.should raise_error(frozen_error_class)
|
||||
-> { a[0] = "bam" }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "calls to_int on index" do
|
||||
|
|
|
@ -112,13 +112,13 @@ describe "String#encode!" do
|
|||
|
||||
it_behaves_like :string_encode, :encode!
|
||||
|
||||
it "raises a #{frozen_error_class} when called on a frozen String" do
|
||||
-> { "foo".freeze.encode!("euc-jp") }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when called on a frozen String" do
|
||||
-> { "foo".freeze.encode!("euc-jp") }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# http://redmine.ruby-lang.org/issues/show/1836
|
||||
it "raises a #{frozen_error_class} when called on a frozen String when it's a no-op" do
|
||||
-> { "foo".freeze.encode!("utf-8") }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when called on a frozen String when it's a no-op" do
|
||||
-> { "foo".freeze.encode!("utf-8") }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
describe "when passed no options" do
|
||||
|
|
|
@ -64,8 +64,8 @@ describe "String#force_encoding" do
|
|||
str.dup.force_encoding('utf-16le').should_not == str.encode('utf-16le')
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
str = "abcd".freeze
|
||||
-> { str.force_encoding(str.encoding) }.should raise_error(frozen_error_class)
|
||||
-> { str.force_encoding(str.encoding) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -613,13 +613,13 @@ describe "String#gsub! with pattern and replacement" do
|
|||
end
|
||||
|
||||
# See [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
s = "hello"
|
||||
s.freeze
|
||||
|
||||
-> { s.gsub!(/ROAR/, "x") }.should raise_error(frozen_error_class)
|
||||
-> { s.gsub!(/e/, "e") }.should raise_error(frozen_error_class)
|
||||
-> { s.gsub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class)
|
||||
-> { s.gsub!(/ROAR/, "x") }.should raise_error(FrozenError)
|
||||
-> { s.gsub!(/e/, "e") }.should raise_error(FrozenError)
|
||||
-> { s.gsub!(/[aeiou]/, '*') }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -652,13 +652,13 @@ describe "String#gsub! with pattern and block" do
|
|||
end
|
||||
|
||||
# See [ruby-core:23663]
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
s = "hello"
|
||||
s.freeze
|
||||
|
||||
-> { s.gsub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class)
|
||||
-> { s.gsub!(/e/) { "e" } }.should raise_error(frozen_error_class)
|
||||
-> { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class)
|
||||
-> { s.gsub!(/ROAR/) { "x" } }.should raise_error(FrozenError)
|
||||
-> { s.gsub!(/e/) { "e" } }.should raise_error(FrozenError)
|
||||
-> { s.gsub!(/[aeiou]/) { '*' } }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "uses the compatible encoding if they are compatible" do
|
||||
|
|
|
@ -59,10 +59,10 @@ describe "String#insert with index, other" do
|
|||
-> { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
str = "abcd".freeze
|
||||
-> { str.insert(4, '') }.should raise_error(frozen_error_class)
|
||||
-> { str.insert(4, 'X') }.should raise_error(frozen_error_class)
|
||||
-> { str.insert(4, '') }.should raise_error(FrozenError)
|
||||
-> { str.insert(4, 'X') }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "inserts a character into a multibyte encoded string" do
|
||||
|
|
|
@ -40,13 +40,13 @@ describe "String#lstrip!" do
|
|||
a.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
-> { " hello ".freeze.lstrip! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> { " hello ".freeze.lstrip! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23657]
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
-> { "hello".freeze.lstrip! }.should raise_error(frozen_error_class)
|
||||
-> { "".freeze.lstrip! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
-> { "hello".freeze.lstrip! }.should raise_error(FrozenError)
|
||||
-> { "".freeze.lstrip! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,12 +20,12 @@ describe "String#prepend" do
|
|||
-> { 'hello '.prepend mock('x') }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
a = "hello"
|
||||
a.freeze
|
||||
|
||||
-> { a.prepend "" }.should raise_error(frozen_error_class)
|
||||
-> { a.prepend "test" }.should raise_error(frozen_error_class)
|
||||
-> { a.prepend "" }.should raise_error(FrozenError)
|
||||
-> { a.prepend "test" }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "works when given a subclass instance" do
|
||||
|
|
|
@ -32,14 +32,14 @@ describe "String#reverse!" do
|
|||
"".reverse!.should == ""
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
-> { "anna".freeze.reverse! }.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.reverse! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> { "anna".freeze.reverse! }.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.reverse! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
-> { "".freeze.reverse! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
-> { "".freeze.reverse! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "reverses a string with multi byte characters" do
|
||||
|
|
|
@ -42,13 +42,13 @@ describe "String#rstrip!" do
|
|||
a.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
-> { " hello ".freeze.rstrip! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> { " hello ".freeze.rstrip! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
-> { "hello".freeze.rstrip! }.should raise_error(frozen_error_class)
|
||||
-> { "".freeze.rstrip! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
-> { "hello".freeze.rstrip! }.should raise_error(FrozenError)
|
||||
-> { "".freeze.rstrip! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,10 +75,10 @@ describe "String#setbyte" do
|
|||
str1.should_not == "ledgehog"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
str = "cold".freeze
|
||||
str.frozen?.should be_true
|
||||
-> { str.setbyte(3,96) }.should raise_error(frozen_error_class)
|
||||
-> { str.setbyte(3,96) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a TypeError unless the second argument is an Integer" do
|
||||
|
|
|
@ -17,12 +17,12 @@ describe :string_concat, shared: true do
|
|||
-> { 'hello '.send(@method, mock('x')) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
a = "hello"
|
||||
a.freeze
|
||||
|
||||
-> { a.send(@method, "") }.should raise_error(frozen_error_class)
|
||||
-> { a.send(@method, "test") }.should raise_error(frozen_error_class)
|
||||
-> { a.send(@method, "") }.should raise_error(FrozenError)
|
||||
-> { a.send(@method, "test") }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "returns a String when given a subclass instance" do
|
||||
|
@ -89,12 +89,12 @@ describe :string_concat, shared: true do
|
|||
-> { "".send(@method, x) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
a = "hello"
|
||||
a.freeze
|
||||
|
||||
-> { a.send(@method, 0) }.should raise_error(frozen_error_class)
|
||||
-> { a.send(@method, 33) }.should raise_error(frozen_error_class)
|
||||
-> { a.send(@method, 0) }.should raise_error(FrozenError)
|
||||
-> { a.send(@method, 33) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,14 +64,14 @@ describe :string_replace, shared: true do
|
|||
-> { "hello".send(@method, mock('x')) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
a = "hello".freeze
|
||||
-> { a.send(@method, "world") }.should raise_error(frozen_error_class)
|
||||
-> { a.send(@method, "world") }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen instance when self-replacing" do
|
||||
it "raises a FrozenError on a frozen instance when self-replacing" do
|
||||
a = "hello".freeze
|
||||
-> { a.send(@method, a) }.should raise_error(frozen_error_class)
|
||||
-> { a.send(@method, a) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,8 +83,8 @@ describe :string_succ_bang, shared: true do
|
|||
end
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
-> { "".freeze.send(@method) }.should raise_error(frozen_error_class)
|
||||
-> { "abcd".freeze.send(@method) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
-> { "".freeze.send(@method) }.should raise_error(FrozenError)
|
||||
-> { "abcd".freeze.send(@method) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,10 +53,10 @@ describe "String#slice! with index" do
|
|||
a.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
-> { "hello".freeze.slice!(1) }.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.slice!(10) }.should raise_error(frozen_error_class)
|
||||
-> { "".freeze.slice!(0) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
-> { "hello".freeze.slice!(1) }.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.slice!(10) }.should raise_error(FrozenError)
|
||||
-> { "".freeze.slice!(0) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "calls to_int on index" do
|
||||
|
@ -119,14 +119,14 @@ describe "String#slice! with index, length" do
|
|||
a.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
-> { "hello".freeze.slice!(1, 2) }.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.slice!(10, 3) }.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.slice!(-10, 3)}.should raise_error(frozen_error_class)
|
||||
-> { "hello".freeze.slice!(4, -3) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
-> { "hello".freeze.slice!(1, 2) }.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.slice!(10, 3) }.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.slice!(-10, 3)}.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.slice!(4, -3) }.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.slice!(10, 3) }.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.slice!(-10, 3)}.should raise_error(FrozenError)
|
||||
-> { "hello".freeze.slice!(4, -3) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "calls to_int on idx and length" do
|
||||
|
@ -248,13 +248,13 @@ describe "String#slice! Range" do
|
|||
end
|
||||
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
-> { "hello".freeze.slice!(1..3) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> { "hello".freeze.slice!(1..3) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see redmine #1551
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
-> { "hello".freeze.slice!(10..20)}.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
-> { "hello".freeze.slice!(10..20)}.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -318,12 +318,12 @@ describe "String#slice! with Regexp" do
|
|||
$~.should == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
-> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
-> { "this is a string".freeze.slice!(/zzz/) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
-> { "this is a string".freeze.slice!(/zzz/) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -410,10 +410,10 @@ describe "String#slice! with Regexp, index" do
|
|||
$~.should == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
-> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(frozen_error_class)
|
||||
-> { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(frozen_error_class)
|
||||
-> { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
-> { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(FrozenError)
|
||||
-> { "this is a string".freeze.slice!(/zzz/, 0)}.should raise_error(FrozenError)
|
||||
-> { "this is a string".freeze.slice!(/(.)/, 2)}.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -468,9 +468,9 @@ describe "String#slice! with String" do
|
|||
r.should be_an_instance_of(StringSpecs::MyString)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
-> { "hello hello".freeze.slice!('llo') }.should raise_error(frozen_error_class)
|
||||
-> { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class)
|
||||
-> { "this is a string".freeze.slice!('zzz')}.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
-> { "hello hello".freeze.slice!('llo') }.should raise_error(FrozenError)
|
||||
-> { "this is a string".freeze.slice!('zzz')}.should raise_error(FrozenError)
|
||||
-> { "this is a string".freeze.slice!('zzz')}.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -105,11 +105,11 @@ describe "String#squeeze!" do
|
|||
-> { s.squeeze!("^e-b") }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
a = "yellow moon"
|
||||
a.freeze
|
||||
|
||||
-> { a.squeeze!("") }.should raise_error(frozen_error_class)
|
||||
-> { a.squeeze! }.should raise_error(frozen_error_class)
|
||||
-> { a.squeeze!("") }.should raise_error(FrozenError)
|
||||
-> { a.squeeze! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,13 +50,13 @@ describe "String#strip!" do
|
|||
a.should == "\x00 goodbye"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen instance that is modified" do
|
||||
-> { " hello ".freeze.strip! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that is modified" do
|
||||
-> { " hello ".freeze.strip! }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
# see #1552
|
||||
it "raises a #{frozen_error_class} on a frozen instance that would not be modified" do
|
||||
-> {"hello".freeze.strip! }.should raise_error(frozen_error_class)
|
||||
-> {"".freeze.strip! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError on a frozen instance that would not be modified" do
|
||||
-> {"hello".freeze.strip! }.should raise_error(FrozenError)
|
||||
-> {"".freeze.strip! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -332,13 +332,13 @@ describe "String#sub! with pattern, replacement" do
|
|||
a.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
s = "hello"
|
||||
s.freeze
|
||||
|
||||
-> { s.sub!(/ROAR/, "x") }.should raise_error(frozen_error_class)
|
||||
-> { s.sub!(/e/, "e") }.should raise_error(frozen_error_class)
|
||||
-> { s.sub!(/[aeiou]/, '*') }.should raise_error(frozen_error_class)
|
||||
-> { s.sub!(/ROAR/, "x") }.should raise_error(FrozenError)
|
||||
-> { s.sub!(/e/, "e") }.should raise_error(FrozenError)
|
||||
-> { s.sub!(/[aeiou]/, '*') }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -387,13 +387,13 @@ describe "String#sub! with pattern and block" do
|
|||
-> { str.sub!(//) { str << 'x' } }.should raise_error(RuntimeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
s = "hello"
|
||||
s.freeze
|
||||
|
||||
-> { s.sub!(/ROAR/) { "x" } }.should raise_error(frozen_error_class)
|
||||
-> { s.sub!(/e/) { "e" } }.should raise_error(frozen_error_class)
|
||||
-> { s.sub!(/[aeiou]/) { '*' } }.should raise_error(frozen_error_class)
|
||||
-> { s.sub!(/ROAR/) { "x" } }.should raise_error(FrozenError)
|
||||
-> { s.sub!(/e/) { "e" } }.should raise_error(FrozenError)
|
||||
-> { s.sub!(/[aeiou]/) { '*' } }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -182,10 +182,10 @@ describe "String#swapcase!" do
|
|||
"".swapcase!.should == nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
["", "hello"].each do |a|
|
||||
a.freeze
|
||||
-> { a.swapcase! }.should raise_error(frozen_error_class)
|
||||
-> { a.swapcase! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -127,10 +127,10 @@ describe "String#tr_s!" do
|
|||
s.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
s = "hello".freeze
|
||||
-> { s.tr_s!("el", "ar") }.should raise_error(frozen_error_class)
|
||||
-> { s.tr_s!("l", "r") }.should raise_error(frozen_error_class)
|
||||
-> { s.tr_s!("", "") }.should raise_error(frozen_error_class)
|
||||
-> { s.tr_s!("el", "ar") }.should raise_error(FrozenError)
|
||||
-> { s.tr_s!("l", "r") }.should raise_error(FrozenError)
|
||||
-> { s.tr_s!("", "") }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -122,10 +122,10 @@ describe "String#tr!" do
|
|||
s.should == "hello"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if self is frozen" do
|
||||
it "raises a FrozenError if self is frozen" do
|
||||
s = "abcdefghijklmnopqR".freeze
|
||||
-> { s.tr!("cdefg", "12") }.should raise_error(frozen_error_class)
|
||||
-> { s.tr!("R", "S") }.should raise_error(frozen_error_class)
|
||||
-> { s.tr!("", "") }.should raise_error(frozen_error_class)
|
||||
-> { s.tr!("cdefg", "12") }.should raise_error(FrozenError)
|
||||
-> { s.tr!("R", "S") }.should raise_error(FrozenError)
|
||||
-> { s.tr!("", "") }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -179,8 +179,8 @@ describe "String#upcase!" do
|
|||
a.should == "HELLO"
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when self is frozen" do
|
||||
-> { "HeLlo".freeze.upcase! }.should raise_error(frozen_error_class)
|
||||
-> { "HELLO".freeze.upcase! }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when self is frozen" do
|
||||
-> { "HeLlo".freeze.upcase! }.should raise_error(FrozenError)
|
||||
-> { "HELLO".freeze.upcase! }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,13 +6,13 @@ describe "Thread#[]=" do
|
|||
Thread.current[:value] = nil
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if the thread is frozen" do
|
||||
it "raises a FrozenError if the thread is frozen" do
|
||||
Thread.new do
|
||||
th = Thread.current
|
||||
th.freeze
|
||||
-> {
|
||||
th[:foo] = "bar"
|
||||
}.should raise_error(frozen_error_class, /frozen/)
|
||||
}.should raise_error(FrozenError, /frozen/)
|
||||
end.join
|
||||
end
|
||||
|
||||
|
|
|
@ -261,10 +261,10 @@ describe "A singleton method definition" do
|
|||
(obj==2).should == 2
|
||||
end
|
||||
|
||||
it "raises #{frozen_error_class} if frozen" do
|
||||
it "raises FrozenError if frozen" do
|
||||
obj = Object.new
|
||||
obj.freeze
|
||||
-> { def obj.foo; end }.should raise_error(frozen_error_class)
|
||||
-> { def obj.foo; end }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -412,12 +412,12 @@ describe "A method definition inside a metaclass scope" do
|
|||
-> { Object.new.a_singleton_method }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "raises #{frozen_error_class} if frozen" do
|
||||
it "raises FrozenError if frozen" do
|
||||
obj = Object.new
|
||||
obj.freeze
|
||||
|
||||
class << obj
|
||||
-> { def foo; end }.should raise_error(frozen_error_class)
|
||||
-> { def foo; end }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,11 +36,11 @@ describe "Date constants" do
|
|||
[Date::MONTHNAMES, Date::DAYNAMES, Date::ABBR_MONTHNAMES, Date::ABBR_DAYNAMES].each do |ary|
|
||||
-> {
|
||||
ary << "Unknown"
|
||||
}.should raise_error(frozen_error_class, /frozen/)
|
||||
}.should raise_error(FrozenError, /frozen/)
|
||||
ary.compact.each do |name|
|
||||
-> {
|
||||
name << "modified"
|
||||
}.should raise_error(frozen_error_class, /frozen/)
|
||||
}.should raise_error(FrozenError, /frozen/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,11 +91,11 @@ describe "Set#compare_by_identity" do
|
|||
set.to_a.sort.should == [a1, a2].sort
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on frozen sets" do
|
||||
it "raises a FrozenError on frozen sets" do
|
||||
set = Set.new.freeze
|
||||
-> {
|
||||
set.compare_by_identity
|
||||
}.should raise_error(frozen_error_class, /frozen Hash/)
|
||||
}.should raise_error(FrozenError, /frozen Hash/)
|
||||
end
|
||||
|
||||
it "persists over #dups" do
|
||||
|
|
|
@ -110,9 +110,9 @@ describe "StringIO#initialize when passed [Object, mode]" do
|
|||
io.closed_write?.should be_false
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed a frozen String in truncate mode as StringIO backend" do
|
||||
it "raises a FrozenError when passed a frozen String in truncate mode as StringIO backend" do
|
||||
io = StringIO.allocate
|
||||
-> { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(frozen_error_class)
|
||||
-> { io.send(:initialize, "example".freeze, IO::TRUNC) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "tries to convert the passed mode to a String using #to_str" do
|
||||
|
|
|
@ -134,8 +134,8 @@ describe "StringIO.open when passed [Object, mode]" do
|
|||
io.closed_write?.should be_false
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when passed a frozen String in truncate mode as StringIO backend" do
|
||||
-> { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when passed a frozen String in truncate mode as StringIO backend" do
|
||||
-> { StringIO.open("example".freeze, IO::TRUNC) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "tries to convert the passed mode to a String using #to_str" do
|
||||
|
|
|
@ -50,8 +50,8 @@ describe "StringIO#reopen when passed [Object, Integer]" do
|
|||
-> { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should raise_error(Errno::EACCES)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when trying to reopen self with a frozen String in truncate-mode" do
|
||||
-> { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError when trying to reopen self with a frozen String in truncate-mode" do
|
||||
-> { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(FrozenError)
|
||||
end
|
||||
|
||||
it "does not raise IOError when passed a frozen String in read-mode" do
|
||||
|
|
|
@ -27,8 +27,8 @@ describe :stringio_read, shared: true do
|
|||
-> { @io.send(@method, 7, Object.new) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} error when passed a frozen String as buffer" do
|
||||
-> { @io.send(@method, 7, "".freeze) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError error when passed a frozen String as buffer" do
|
||||
-> { @io.send(@method, 7, "".freeze) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -83,8 +83,8 @@ describe "C-API Array function" do
|
|||
@s.rb_ary_cat([1, 2], 3, 4).should == [1, 2, 3, 4]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if the array is frozen" do
|
||||
-> { @s.rb_ary_cat([].freeze, 1) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if the array is frozen" do
|
||||
-> { @s.rb_ary_cat([].freeze, 1) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -130,8 +130,8 @@ describe "C-API Array function" do
|
|||
@s.rb_ary_rotate([1, 2, 3, 4], -3).should == [2, 3, 4, 1]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if the array is frozen" do
|
||||
-> { @s.rb_ary_rotate([].freeze, 1) }.should raise_error(frozen_error_class)
|
||||
it "raises a FrozenError if the array is frozen" do
|
||||
-> { @s.rb_ary_rotate([].freeze, 1) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -214,9 +214,9 @@ describe "C-API Array function" do
|
|||
a.should == [nil, nil, 7]
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} if the array is frozen" do
|
||||
it "raises a FrozenError if the array is frozen" do
|
||||
a = [1, 2, 3].freeze
|
||||
-> { @s.rb_ary_store(a, 1, 5) }.should raise_error(frozen_error_class)
|
||||
-> { @s.rb_ary_store(a, 1, 5) }.should raise_error(FrozenError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче