mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@875a09e
This commit is contained in:
parent
a06301b103
commit
5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions
|
@ -28,7 +28,6 @@ CSAutoloadC
|
|||
CSAutoloadD
|
||||
CSV
|
||||
ChainedNextTest
|
||||
Channel
|
||||
ChildClass
|
||||
ClassIdUnderAutoload
|
||||
ClassSpecDefineClass
|
||||
|
|
|
@ -100,3 +100,18 @@ Lint/UriRegexp:
|
|||
Lint/Debugger:
|
||||
Exclude:
|
||||
- 'core/binding/fixtures/irb.rb'
|
||||
|
||||
Style/Lambda:
|
||||
Enabled: true
|
||||
EnforcedStyle: literal
|
||||
Exclude:
|
||||
- 'language/lambda_spec.rb'
|
||||
- 'language/proc_spec.rb'
|
||||
- 'core/kernel/lambda_spec.rb'
|
||||
|
||||
Style/EmptyLambdaParameter:
|
||||
Enabled: true
|
||||
|
||||
Style/StabbyLambdaParentheses:
|
||||
Enabled: true
|
||||
EnforcedStyle: require_no_parentheses
|
||||
|
|
|
@ -144,6 +144,9 @@ Lint/UselessAccessModifier:
|
|||
- 'core/module/fixtures/classes.rb'
|
||||
- 'core/module/module_function_spec.rb'
|
||||
- 'core/module/private_class_method_spec.rb'
|
||||
- 'core/module/private_spec.rb'
|
||||
- 'core/module/protected_spec.rb'
|
||||
- 'core/module/public_spec.rb'
|
||||
- 'language/fixtures/send.rb'
|
||||
|
||||
# Offense count: 6186
|
||||
|
|
|
@ -22,8 +22,8 @@ describe "ARGF.close" do
|
|||
|
||||
it "doesn't raise an IOError if called on a closed stream" do
|
||||
argf [@file1_name] do
|
||||
lambda { @argf.close }.should_not raise_error
|
||||
lambda { @argf.close }.should_not raise_error
|
||||
-> { @argf.close }.should_not raise_error
|
||||
-> { @argf.close }.should_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ platform_is_not :windows do
|
|||
|
||||
it 'raises IO::EAGAINWaitReadable when empty' do
|
||||
argf ['-'] do
|
||||
lambda {
|
||||
-> {
|
||||
@argf.read_nonblock(4)
|
||||
}.should raise_error(IO::EAGAINWaitReadable)
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ describe "ARGF.readchar" do
|
|||
|
||||
it "raises EOFError when end of stream reached" do
|
||||
argf [@file1, @file2] do
|
||||
lambda { while @argf.readchar; end }.should raise_error(EOFError)
|
||||
-> { while @argf.readchar; end }.should raise_error(EOFError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe "ARGF.readline" do
|
|||
|
||||
it "raises an EOFError when reaching end of files" do
|
||||
argf [@file1, @file2] do
|
||||
lambda { while @argf.readline; end }.should raise_error(EOFError)
|
||||
-> { while @argf.readline; end }.should raise_error(EOFError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ describe "ARGF.readpartial" do
|
|||
|
||||
it "raises an ArgumentError if called without a maximum read length" do
|
||||
argf [@file1_name] do
|
||||
lambda { @argf.readpartial }.should raise_error(ArgumentError)
|
||||
-> { @argf.readpartial }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,8 +59,8 @@ describe "ARGF.readpartial" do
|
|||
@argf.readpartial(@file1.size)
|
||||
@argf.readpartial(1)
|
||||
@argf.readpartial(@file2.size)
|
||||
lambda { @argf.readpartial(1) }.should raise_error(EOFError)
|
||||
lambda { @argf.readpartial(1) }.should raise_error(EOFError)
|
||||
-> { @argf.readpartial(1) }.should raise_error(EOFError)
|
||||
-> { @argf.readpartial(1) }.should raise_error(EOFError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ describe "ARGF.rewind" do
|
|||
it "raises an ArgumentError when end of stream reached" do
|
||||
argf [@file1_name, @file2_name] do
|
||||
@argf.read
|
||||
lambda { @argf.rewind }.should raise_error(ArgumentError)
|
||||
-> { @argf.rewind }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,7 +57,7 @@ describe "ARGF.seek" do
|
|||
|
||||
it "takes at least one argument (offset)" do
|
||||
argf [@file1_name] do
|
||||
lambda { @argf.seek }.should raise_error(ArgumentError)
|
||||
-> { @argf.seek }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ describe :argf_eof, shared: true do
|
|||
it "raises IOError when called on a closed stream" do
|
||||
argf [@file1] do
|
||||
@argf.read
|
||||
lambda { @argf.send(@method) }.should raise_error(IOError)
|
||||
-> { @argf.send(@method) }.should raise_error(IOError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ describe :argf_fileno, shared: true do
|
|||
it "raises an ArgumentError when called on a closed stream" do
|
||||
argf [@file1] do
|
||||
@argf.read
|
||||
lambda { @argf.send(@method) }.should raise_error(ArgumentError)
|
||||
-> { @argf.send(@method) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ describe :argf_pos, shared: true do
|
|||
it "raises an ArgumentError when called on a closed stream" do
|
||||
argf [@file1] do
|
||||
@argf.read
|
||||
lambda { @argf.send(@method) }.should raise_error(ArgumentError)
|
||||
-> { @argf.send(@method) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,6 +37,6 @@ describe "ARGF.skip" do
|
|||
# which as a side-effect calls argf.file which will initialize
|
||||
# internals of ARGF enough for this to work.
|
||||
it "has no effect when nothing has been processed yet" do
|
||||
lambda { ARGF.class.new(@file1_name).skip }.should_not raise_error
|
||||
-> { ARGF.class.new(@file1_name).skip }.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,6 @@ describe "Array.allocate" do
|
|||
end
|
||||
|
||||
it "does not accept any arguments" do
|
||||
lambda { Array.allocate(1) }.should raise_error(ArgumentError)
|
||||
-> { Array.allocate(1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ describe "Array#<<" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array << 5 }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array << 5 }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -47,10 +47,10 @@ describe "Array#at" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when the passed argument can't be coerced to Integer" do
|
||||
lambda { [].at("cat") }.should raise_error(TypeError)
|
||||
-> { [].at("cat") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when 2 or more arguments are passed" do
|
||||
lambda { [:a, :b].at(0,1) }.should raise_error(ArgumentError)
|
||||
-> { [:a, :b].at(0,1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ describe "Array#bsearch_index" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when block returns a String" do
|
||||
lambda { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError)
|
||||
-> { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "returns nil when block is empty" do
|
||||
|
|
|
@ -9,11 +9,11 @@ describe "Array#bsearch" do
|
|||
it_behaves_like :enumeratorized_with_unknown_size, :bsearch, [1,2,3]
|
||||
|
||||
it "raises a TypeError if the block returns an Object" do
|
||||
lambda { [1].bsearch { Object.new } }.should raise_error(TypeError)
|
||||
-> { [1].bsearch { Object.new } }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if the block returns a String" do
|
||||
lambda { [1].bsearch { "1" } }.should raise_error(TypeError)
|
||||
-> { [1].bsearch { "1" } }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
context "with a block returning true or false" do
|
||||
|
|
|
@ -29,7 +29,7 @@ describe "Array#clear" do
|
|||
end
|
||||
|
||||
it "does not accept any arguments" do
|
||||
lambda { [1].clear(true) }.should raise_error(ArgumentError)
|
||||
-> { [1].clear(true) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "keeps untrusted status" do
|
||||
|
@ -43,6 +43,6 @@ describe "Array#clear" do
|
|||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
a = [1]
|
||||
a.freeze
|
||||
lambda { a.clear }.should raise_error(frozen_error_class)
|
||||
-> { a.clear }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,6 +72,6 @@ describe "Array#compact!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.compact! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.compact! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,12 +33,12 @@ describe "Array#concat" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when Array is frozen and modification occurs" do
|
||||
lambda { ArraySpecs.frozen_array.concat [1] }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.concat [1] }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} when Array is frozen and no modification occurs" do
|
||||
lambda { ArraySpecs.frozen_array.concat([]) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.concat([]) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "keeps tainted status" do
|
||||
|
|
|
@ -6,7 +6,7 @@ describe "Array#cycle" do
|
|||
ScratchPad.record []
|
||||
|
||||
@array = [1, 2, 3]
|
||||
@prc = lambda { |x| ScratchPad << x }
|
||||
@prc = -> x { ScratchPad << x }
|
||||
end
|
||||
|
||||
it "does not yield and returns nil when the array is empty and passed value is an integer" do
|
||||
|
@ -46,13 +46,13 @@ describe "Array#cycle" do
|
|||
end
|
||||
|
||||
it "does not rescue StopIteration when not passed a count" do
|
||||
lambda do
|
||||
-> do
|
||||
@array.cycle { raise StopIteration }
|
||||
end.should raise_error(StopIteration)
|
||||
end
|
||||
|
||||
it "does not rescue StopIteration when passed a count" do
|
||||
lambda do
|
||||
-> do
|
||||
@array.cycle(3) { raise StopIteration }
|
||||
end.should raise_error(StopIteration)
|
||||
end
|
||||
|
@ -74,23 +74,23 @@ describe "Array#cycle" do
|
|||
count = mock("cycle count 2")
|
||||
count.should_receive(:to_int).and_return("2")
|
||||
|
||||
lambda { @array.cycle(count, &@prc) }.should raise_error(TypeError)
|
||||
-> { @array.cycle(count, &@prc) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed a String" do
|
||||
lambda { @array.cycle("4") { } }.should raise_error(TypeError)
|
||||
-> { @array.cycle("4") { } }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed an Object" do
|
||||
lambda { @array.cycle(mock("cycle count")) { } }.should raise_error(TypeError)
|
||||
-> { @array.cycle(mock("cycle count")) { } }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed true" do
|
||||
lambda { @array.cycle(true) { } }.should raise_error(TypeError)
|
||||
-> { @array.cycle(true) { } }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed false" do
|
||||
lambda { @array.cycle(false) { } }.should raise_error(TypeError)
|
||||
-> { @array.cycle(false) { } }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
before :all do
|
||||
|
|
|
@ -36,7 +36,7 @@ describe "Array#delete_at" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { [1,2,3].freeze.delete_at(0) }.should raise_error(frozen_error_class)
|
||||
-> { [1,2,3].freeze.delete_at(0) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "keeps tainted status" do
|
||||
|
|
|
@ -40,11 +40,11 @@ describe "Array#delete_if" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.delete_if {} }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.delete_if {} }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
lambda { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.delete_if {} }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "keeps tainted status" do
|
||||
|
|
|
@ -41,7 +41,7 @@ describe "Array#delete" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { [1, 2, 3].freeze.delete(1) }.should raise_error(frozen_error_class)
|
||||
-> { [1, 2, 3].freeze.delete(1) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "keeps tainted status" do
|
||||
|
|
|
@ -20,20 +20,20 @@ describe "Array#dig" do
|
|||
end
|
||||
|
||||
it "raises a TypeError for a non-numeric index" do
|
||||
lambda {
|
||||
-> {
|
||||
['a'].dig(:first)
|
||||
}.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if any intermediate step does not respond to #dig" do
|
||||
a = [1, 2]
|
||||
lambda {
|
||||
-> {
|
||||
a.dig(0, 1)
|
||||
}.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if no arguments provided" do
|
||||
lambda {
|
||||
-> {
|
||||
[10].dig()
|
||||
}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ describe "Array#drop" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if the number of elements specified is negative" do
|
||||
lambda { [1, 2].drop(-3) }.should raise_error(ArgumentError)
|
||||
-> { [1, 2].drop(-3) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "returns an empty Array if all elements are dropped" do
|
||||
|
|
|
@ -94,8 +94,8 @@ describe "Array#[]=" do
|
|||
|
||||
it "checks frozen before attempting to coerce arguments" do
|
||||
a = [1,2,3,4].freeze
|
||||
lambda {a[:foo] = 1}.should raise_error(frozen_error_class)
|
||||
lambda {a[:foo, :bar] = 1}.should raise_error(frozen_error_class)
|
||||
-> {a[:foo] = 1}.should raise_error(frozen_error_class)
|
||||
-> {a[:foo, :bar] = 1}.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "sets elements in the range arguments when passed ranges" do
|
||||
|
@ -195,25 +195,25 @@ describe "Array#[]=" do
|
|||
|
||||
a[to .. from] = ["x"]
|
||||
a.should == [1, "a", "b", "x", "c", 4]
|
||||
lambda { a["a" .. "b"] = [] }.should raise_error(TypeError)
|
||||
lambda { a[from .. "b"] = [] }.should raise_error(TypeError)
|
||||
-> { a["a" .. "b"] = [] }.should raise_error(TypeError)
|
||||
-> { a[from .. "b"] = [] }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises an IndexError when passed indexes out of bounds" do
|
||||
a = [1, 2, 3, 4]
|
||||
lambda { a[-5] = "" }.should raise_error(IndexError)
|
||||
lambda { a[-5, -1] = "" }.should raise_error(IndexError)
|
||||
lambda { a[-5, 0] = "" }.should raise_error(IndexError)
|
||||
lambda { a[-5, 1] = "" }.should raise_error(IndexError)
|
||||
lambda { a[-5, 2] = "" }.should raise_error(IndexError)
|
||||
lambda { a[-5, 10] = "" }.should raise_error(IndexError)
|
||||
-> { a[-5] = "" }.should raise_error(IndexError)
|
||||
-> { a[-5, -1] = "" }.should raise_error(IndexError)
|
||||
-> { a[-5, 0] = "" }.should raise_error(IndexError)
|
||||
-> { a[-5, 1] = "" }.should raise_error(IndexError)
|
||||
-> { a[-5, 2] = "" }.should raise_error(IndexError)
|
||||
-> { a[-5, 10] = "" }.should raise_error(IndexError)
|
||||
|
||||
lambda { a[-5..-5] = "" }.should raise_error(RangeError)
|
||||
lambda { a[-5...-5] = "" }.should raise_error(RangeError)
|
||||
lambda { a[-5..-4] = "" }.should raise_error(RangeError)
|
||||
lambda { a[-5...-4] = "" }.should raise_error(RangeError)
|
||||
lambda { a[-5..10] = "" }.should raise_error(RangeError)
|
||||
lambda { a[-5...10] = "" }.should raise_error(RangeError)
|
||||
-> { a[-5..-5] = "" }.should raise_error(RangeError)
|
||||
-> { a[-5...-5] = "" }.should raise_error(RangeError)
|
||||
-> { a[-5..-4] = "" }.should raise_error(RangeError)
|
||||
-> { a[-5...-4] = "" }.should raise_error(RangeError)
|
||||
-> { a[-5..10] = "" }.should raise_error(RangeError)
|
||||
-> { a[-5...10] = "" }.should raise_error(RangeError)
|
||||
|
||||
# ok
|
||||
a[0..-9] = [1]
|
||||
|
@ -237,7 +237,7 @@ describe "Array#[]=" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array[0, 0] = [] }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array[0, 0] = [] }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -337,12 +337,12 @@ describe "Array#[]= with [index, count]" do
|
|||
|
||||
it "raises an IndexError when passed start and negative length" do
|
||||
a = [1, 2, 3, 4]
|
||||
lambda { a[-2, -1] = "" }.should raise_error(IndexError)
|
||||
lambda { a[0, -1] = "" }.should raise_error(IndexError)
|
||||
lambda { a[2, -1] = "" }.should raise_error(IndexError)
|
||||
lambda { a[4, -1] = "" }.should raise_error(IndexError)
|
||||
lambda { a[10, -1] = "" }.should raise_error(IndexError)
|
||||
lambda { [1, 2, 3, 4, 5][2, -1] = [7, 8] }.should raise_error(IndexError)
|
||||
-> { a[-2, -1] = "" }.should raise_error(IndexError)
|
||||
-> { a[0, -1] = "" }.should raise_error(IndexError)
|
||||
-> { a[2, -1] = "" }.should raise_error(IndexError)
|
||||
-> { a[4, -1] = "" }.should raise_error(IndexError)
|
||||
-> { a[10, -1] = "" }.should raise_error(IndexError)
|
||||
-> { [1, 2, 3, 4, 5][2, -1] = [7, 8] }.should raise_error(IndexError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ describe "Array#fetch" do
|
|||
end
|
||||
|
||||
it "raises an IndexError if there is no element at index" do
|
||||
lambda { [1, 2, 3].fetch(3) }.should raise_error(IndexError)
|
||||
lambda { [1, 2, 3].fetch(-4) }.should raise_error(IndexError)
|
||||
lambda { [].fetch(0) }.should raise_error(IndexError)
|
||||
-> { [1, 2, 3].fetch(3) }.should raise_error(IndexError)
|
||||
-> { [1, 2, 3].fetch(-4) }.should raise_error(IndexError)
|
||||
-> { [].fetch(0) }.should raise_error(IndexError)
|
||||
end
|
||||
|
||||
it "returns default if there is no element at index if passed a default value" do
|
||||
|
@ -37,7 +37,7 @@ describe "Array#fetch" do
|
|||
end
|
||||
|
||||
it "gives precedence to the default block over the default argument" do
|
||||
lambda {
|
||||
-> {
|
||||
@result = [1, 2, 3].fetch(9, :foo) { |i| i * i }
|
||||
}.should complain(/block supersedes default value argument/)
|
||||
@result.should == 81
|
||||
|
@ -50,6 +50,6 @@ describe "Array#fetch" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when the passed argument can't be coerced to Integer" do
|
||||
lambda { [].fetch("cat") }.should raise_error(TypeError)
|
||||
-> { [].fetch("cat") }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
|
|||
|
||||
describe "Array#fill" do
|
||||
before :all do
|
||||
@never_passed = lambda do |i|
|
||||
@never_passed = -> i do
|
||||
raise ExpectationNotMetError, "the control path should not pass here"
|
||||
end
|
||||
end
|
||||
|
@ -44,33 +44,33 @@ describe "Array#fill" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.fill('x') }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.fill('x') }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
lambda { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.fill('x') }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if 4 or more arguments are passed when no block given" do
|
||||
lambda { [].fill('a') }.should_not raise_error(ArgumentError)
|
||||
-> { [].fill('a') }.should_not raise_error(ArgumentError)
|
||||
|
||||
lambda { [].fill('a', 1) }.should_not raise_error(ArgumentError)
|
||||
-> { [].fill('a', 1) }.should_not raise_error(ArgumentError)
|
||||
|
||||
lambda { [].fill('a', 1, 2) }.should_not raise_error(ArgumentError)
|
||||
lambda { [].fill('a', 1, 2, true) }.should raise_error(ArgumentError)
|
||||
-> { [].fill('a', 1, 2) }.should_not raise_error(ArgumentError)
|
||||
-> { [].fill('a', 1, 2, true) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if no argument passed and no block given" do
|
||||
lambda { [].fill }.should raise_error(ArgumentError)
|
||||
-> { [].fill }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if 3 or more arguments are passed when a block given" do
|
||||
lambda { [].fill() {|i|} }.should_not raise_error(ArgumentError)
|
||||
-> { [].fill() {|i|} }.should_not raise_error(ArgumentError)
|
||||
|
||||
lambda { [].fill(1) {|i|} }.should_not raise_error(ArgumentError)
|
||||
-> { [].fill(1) {|i|} }.should_not raise_error(ArgumentError)
|
||||
|
||||
lambda { [].fill(1, 2) {|i|} }.should_not raise_error(ArgumentError)
|
||||
lambda { [].fill(1, 2, true) {|i|} }.should raise_error(ArgumentError)
|
||||
-> { [].fill(1, 2) {|i|} }.should_not raise_error(ArgumentError)
|
||||
-> { [].fill(1, 2, true) {|i|} }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -171,23 +171,23 @@ describe "Array#fill with (filler, index, length)" do
|
|||
|
||||
# See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17481
|
||||
it "does not raise an exception if the given length is negative and its absolute value does not exceed the index" do
|
||||
lambda { [1, 2, 3, 4].fill('a', 3, -1)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill('a', 3, -2)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill('a', 3, -3)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill('a', 3, -1)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill('a', 3, -2)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill('a', 3, -3)}.should_not raise_error(ArgumentError)
|
||||
|
||||
lambda { [1, 2, 3, 4].fill(3, -1, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill(3, -2, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill(3, -3, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill(3, -1, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill(3, -2, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill(3, -3, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not raise an exception even if the given length is negative and its absolute value exceeds the index" do
|
||||
lambda { [1, 2, 3, 4].fill('a', 3, -4)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill('a', 3, -5)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill('a', 3, -10000)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill('a', 3, -4)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill('a', 3, -5)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill('a', 3, -10000)}.should_not raise_error(ArgumentError)
|
||||
|
||||
lambda { [1, 2, 3, 4].fill(3, -4, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill(3, -5, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
lambda { [1, 2, 3, 4].fill(3, -10000, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill(3, -4, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill(3, -5, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
-> { [1, 2, 3, 4].fill(3, -10000, &@never_passed)}.should_not raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "tries to convert the second and third arguments to Integers using #to_int" do
|
||||
|
@ -199,17 +199,17 @@ describe "Array#fill with (filler, index, length)" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if the index is not numeric" do
|
||||
lambda { [].fill 'a', true }.should raise_error(TypeError)
|
||||
-> { [].fill 'a', true }.should raise_error(TypeError)
|
||||
|
||||
obj = mock('nonnumeric')
|
||||
lambda { [].fill('a', obj) }.should raise_error(TypeError)
|
||||
-> { [].fill('a', obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
not_supported_on :opal do
|
||||
it "raises an ArgumentError or RangeError for too-large sizes" do
|
||||
arr = [1, 2, 3]
|
||||
lambda { arr.fill(10, 1, fixnum_max) }.should raise_error(ArgumentError)
|
||||
lambda { arr.fill(10, 1, bignum_value) }.should raise_error(RangeError)
|
||||
-> { arr.fill(10, 1, fixnum_max) }.should raise_error(ArgumentError)
|
||||
-> { arr.fill(10, 1, bignum_value) }.should raise_error(RangeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -239,7 +239,7 @@ describe "Array#fill with (filler, range)" do
|
|||
end
|
||||
|
||||
it "raises a TypeError with range and length argument" do
|
||||
lambda { [].fill('x', 0 .. 2, 5) }.should raise_error(TypeError)
|
||||
-> { [].fill('x', 0 .. 2, 5) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "replaces elements between the (-m)th to the last and the (n+1)th from the first if given an range m..n where m < 0 and n >= 0" do
|
||||
|
@ -291,13 +291,13 @@ describe "Array#fill with (filler, range)" do
|
|||
end
|
||||
|
||||
it "raises an exception if some of the given range lies before the first of the array" do
|
||||
lambda { [1, 2, 3].fill('x', -5..-3) }.should raise_error(RangeError)
|
||||
lambda { [1, 2, 3].fill('x', -5...-3) }.should raise_error(RangeError)
|
||||
lambda { [1, 2, 3].fill('x', -5..-4) }.should raise_error(RangeError)
|
||||
-> { [1, 2, 3].fill('x', -5..-3) }.should raise_error(RangeError)
|
||||
-> { [1, 2, 3].fill('x', -5...-3) }.should raise_error(RangeError)
|
||||
-> { [1, 2, 3].fill('x', -5..-4) }.should raise_error(RangeError)
|
||||
|
||||
lambda { [1, 2, 3].fill(-5..-3, &@never_passed) }.should raise_error(RangeError)
|
||||
lambda { [1, 2, 3].fill(-5...-3, &@never_passed) }.should raise_error(RangeError)
|
||||
lambda { [1, 2, 3].fill(-5..-4, &@never_passed) }.should raise_error(RangeError)
|
||||
-> { [1, 2, 3].fill(-5..-3, &@never_passed) }.should raise_error(RangeError)
|
||||
-> { [1, 2, 3].fill(-5...-3, &@never_passed) }.should raise_error(RangeError)
|
||||
-> { [1, 2, 3].fill(-5..-4, &@never_passed) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "tries to convert the start and end of the passed range to Integers using #to_int" do
|
||||
|
@ -312,6 +312,6 @@ describe "Array#fill with (filler, range)" do
|
|||
it "raises a TypeError if the start or end of the passed range is not numeric" do
|
||||
obj = mock('nonnumeric')
|
||||
def obj.<=>(rhs); rhs == self ? 0 : nil end
|
||||
lambda { [].fill('a', obj..obj) }.should raise_error(TypeError)
|
||||
-> { [].fill('a', obj..obj) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,11 +30,11 @@ describe "Array#first" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when count is negative" do
|
||||
lambda { [1, 2].first(-1) }.should raise_error(ArgumentError)
|
||||
-> { [1, 2].first(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a RangeError when count is a Bignum" do
|
||||
lambda { [].first(bignum_value) }.should raise_error(RangeError)
|
||||
-> { [].first(bignum_value) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "returns the entire array when count > length" do
|
||||
|
@ -66,11 +66,11 @@ describe "Array#first" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if the passed argument is not numeric" do
|
||||
lambda { [1,2].first(nil) }.should raise_error(TypeError)
|
||||
lambda { [1,2].first("a") }.should raise_error(TypeError)
|
||||
-> { [1,2].first(nil) }.should raise_error(TypeError)
|
||||
-> { [1,2].first("a") }.should raise_error(TypeError)
|
||||
|
||||
obj = mock("nonnumeric")
|
||||
lambda { [1,2].first(obj) }.should raise_error(TypeError)
|
||||
-> { [1,2].first(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not return subclass instance when passed count on Array subclasses" do
|
||||
|
|
|
@ -30,7 +30,7 @@ describe "Array#flatten" do
|
|||
|
||||
it "raises a TypeError when the passed Object can't be converted to an Integer" do
|
||||
obj = mock("Not converted")
|
||||
lambda { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should raise_error(TypeError)
|
||||
-> { [ 1, 2, [3, [4, 5] ] ].flatten(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not call flatten on elements" do
|
||||
|
@ -46,13 +46,13 @@ describe "Array#flatten" do
|
|||
it "raises an ArgumentError on recursive arrays" do
|
||||
x = []
|
||||
x << x
|
||||
lambda { x.flatten }.should raise_error(ArgumentError)
|
||||
-> { x.flatten }.should raise_error(ArgumentError)
|
||||
|
||||
x = []
|
||||
y = []
|
||||
x << y
|
||||
y << x
|
||||
lambda { x.flatten }.should raise_error(ArgumentError)
|
||||
-> { x.flatten }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "flattens any element which responds to #to_ary, using the return value of said method" do
|
||||
|
@ -106,7 +106,7 @@ describe "Array#flatten" do
|
|||
|
||||
it "raises a TypeError if #to_ary does not return an Array" do
|
||||
@obj.should_receive(:to_ary).and_return(1)
|
||||
lambda { [@obj].flatten }.should raise_error(TypeError)
|
||||
-> { [@obj].flatten }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
ruby_version_is ""..."2.5" do
|
||||
|
@ -135,7 +135,7 @@ describe "Array#flatten" do
|
|||
it "calls #to_ary if not defined when #respond_to_missing? returns true" do
|
||||
def @obj.respond_to_missing?(name, priv) ScratchPad << name; true end
|
||||
|
||||
lambda { [@obj].flatten }.should raise_error(NoMethodError)
|
||||
-> { [@obj].flatten }.should raise_error(NoMethodError)
|
||||
ScratchPad.recorded.should == [:to_ary]
|
||||
end
|
||||
|
||||
|
@ -226,7 +226,7 @@ describe "Array#flatten!" do
|
|||
|
||||
it "raises a TypeError when the passed Object can't be converted to an Integer" do
|
||||
obj = mock("Not converted")
|
||||
lambda { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should raise_error(TypeError)
|
||||
-> { [ 1, 2, [3, [4, 5] ] ].flatten!(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not call flatten! on elements" do
|
||||
|
@ -242,13 +242,13 @@ describe "Array#flatten!" do
|
|||
it "raises an ArgumentError on recursive arrays" do
|
||||
x = []
|
||||
x << x
|
||||
lambda { x.flatten! }.should raise_error(ArgumentError)
|
||||
-> { x.flatten! }.should raise_error(ArgumentError)
|
||||
|
||||
x = []
|
||||
y = []
|
||||
x << y
|
||||
y << x
|
||||
lambda { x.flatten! }.should raise_error(ArgumentError)
|
||||
-> { x.flatten! }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "flattens any elements which responds to #to_ary, using the return value of said method" do
|
||||
|
@ -273,12 +273,12 @@ describe "Array#flatten!" do
|
|||
it "raises a #{frozen_error_class} on frozen arrays when the array is modified" do
|
||||
nested_ary = [1, 2, []]
|
||||
nested_ary.freeze
|
||||
lambda { nested_ary.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { nested_ary.flatten! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
# see [ruby-core:23663]
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array would not be modified" do
|
||||
lambda { ArraySpecs.frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
lambda { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.flatten! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,10 +13,10 @@ describe "Array#hash" do
|
|||
|
||||
it "properly handles recursive arrays" do
|
||||
empty = ArraySpecs.empty_recursive_array
|
||||
lambda { empty.hash }.should_not raise_error
|
||||
-> { empty.hash }.should_not raise_error
|
||||
|
||||
array = ArraySpecs.recursive_array
|
||||
lambda { array.hash }.should_not raise_error
|
||||
-> { array.hash }.should_not raise_error
|
||||
end
|
||||
|
||||
it "returns the same hash for equal recursive arrays" do
|
||||
|
|
|
@ -24,19 +24,19 @@ describe "Array#initialize" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if passed 3 or more arguments" do
|
||||
lambda do
|
||||
-> do
|
||||
[1, 2].send :initialize, 1, 'x', true
|
||||
end.should raise_error(ArgumentError)
|
||||
lambda do
|
||||
-> do
|
||||
[1, 2].send(:initialize, 1, 'x', true) {}
|
||||
end.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on frozen arrays" do
|
||||
lambda do
|
||||
-> do
|
||||
ArraySpecs.frozen_array.send :initialize
|
||||
end.should raise_error(frozen_error_class)
|
||||
lambda do
|
||||
-> do
|
||||
ArraySpecs.frozen_array.send :initialize, ArraySpecs.frozen_array
|
||||
end.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
@ -53,7 +53,7 @@ describe "Array#initialize with no arguments" do
|
|||
end
|
||||
|
||||
it "does not use the given block" do
|
||||
lambda{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
|
||||
->{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -64,7 +64,7 @@ describe "Array#initialize with (array)" do
|
|||
end
|
||||
|
||||
it "does not use the given block" do
|
||||
lambda{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
|
||||
->{ [1, 2, 3].send(:initialize) { raise } }.should_not raise_error
|
||||
end
|
||||
|
||||
it "calls #to_ary to convert the value to an array" do
|
||||
|
@ -81,7 +81,7 @@ describe "Array#initialize with (array)" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if an Array type argument and a default object" do
|
||||
lambda { [].send(:initialize, [1, 2], 1) }.should raise_error(TypeError)
|
||||
-> { [].send(:initialize, [1, 2], 1) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,12 +103,12 @@ describe "Array#initialize with (size, object=nil)" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if size is negative" do
|
||||
lambda { [].send(:initialize, -1, :a) }.should raise_error(ArgumentError)
|
||||
lambda { [].send(:initialize, -1) }.should raise_error(ArgumentError)
|
||||
-> { [].send(:initialize, -1, :a) }.should raise_error(ArgumentError)
|
||||
-> { [].send(:initialize, -1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if size is too large" do
|
||||
lambda { [].send(:initialize, fixnum_max+1) }.should raise_error(ArgumentError)
|
||||
-> { [].send(:initialize, fixnum_max+1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "calls #to_int to convert the size argument to an Integer when object is given" do
|
||||
|
@ -126,7 +126,7 @@ describe "Array#initialize with (size, object=nil)" do
|
|||
it "raises a TypeError if the size argument is not an Integer type" do
|
||||
obj = mock('nonnumeric')
|
||||
obj.stub!(:to_ary).and_return([1, 2])
|
||||
lambda{ [].send(:initialize, obj, :a) }.should raise_error(TypeError)
|
||||
->{ [].send(:initialize, obj, :a) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "yields the index of the element and sets the element to the value of the block" do
|
||||
|
@ -134,7 +134,7 @@ describe "Array#initialize with (size, object=nil)" do
|
|||
end
|
||||
|
||||
it "uses the block value instead of using the default value" do
|
||||
lambda {
|
||||
-> {
|
||||
@result = [].send(:initialize, 3, :obj) { |i| i.to_s }
|
||||
}.should complain(/block supersedes default value argument/)
|
||||
@result.should == ['0', '1', '2']
|
||||
|
|
|
@ -46,8 +46,8 @@ describe "Array#insert" do
|
|||
end
|
||||
|
||||
it "raises an IndexError if the negative index is out of bounds" do
|
||||
lambda { [].insert(-2, 1) }.should raise_error(IndexError)
|
||||
lambda { [1].insert(-3, 2) }.should raise_error(IndexError)
|
||||
-> { [].insert(-2, 1) }.should raise_error(IndexError)
|
||||
-> { [1].insert(-3, 2) }.should raise_error(IndexError)
|
||||
end
|
||||
|
||||
it "does nothing of no object is passed" do
|
||||
|
@ -64,15 +64,15 @@ describe "Array#insert" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if no argument passed" do
|
||||
lambda { [].insert() }.should raise_error(ArgumentError)
|
||||
-> { [].insert() }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array is modified" do
|
||||
lambda { ArraySpecs.frozen_array.insert(0, 'x') }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.insert(0, 'x') }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on frozen arrays when the array would not be modified" do
|
||||
lambda { ArraySpecs.frozen_array.insert(0) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.insert(0) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,11 +24,11 @@ describe "Array#join" do
|
|||
|
||||
it "raises a TypeError if the separator cannot be coerced to a String by calling #to_str" do
|
||||
obj = mock("not a string")
|
||||
lambda { [1, 2].join(obj) }.should raise_error(TypeError)
|
||||
-> { [1, 2].join(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed false as the separator" do
|
||||
lambda { [1, 2].join(false) }.should raise_error(TypeError)
|
||||
-> { [1, 2].join(false) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ describe "Array#last" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when count is negative" do
|
||||
lambda { [1, 2].last(-1) }.should raise_error(ArgumentError)
|
||||
-> { [1, 2].last(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "returns the entire array when count > length" do
|
||||
|
@ -60,11 +60,11 @@ describe "Array#last" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if the passed argument is not numeric" do
|
||||
lambda { [1,2].last(nil) }.should raise_error(TypeError)
|
||||
lambda { [1,2].last("a") }.should raise_error(TypeError)
|
||||
-> { [1,2].last(nil) }.should raise_error(TypeError)
|
||||
-> { [1,2].last("a") }.should raise_error(TypeError)
|
||||
|
||||
obj = mock("nonnumeric")
|
||||
lambda { [1,2].last(obj) }.should raise_error(TypeError)
|
||||
-> { [1,2].last(obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not return subclass instance on Array subclasses" do
|
||||
|
|
|
@ -68,16 +68,16 @@ describe "Array#max" do
|
|||
end
|
||||
|
||||
it "raises a NoMethodError for elements without #<=>" do
|
||||
lambda do
|
||||
-> do
|
||||
[BasicObject.new, BasicObject.new].max
|
||||
end.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError for incomparable elements" do
|
||||
lambda do
|
||||
-> do
|
||||
[11,"22"].max
|
||||
end.should raise_error(ArgumentError)
|
||||
lambda do
|
||||
-> do
|
||||
[11,12,22,33].max{|a, b| nil}
|
||||
end.should raise_error(ArgumentError)
|
||||
end
|
||||
|
|
|
@ -68,16 +68,16 @@ describe "Array#min" do
|
|||
end
|
||||
|
||||
it "raises a NoMethodError for elements without #<=>" do
|
||||
lambda do
|
||||
-> do
|
||||
[BasicObject.new, BasicObject.new].min
|
||||
end.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError for incomparable elements" do
|
||||
lambda do
|
||||
-> do
|
||||
[11,"22"].min
|
||||
end.should raise_error(ArgumentError)
|
||||
lambda do
|
||||
-> do
|
||||
[11,12,22,33].min{|a, b| nil}
|
||||
end.should raise_error(ArgumentError)
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe "Array#*" do
|
|||
|
||||
it "raises a TypeError if the argument can neither be converted to a string nor an integer" do
|
||||
obj = mock('not a string or integer')
|
||||
lambda{ [1,2] * obj }.should raise_error(TypeError)
|
||||
->{ [1,2] * obj }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "converts the passed argument to a String rather than an Integer" do
|
||||
|
@ -28,15 +28,15 @@ describe "Array#*" do
|
|||
end
|
||||
|
||||
it "raises a TypeError is the passed argument is nil" do
|
||||
lambda{ [1,2] * nil }.should raise_error(TypeError)
|
||||
->{ [1,2] * nil }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when passed 2 or more arguments" do
|
||||
lambda{ [1,2].send(:*, 1, 2) }.should raise_error(ArgumentError)
|
||||
->{ [1,2].send(:*, 1, 2) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when passed no arguments" do
|
||||
lambda{ [1,2].send(:*) }.should raise_error(ArgumentError)
|
||||
->{ [1,2].send(:*) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,8 +65,8 @@ describe "Array#* with an integer" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when passed a negative integer" do
|
||||
lambda { [ 1, 2, 3 ] * -1 }.should raise_error(ArgumentError)
|
||||
lambda { [] * -1 }.should raise_error(ArgumentError)
|
||||
-> { [ 1, 2, 3 ] * -1 }.should raise_error(ArgumentError)
|
||||
-> { [] * -1 }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
describe "with a subclass of Array" do
|
||||
|
|
|
@ -11,10 +11,10 @@ describe "Array.new" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if passed 3 or more arguments" do
|
||||
lambda do
|
||||
-> do
|
||||
[1, 2].send :initialize, 1, 'x', true
|
||||
end.should raise_error(ArgumentError)
|
||||
lambda do
|
||||
-> do
|
||||
[1, 2].send(:initialize, 1, 'x', true) {}
|
||||
end.should raise_error(ArgumentError)
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ describe "Array.new with no arguments" do
|
|||
end
|
||||
|
||||
it "does not use the given block" do
|
||||
lambda{ Array.new { raise } }.should_not raise_error
|
||||
->{ Array.new { raise } }.should_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,7 +37,7 @@ describe "Array.new with (array)" do
|
|||
end
|
||||
|
||||
it "does not use the given block" do
|
||||
lambda{ Array.new([1, 2]) { raise } }.should_not raise_error
|
||||
->{ Array.new([1, 2]) { raise } }.should_not raise_error
|
||||
end
|
||||
|
||||
it "calls #to_ary to convert the value to an array" do
|
||||
|
@ -54,7 +54,7 @@ describe "Array.new with (array)" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if an Array type argument and a default object" do
|
||||
lambda { Array.new([1, 2], 1) }.should raise_error(TypeError)
|
||||
-> { Array.new([1, 2], 1) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,12 +74,12 @@ describe "Array.new with (size, object=nil)" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if size is negative" do
|
||||
lambda { Array.new(-1, :a) }.should raise_error(ArgumentError)
|
||||
lambda { Array.new(-1) }.should raise_error(ArgumentError)
|
||||
-> { Array.new(-1, :a) }.should raise_error(ArgumentError)
|
||||
-> { Array.new(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if size is too large" do
|
||||
lambda { Array.new(fixnum_max+1) }.should raise_error(ArgumentError)
|
||||
-> { Array.new(fixnum_max+1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "calls #to_int to convert the size argument to an Integer when object is given" do
|
||||
|
@ -97,7 +97,7 @@ describe "Array.new with (size, object=nil)" do
|
|||
it "raises a TypeError if the size argument is not an Integer type" do
|
||||
obj = mock('nonnumeric')
|
||||
obj.stub!(:to_ary).and_return([1, 2])
|
||||
lambda{ Array.new(obj, :a) }.should raise_error(TypeError)
|
||||
->{ Array.new(obj, :a) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "yields the index of the element and sets the element to the value of the block" do
|
||||
|
@ -105,7 +105,7 @@ describe "Array.new with (size, object=nil)" do
|
|||
end
|
||||
|
||||
it "uses the block value instead of using the default value" do
|
||||
lambda {
|
||||
-> {
|
||||
@result = Array.new(3, :obj) { |i| i.to_s }
|
||||
}.should complain(/block supersedes default value argument/)
|
||||
@result.should == ['0', '1', '2']
|
||||
|
|
|
@ -24,7 +24,7 @@ describe "Array#pack with :buffer option" do
|
|||
end
|
||||
|
||||
it "raises TypeError exception if buffer is not String" do
|
||||
lambda { [65].pack("ccc", buffer: []) }.should raise_error(
|
||||
-> { [65].pack("ccc", buffer: []) }.should raise_error(
|
||||
TypeError, "buffer must be String, not Array")
|
||||
end
|
||||
|
||||
|
|
|
@ -285,16 +285,16 @@ describe "Array#pack with format 'm'" do
|
|||
|
||||
it "raises a TypeError if #to_str does not return a String" do
|
||||
obj = mock("pack m non-string")
|
||||
lambda { [obj].pack("m") }.should raise_error(TypeError)
|
||||
-> { [obj].pack("m") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed nil" do
|
||||
lambda { [nil].pack("m") }.should raise_error(TypeError)
|
||||
-> { [nil].pack("m") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed an Integer" do
|
||||
lambda { [0].pack("m") }.should raise_error(TypeError)
|
||||
lambda { [bignum_value].pack("m") }.should raise_error(TypeError)
|
||||
-> { [0].pack("m") }.should raise_error(TypeError)
|
||||
-> { [bignum_value].pack("m") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not emit a newline if passed zero as the count modifier" do
|
||||
|
|
|
@ -2,6 +2,6 @@ require_relative '../../../spec_helper'
|
|||
|
||||
describe "Array#pack with format '%'" do
|
||||
it "raises an Argument Error" do
|
||||
lambda { [1].pack("%") }.should raise_error(ArgumentError)
|
||||
-> { [1].pack("%") }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
describe :array_pack_arguments, shared: true do
|
||||
it "raises an ArgumentError if there are fewer elements than the format requires" do
|
||||
lambda { [].pack(pack_format(1)) }.should raise_error(ArgumentError)
|
||||
-> { [].pack(pack_format(1)) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -10,11 +10,11 @@ describe :array_pack_basic, shared: true do
|
|||
end
|
||||
|
||||
it "raises a TypeError when passed nil" do
|
||||
lambda { [@obj].pack(nil) }.should raise_error(TypeError)
|
||||
-> { [@obj].pack(nil) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed an Integer" do
|
||||
lambda { [@obj].pack(1) }.should raise_error(TypeError)
|
||||
-> { [@obj].pack(1) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -56,10 +56,10 @@ end
|
|||
|
||||
describe :array_pack_no_platform, shared: true do
|
||||
it "raises ArgumentError when the format modifier is '_'" do
|
||||
lambda{ [1].pack(pack_format("_")) }.should raise_error(ArgumentError)
|
||||
->{ [1].pack(pack_format("_")) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises ArgumentError when the format modifier is '!'" do
|
||||
lambda{ [1].pack(pack_format("!")) }.should raise_error(ArgumentError)
|
||||
->{ [1].pack(pack_format("!")) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,12 +5,12 @@ describe :array_pack_hex, shared: true do
|
|||
|
||||
it "raises a TypeError if the object does not respond to #to_str" do
|
||||
obj = mock("pack hex non-string")
|
||||
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if #to_str does not return a String" do
|
||||
obj = mock("pack hex non-string")
|
||||
obj.should_receive(:to_str).and_return(1)
|
||||
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ describe :array_pack_float_le, shared: true do
|
|||
end
|
||||
|
||||
it "raises a TypeError if passed a String representation of a floating point number" do
|
||||
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "encodes the number of array elements specified by the count modifier" do
|
||||
|
@ -69,7 +69,7 @@ describe :array_pack_float_be, shared: true do
|
|||
end
|
||||
|
||||
it "raises a TypeError if passed a String representation of a floating point number" do
|
||||
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "encodes the number of array elements specified by the count modifier" do
|
||||
|
@ -124,7 +124,7 @@ describe :array_pack_double_le, shared: true do
|
|||
end
|
||||
|
||||
it "raises a TypeError if passed a String representation of a floating point number" do
|
||||
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "encodes the number of array elements specified by the count modifier" do
|
||||
|
@ -183,7 +183,7 @@ describe :array_pack_double_be, shared: true do
|
|||
end
|
||||
|
||||
it "raises a TypeError if passed a String representation of a floating point number" do
|
||||
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { ["13"].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "encodes the number of array elements specified by the count modifier" do
|
||||
|
|
|
@ -4,15 +4,15 @@ describe :array_pack_numeric_basic, shared: true do
|
|||
end
|
||||
|
||||
it "raises a TypeError when passed nil" do
|
||||
lambda { [nil].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [nil].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed true" do
|
||||
lambda { [true].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [true].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed false" do
|
||||
lambda { [false].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [false].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "returns a binary string" do
|
||||
|
@ -24,21 +24,21 @@ end
|
|||
describe :array_pack_integer, shared: true do
|
||||
it "raises a TypeError when the object does not respond to #to_int" do
|
||||
obj = mock('not an integer')
|
||||
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed a String" do
|
||||
lambda { ["5"].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { ["5"].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
describe :array_pack_float, shared: true do
|
||||
it "raises a TypeError if a String does not represent a floating point number" do
|
||||
lambda { ["a"].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { ["a"].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when the object does not respond to #to_f" do
|
||||
obj = mock('not an float')
|
||||
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,11 +17,11 @@ describe :array_pack_string, shared: true do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when the Array is empty" do
|
||||
lambda { [].pack(pack_format) }.should raise_error(ArgumentError)
|
||||
-> { [].pack(pack_format) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when the Array has too few elements" do
|
||||
lambda { ["a"].pack(pack_format(nil, 2)) }.should raise_error(ArgumentError)
|
||||
-> { ["a"].pack(pack_format(nil, 2)) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "calls #to_str to convert the element to a String" do
|
||||
|
@ -33,7 +33,7 @@ describe :array_pack_string, shared: true do
|
|||
|
||||
it "raises a TypeError when the object does not respond to #to_str" do
|
||||
obj = mock("not a string")
|
||||
lambda { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
-> { [obj].pack(pack_format) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "returns a string in encoding of common to the concatenated results" do
|
||||
|
|
|
@ -64,7 +64,7 @@ describe :array_pack_unicode, shared: true do
|
|||
it "raises a TypeError if #to_int does not return an Integer" do
|
||||
obj = mock('to_int')
|
||||
obj.should_receive(:to_int).and_return("5")
|
||||
lambda { [obj].pack("U") }.should raise_error(TypeError)
|
||||
-> { [obj].pack("U") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "ignores NULL bytes between directives" do
|
||||
|
@ -76,11 +76,11 @@ describe :array_pack_unicode, shared: true do
|
|||
end
|
||||
|
||||
it "raises a RangeError if passed a negative number" do
|
||||
lambda { [-1].pack("U") }.should raise_error(RangeError)
|
||||
-> { [-1].pack("U") }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "raises a RangeError if passed a number larger than an unsigned 32-bit integer" do
|
||||
lambda { [2**32].pack("U") }.should raise_error(RangeError)
|
||||
-> { [2**32].pack("U") }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "sets the output string to UTF-8 encoding" do
|
||||
|
|
|
@ -112,16 +112,16 @@ describe "Array#pack with format 'u'" do
|
|||
|
||||
it "raises a TypeError if #to_str does not return a String" do
|
||||
obj = mock("pack m non-string")
|
||||
lambda { [obj].pack("u") }.should raise_error(TypeError)
|
||||
-> { [obj].pack("u") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed nil" do
|
||||
lambda { [nil].pack("u") }.should raise_error(TypeError)
|
||||
-> { [nil].pack("u") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed an Integer" do
|
||||
lambda { [0].pack("u") }.should raise_error(TypeError)
|
||||
lambda { [bignum_value].pack("u") }.should raise_error(TypeError)
|
||||
-> { [0].pack("u") }.should raise_error(TypeError)
|
||||
-> { [bignum_value].pack("u") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "sets the output string to US-ASCII encoding" do
|
||||
|
|
|
@ -33,7 +33,7 @@ describe "Array#pack with format 'w'" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when passed a negative value" do
|
||||
lambda { [-1].pack("w") }.should raise_error(ArgumentError)
|
||||
-> { [-1].pack("w") }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "returns a binary string" do
|
||||
|
|
|
@ -55,10 +55,10 @@ describe "Array#pack with format 'X'" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if the output string is empty" do
|
||||
lambda { [1, 2, 3].pack("XC") }.should raise_error(ArgumentError)
|
||||
-> { [1, 2, 3].pack("XC") }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if the count modifier is greater than the bytes in the string" do
|
||||
lambda { [1, 2, 3].pack("C2X3") }.should raise_error(ArgumentError)
|
||||
-> { [1, 2, 3].pack("C2X3") }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,11 +39,11 @@ describe "Array#pop" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.pop }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.pop }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
lambda { ArraySpecs.empty_frozen_array.pop }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.pop }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "keeps untrusted status" do
|
||||
|
@ -105,7 +105,7 @@ describe "Array#pop" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if n is negative" do
|
||||
lambda{ [1, 2, 3].pop(-1) }.should raise_error(ArgumentError)
|
||||
->{ [1, 2, 3].pop(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "tries to convert n to an Integer using #to_int" do
|
||||
|
@ -120,12 +120,12 @@ describe "Array#pop" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when the passed n cannot be coerced to Integer" do
|
||||
lambda{ [1, 2].pop("cat") }.should raise_error(TypeError)
|
||||
lambda{ [1, 2].pop(nil) }.should raise_error(TypeError)
|
||||
->{ [1, 2].pop("cat") }.should raise_error(TypeError)
|
||||
->{ [1, 2].pop(nil) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if more arguments are passed" do
|
||||
lambda{ [1, 2].pop(1, 2) }.should raise_error(ArgumentError)
|
||||
->{ [1, 2].pop(1, 2) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not return subclass instances with Array subclass" do
|
||||
|
@ -153,8 +153,8 @@ describe "Array#pop" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.pop(2) }.should raise_error(frozen_error_class)
|
||||
lambda { ArraySpecs.frozen_array.pop(0) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.pop(2) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.pop(0) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "keeps untrusted status" do
|
||||
|
|
|
@ -3,7 +3,7 @@ require_relative 'fixtures/classes'
|
|||
|
||||
describe "Array#product" do
|
||||
it "returns converted arguments using :to_ary" do
|
||||
lambda{ [1].product(2..3) }.should raise_error(TypeError)
|
||||
->{ [1].product(2..3) }.should raise_error(TypeError)
|
||||
ar = ArraySpecs::ArrayConvertible.new(2,3)
|
||||
[1].product(ar).should == [[1,2],[1,3]]
|
||||
ar.called.should == :to_ary
|
||||
|
@ -24,7 +24,7 @@ describe "Array#product" do
|
|||
|
||||
it "does not attempt to produce an unreasonable number of products" do
|
||||
a = (0..100).to_a
|
||||
lambda do
|
||||
-> do
|
||||
a.product(a, a, a, a, a, a, a, a, a, a)
|
||||
end.should raise_error(RangeError)
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ describe "Array#product" do
|
|||
|
||||
it "will ignore unreasonable numbers of products and yield anyway" do
|
||||
a = (0..100).to_a
|
||||
lambda do
|
||||
-> do
|
||||
a.product(a, a, a, a, a, a, a, a, a, a)
|
||||
end.should raise_error(RangeError)
|
||||
end
|
||||
|
|
|
@ -104,11 +104,11 @@ describe "Array#reject!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.reject! {} }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.reject! {} }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
lambda { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.reject! {} }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "does not truncate the array is the block raises an exception" do
|
||||
|
|
|
@ -37,6 +37,6 @@ describe "Array#reverse!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.reverse! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.reverse! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,10 +27,10 @@ describe "Array#rotate" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if not passed an integer-like argument" do
|
||||
lambda {
|
||||
-> {
|
||||
[1, 2].rotate(nil)
|
||||
}.should raise_error(TypeError)
|
||||
lambda {
|
||||
-> {
|
||||
[1, 2].rotate("4")
|
||||
}.should raise_error(TypeError)
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ describe "Array#rotate" do
|
|||
end
|
||||
|
||||
it "does not mutate the receiver" do
|
||||
lambda {
|
||||
-> {
|
||||
[].freeze.rotate
|
||||
[2].freeze.rotate(2)
|
||||
[1,2,3].freeze.rotate(-3)
|
||||
|
@ -94,10 +94,10 @@ describe "Array#rotate!" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if not passed an integer-like argument" do
|
||||
lambda {
|
||||
-> {
|
||||
[1, 2].rotate!(nil)
|
||||
}.should raise_error(TypeError)
|
||||
lambda {
|
||||
-> {
|
||||
[1, 2].rotate!("4")
|
||||
}.should raise_error(TypeError)
|
||||
end
|
||||
|
@ -122,8 +122,8 @@ describe "Array#rotate!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { [1, 2, 3].freeze.rotate!(0) }.should raise_error(frozen_error_class)
|
||||
lambda { [1].freeze.rotate!(42) }.should raise_error(frozen_error_class)
|
||||
lambda { [].freeze.rotate! }.should raise_error(frozen_error_class)
|
||||
-> { [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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,7 +57,7 @@ describe "Array#sample" do
|
|||
end
|
||||
|
||||
it "raises ArgumentError when passed a negative count" do
|
||||
lambda { [1, 2].sample(-1) }.should raise_error(ArgumentError)
|
||||
-> { [1, 2].sample(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not return subclass instances with Array subclass" do
|
||||
|
@ -92,7 +92,7 @@ describe "Array#sample" do
|
|||
it "raises a NoMethodError if an object passed for the RNG does not define #rand" do
|
||||
obj = BasicObject.new
|
||||
|
||||
lambda { [1, 2].sample(random: obj) }.should raise_error(NoMethodError)
|
||||
-> { [1, 2].sample(random: obj) }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
describe "when the object returned by #rand is a Fixnum" do
|
||||
|
@ -112,14 +112,14 @@ describe "Array#sample" do
|
|||
random = mock("array_sample_random")
|
||||
random.should_receive(:rand).and_return(-1)
|
||||
|
||||
lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
-> { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "raises a RangeError if the value is equal to the Array size" do
|
||||
random = mock("array_sample_random")
|
||||
random.should_receive(:rand).and_return(2)
|
||||
|
||||
lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
-> { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -140,7 +140,7 @@ describe "Array#sample" do
|
|||
random = mock("array_sample_random")
|
||||
random.should_receive(:rand).and_return(value)
|
||||
|
||||
lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
-> { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "raises a RangeError if the value is equal to the Array size" do
|
||||
|
@ -149,7 +149,7 @@ describe "Array#sample" do
|
|||
random = mock("array_sample_random")
|
||||
random.should_receive(:rand).and_return(value)
|
||||
|
||||
lambda { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
-> { [1, 2].sample(random: random) }.should raise_error(RangeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ describe :array_collect, shared: true do
|
|||
|
||||
it "raises an ArgumentError when no block and with arguments" do
|
||||
a = [1, 2, 3]
|
||||
lambda {
|
||||
-> {
|
||||
a.send(@method, :foo)
|
||||
}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
@ -111,21 +111,21 @@ describe :array_collect_b, shared: true do
|
|||
|
||||
describe "when frozen" do
|
||||
it "raises a #{frozen_error_class}" do
|
||||
lambda { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when empty" do
|
||||
lambda { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.send(@method) {} }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when calling #each on the returned Enumerator" do
|
||||
enumerator = ArraySpecs.frozen_array.send(@method)
|
||||
lambda { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
|
||||
-> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} when calling #each on the returned Enumerator when empty" do
|
||||
enumerator = ArraySpecs.empty_frozen_array.send(@method)
|
||||
lambda { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
|
||||
-> { enumerator.each {|x| x } }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ describe :array_binary_difference, shared: true do
|
|||
|
||||
it "raises a TypeError if the argument cannot be coerced to an Array by calling #to_ary" do
|
||||
obj = mock('not an array')
|
||||
lambda { [1, 2, 3].send(@method, obj) }.should raise_error(TypeError)
|
||||
-> { [1, 2, 3].send(@method, obj) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not return subclass instance for Array subclasses" do
|
||||
|
|
|
@ -55,7 +55,7 @@ describe :array_inspect, shared: true do
|
|||
obj.should_receive(:inspect).and_return(obj)
|
||||
obj.should_receive(:to_s).and_raise(Exception)
|
||||
|
||||
lambda { [obj].send(@method) }.should raise_error(Exception)
|
||||
-> { [obj].send(@method) }.should raise_error(Exception)
|
||||
end
|
||||
|
||||
it "represents a recursive element with '[...]'" do
|
||||
|
|
|
@ -49,13 +49,13 @@ describe :array_join_with_default_separator, shared: true do
|
|||
it "raises a NoMethodError if an element does not respond to #to_str, #to_ary, or #to_s" do
|
||||
obj = mock('o')
|
||||
class << obj; undef :to_s; end
|
||||
lambda { [1, obj].send(@method) }.should raise_error(NoMethodError)
|
||||
-> { [1, obj].send(@method) }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError when the Array is recursive" do
|
||||
lambda { ArraySpecs.recursive_array.send(@method) }.should raise_error(ArgumentError)
|
||||
lambda { ArraySpecs.head_recursive_array.send(@method) }.should raise_error(ArgumentError)
|
||||
lambda { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
|
||||
-> { ArraySpecs.recursive_array.send(@method) }.should raise_error(ArgumentError)
|
||||
-> { ArraySpecs.head_recursive_array.send(@method) }.should raise_error(ArgumentError)
|
||||
-> { ArraySpecs.empty_recursive_array.send(@method) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "taints the result if the Array is tainted and non-empty" do
|
||||
|
@ -109,7 +109,7 @@ describe :array_join_with_default_separator, shared: true do
|
|||
it "fails for arrays with incompatibly-encoded strings" do
|
||||
ary_utf8_bad_binary = ArraySpecs.array_with_utf8_and_binary_strings
|
||||
|
||||
lambda { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError)
|
||||
-> { ary_utf8_bad_binary.send(@method) }.should raise_error(EncodingError)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -37,23 +37,23 @@ describe :keep_if, shared: true do
|
|||
|
||||
describe "with truthy block" do
|
||||
it "keeps elements after any exception" do
|
||||
lambda { @frozen.send(@method) { true } }.should raise_error(Exception)
|
||||
-> { @frozen.send(@method) { true } }.should raise_error(Exception)
|
||||
@frozen.should == @origin
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class}" do
|
||||
lambda { @frozen.send(@method) { true } }.should raise_error(frozen_error_class)
|
||||
-> { @frozen.send(@method) { true } }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with falsy block" do
|
||||
it "keeps elements after any exception" do
|
||||
lambda { @frozen.send(@method) { false } }.should raise_error(Exception)
|
||||
-> { @frozen.send(@method) { false } }.should raise_error(Exception)
|
||||
@frozen.should == @origin
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class}" do
|
||||
lambda { @frozen.send(@method) { false } }.should raise_error(frozen_error_class)
|
||||
-> { @frozen.send(@method) { false } }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ describe :array_push, shared: true do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
|
||||
lambda { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ describe :array_replace, shared: true do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda {
|
||||
-> {
|
||||
ArraySpecs.frozen_array.send(@method, ArraySpecs.frozen_array)
|
||||
}.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
|
|
@ -266,10 +266,10 @@ describe :array_slice, shared: true do
|
|||
a.send(@method, 1..0).should == []
|
||||
a.send(@method, 1...0).should == []
|
||||
|
||||
lambda { a.send(@method, "a" .. "b") }.should raise_error(TypeError)
|
||||
lambda { a.send(@method, "a" ... "b") }.should raise_error(TypeError)
|
||||
lambda { a.send(@method, from .. "b") }.should raise_error(TypeError)
|
||||
lambda { a.send(@method, from ... "b") }.should raise_error(TypeError)
|
||||
-> { a.send(@method, "a" .. "b") }.should raise_error(TypeError)
|
||||
-> { a.send(@method, "a" ... "b") }.should raise_error(TypeError)
|
||||
-> { a.send(@method, from .. "b") }.should raise_error(TypeError)
|
||||
-> { a.send(@method, from ... "b") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "returns the same elements as [m..n] and [m...n] with Range subclasses" do
|
||||
|
@ -441,19 +441,19 @@ describe :array_slice, shared: true do
|
|||
array = [1, 2, 3, 4, 5, 6]
|
||||
obj = mock('large value')
|
||||
obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
|
||||
lambda { array.send(@method, obj) }.should raise_error(RangeError)
|
||||
-> { array.send(@method, obj) }.should raise_error(RangeError)
|
||||
|
||||
obj = 8e19
|
||||
lambda { array.send(@method, obj) }.should raise_error(RangeError)
|
||||
-> { array.send(@method, obj) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "raises a RangeError when the length is out of range of Fixnum" do
|
||||
array = [1, 2, 3, 4, 5, 6]
|
||||
obj = mock('large value')
|
||||
obj.should_receive(:to_int).and_return(0x8000_0000_0000_0000_0000)
|
||||
lambda { array.send(@method, 1, obj) }.should raise_error(RangeError)
|
||||
-> { array.send(@method, 1, obj) }.should raise_error(RangeError)
|
||||
|
||||
obj = 8e19
|
||||
lambda { array.send(@method, 1, obj) }.should raise_error(RangeError)
|
||||
-> { array.send(@method, 1, obj) }.should raise_error(RangeError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,11 +36,11 @@ describe :array_unshift, shared: true do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array when the array is modified" do
|
||||
lambda { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.send(@method, 1) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen array when the array would not be modified" do
|
||||
lambda { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.send(@method) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,10 +31,10 @@ describe "Array#shift" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.shift }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.shift }.should raise_error(frozen_error_class)
|
||||
end
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
lambda { ArraySpecs.empty_frozen_array.shift }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.shift }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
describe "passed a number n as an argument" do
|
||||
|
@ -90,7 +90,7 @@ describe "Array#shift" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError if n is negative" do
|
||||
lambda{ [1, 2, 3].shift(-1) }.should raise_error(ArgumentError)
|
||||
->{ [1, 2, 3].shift(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "tries to convert n to an Integer using #to_int" do
|
||||
|
@ -105,12 +105,12 @@ describe "Array#shift" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when the passed n cannot be coerced to Integer" do
|
||||
lambda{ [1, 2].shift("cat") }.should raise_error(TypeError)
|
||||
lambda{ [1, 2].shift(nil) }.should raise_error(TypeError)
|
||||
->{ [1, 2].shift("cat") }.should raise_error(TypeError)
|
||||
->{ [1, 2].shift(nil) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if more arguments are passed" do
|
||||
lambda{ [1, 2].shift(1, 2) }.should raise_error(ArgumentError)
|
||||
->{ [1, 2].shift(1, 2) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not return subclass instances with Array subclass" do
|
||||
|
|
|
@ -43,7 +43,7 @@ describe "Array#shuffle" do
|
|||
it "raises a NoMethodError if an object passed for the RNG does not define #rand" do
|
||||
obj = BasicObject.new
|
||||
|
||||
lambda { [1, 2].shuffle(random: obj) }.should raise_error(NoMethodError)
|
||||
-> { [1, 2].shuffle(random: obj) }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "accepts a Float for the value returned by #rand" do
|
||||
|
@ -68,7 +68,7 @@ describe "Array#shuffle" do
|
|||
random = mock("array_shuffle_random")
|
||||
random.should_receive(:rand).and_return(value)
|
||||
|
||||
lambda { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
|
||||
-> { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
|
||||
end
|
||||
|
||||
it "raises a RangeError if the value is equal to one" do
|
||||
|
@ -77,7 +77,7 @@ describe "Array#shuffle" do
|
|||
random = mock("array_shuffle_random")
|
||||
random.should_receive(:rand).at_least(1).times.and_return(value)
|
||||
|
||||
lambda { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
|
||||
-> { [1, 2].shuffle(random: random) }.should raise_error(RangeError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,7 +96,7 @@ describe "Array#shuffle!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.shuffle! }.should raise_error(frozen_error_class)
|
||||
lambda { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.shuffle! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.shuffle! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -116,8 +116,8 @@ describe "Array#slice!" do
|
|||
a.slice!(from .. to).should == [2, 3, 4]
|
||||
a.should == [1, 5]
|
||||
|
||||
lambda { a.slice!("a" .. "b") }.should raise_error(TypeError)
|
||||
lambda { a.slice!(from .. "b") }.should raise_error(TypeError)
|
||||
-> { a.slice!("a" .. "b") }.should raise_error(TypeError)
|
||||
-> { a.slice!(from .. "b") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "returns last element for consecutive calls at zero index" do
|
||||
|
@ -151,7 +151,7 @@ describe "Array#slice!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.slice!(0, 0) }.should raise_error(frozen_error_class)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ describe "Array#sort_by!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on an empty frozen array" do
|
||||
lambda { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.sort_by! {}}.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "returns the specified value when it would break in the given block" do
|
||||
|
|
|
@ -66,7 +66,7 @@ describe "Array#sort" do
|
|||
it "does not deal with exceptions raised by unimplemented or incorrect #<=>" do
|
||||
o = Object.new
|
||||
|
||||
lambda {
|
||||
-> {
|
||||
[o, 1].sort
|
||||
}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
@ -78,7 +78,7 @@ describe "Array#sort" do
|
|||
end
|
||||
|
||||
it "raises an error when a given block returns nil" do
|
||||
lambda { [1, 2].sort {} }.should raise_error(ArgumentError)
|
||||
-> { [1, 2].sort {} }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not call #<=> on contained objects when invoked with a block" do
|
||||
|
@ -134,7 +134,7 @@ describe "Array#sort" do
|
|||
a.sort { |n, m|
|
||||
ArraySpecs::ComparableWithFixnum.new(n-m)
|
||||
}.should == [-4, 1, 2, 5, 7, 10, 12]
|
||||
lambda {
|
||||
-> {
|
||||
a.sort { |n, m| (n - m).to_s }
|
||||
}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
@ -155,7 +155,7 @@ describe "Array#sort" do
|
|||
|
||||
it "raises an error if objects can't be compared" do
|
||||
a=[ArraySpecs::Uncomparable.new, ArraySpecs::Uncomparable.new]
|
||||
lambda {a.sort}.should raise_error(ArgumentError)
|
||||
-> {a.sort}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
# From a strange Rubinius bug
|
||||
|
@ -234,7 +234,7 @@ describe "Array#sort!" do
|
|||
end
|
||||
|
||||
it "raises a #{frozen_error_class} on a frozen array" do
|
||||
lambda { ArraySpecs.frozen_array.sort! }.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.sort! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "returns the specified value when it would break in the given block" do
|
||||
|
|
|
@ -26,11 +26,11 @@ describe "Array#sum" do
|
|||
end
|
||||
|
||||
it 'raises TypeError if any element are not numeric' do
|
||||
lambda { ["a"].sum }.should raise_error(TypeError)
|
||||
-> { ["a"].sum }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it 'raises TypeError if any element cannot be added to init value' do
|
||||
lambda { [1].sum([]) }.should raise_error(TypeError)
|
||||
-> { [1].sum([]) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "calls + to sum the elements" do
|
||||
|
|
|
@ -22,6 +22,6 @@ describe "Array#take" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError when the argument is negative" do
|
||||
lambda{ [1].take(-3) }.should raise_error(ArgumentError)
|
||||
->{ [1].take(-3) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,15 +24,15 @@ describe "Array#to_h" do
|
|||
end
|
||||
|
||||
it "raises TypeError if an element is not an array" do
|
||||
lambda { [:x].to_h }.should raise_error(TypeError)
|
||||
-> { [:x].to_h }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises ArgumentError if an element is not a [key, value] pair" do
|
||||
lambda { [[:x]].to_h }.should raise_error(ArgumentError)
|
||||
-> { [[:x]].to_h }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "does not accept arguments" do
|
||||
lambda { [].to_h(:a, :b) }.should raise_error(ArgumentError)
|
||||
-> { [].to_h(:a, :b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "produces a hash that returns nil for a missing element" do
|
||||
|
|
|
@ -32,7 +32,7 @@ describe "Array#transpose" do
|
|||
end
|
||||
|
||||
it "raises a TypeError if the passed Argument does not respond to #to_ary" do
|
||||
lambda { [Object.new, [:a, :b]].transpose }.should raise_error(TypeError)
|
||||
-> { [Object.new, [:a, :b]].transpose }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not call to_ary on array subclass elements" do
|
||||
|
@ -41,7 +41,7 @@ describe "Array#transpose" do
|
|||
end
|
||||
|
||||
it "raises an IndexError if the arrays are not of the same length" do
|
||||
lambda { [[1, 2], [:a]].transpose }.should raise_error(IndexError)
|
||||
-> { [[1, 2], [:a]].transpose }.should raise_error(IndexError)
|
||||
end
|
||||
|
||||
it "does not return subclass instance on Array subclasses" do
|
||||
|
|
|
@ -39,12 +39,12 @@ describe "Array.try_convert" do
|
|||
it "sends #to_ary to the argument and raises TypeError if it's not a kind of Array" do
|
||||
obj = mock("to_ary")
|
||||
obj.should_receive(:to_ary).and_return(Object.new)
|
||||
lambda { Array.try_convert obj }.should raise_error(TypeError)
|
||||
-> { Array.try_convert obj }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "does not rescue exceptions raised by #to_ary" do
|
||||
obj = mock("to_ary")
|
||||
obj.should_receive(:to_ary).and_raise(RuntimeError)
|
||||
lambda { Array.try_convert obj }.should raise_error(RuntimeError)
|
||||
-> { Array.try_convert obj }.should raise_error(RuntimeError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -191,17 +191,17 @@ describe "Array#uniq!" do
|
|||
it "raises a #{frozen_error_class} on a frozen array when the array is modified" do
|
||||
dup_ary = [1, 1, 2]
|
||||
dup_ary.freeze
|
||||
lambda { dup_ary.uniq! }.should raise_error(frozen_error_class)
|
||||
-> { dup_ary.uniq! }.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
# see [ruby-core:23666]
|
||||
it "raises a #{frozen_error_class} on a frozen array when the array would not be modified" do
|
||||
lambda { ArraySpecs.frozen_array.uniq!}.should raise_error(frozen_error_class)
|
||||
lambda { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.frozen_array.uniq!}.should raise_error(frozen_error_class)
|
||||
-> { ArraySpecs.empty_frozen_array.uniq!}.should raise_error(frozen_error_class)
|
||||
end
|
||||
|
||||
it "doesn't yield to the block on a frozen array" do
|
||||
lambda { 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(frozen_error_class)
|
||||
end
|
||||
|
||||
it "compares elements based on the value returned from the block" do
|
||||
|
|
|
@ -8,7 +8,7 @@ describe "BasicObject" do
|
|||
end
|
||||
|
||||
it "raises NameError when referencing built-in constants" do
|
||||
lambda { class BasicObjectSpecs::BOSubclass; Kernel; end }.should raise_error(NameError)
|
||||
-> { class BasicObjectSpecs::BOSubclass; Kernel; end }.should raise_error(NameError)
|
||||
end
|
||||
|
||||
it "does not define built-in constants (according to const_defined?)" do
|
||||
|
@ -85,7 +85,7 @@ describe "BasicObject subclass" do
|
|||
|
||||
describe "BasicObject references" do
|
||||
it "can refer to BasicObject from within itself" do
|
||||
lambda { BasicObject::BasicObject }.should_not raise_error
|
||||
-> { BasicObject::BasicObject }.should_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ describe "BasicObject#initialize" do
|
|||
end
|
||||
|
||||
it "does not accept arguments" do
|
||||
lambda {
|
||||
-> {
|
||||
BasicObject.new("This", "makes it easier", "to call super", "from other constructors")
|
||||
}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
|
|
@ -21,11 +21,11 @@ describe "BasicObject#instance_eval" do
|
|||
end
|
||||
|
||||
it "expects a block with no arguments" do
|
||||
lambda { "hola".instance_eval }.should raise_error(ArgumentError)
|
||||
-> { "hola".instance_eval }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "takes no arguments with a block" do
|
||||
lambda { "hola".instance_eval(4, 5) {|a,b| a + b } }.should raise_error(ArgumentError)
|
||||
-> { "hola".instance_eval(4, 5) {|a,b| a + b } }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "yields the object to the block" do
|
||||
|
@ -45,7 +45,7 @@ describe "BasicObject#instance_eval" do
|
|||
end
|
||||
end
|
||||
f.foo.should == 1
|
||||
lambda { Object.new.foo }.should raise_error(NoMethodError)
|
||||
-> { Object.new.foo }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "preserves self in the original block when passed a block argument" do
|
||||
|
@ -122,10 +122,10 @@ describe "BasicObject#instance_eval" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when defining methods on an immediate" do
|
||||
lambda do
|
||||
-> do
|
||||
1.instance_eval { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
lambda do
|
||||
-> do
|
||||
:foo.instance_eval { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
end
|
||||
|
@ -143,10 +143,10 @@ quarantine! do # Not clean, leaves cvars lying around to break other specs
|
|||
end
|
||||
|
||||
it "raises a TypeError when defining methods on numerics" do
|
||||
lambda do
|
||||
-> do
|
||||
(1.0).instance_eval { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
lambda do
|
||||
-> do
|
||||
(1 << 64).instance_eval { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
end
|
||||
|
|
|
@ -17,7 +17,7 @@ describe "BasicObject#instance_exec" do
|
|||
end
|
||||
|
||||
it "raises a LocalJumpError unless given a block" do
|
||||
lambda { "hola".instance_exec }.should raise_error(LocalJumpError)
|
||||
-> { "hola".instance_exec }.should raise_error(LocalJumpError)
|
||||
end
|
||||
|
||||
it "has an arity of -1" do
|
||||
|
@ -25,7 +25,7 @@ describe "BasicObject#instance_exec" do
|
|||
end
|
||||
|
||||
it "accepts arguments with a block" do
|
||||
lambda { "hola".instance_exec(4, 5) { |a,b| a + b } }.should_not raise_error
|
||||
-> { "hola".instance_exec(4, 5) { |a,b| a + b } }.should_not raise_error
|
||||
end
|
||||
|
||||
it "doesn't pass self to the block as an argument" do
|
||||
|
@ -44,7 +44,7 @@ describe "BasicObject#instance_exec" do
|
|||
end
|
||||
end
|
||||
f.foo.should == 1
|
||||
lambda { Object.new.foo }.should raise_error(NoMethodError)
|
||||
-> { Object.new.foo }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
# TODO: This should probably be replaced with a "should behave like" that uses
|
||||
|
@ -76,10 +76,10 @@ describe "BasicObject#instance_exec" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when defining methods on an immediate" do
|
||||
lambda do
|
||||
-> do
|
||||
1.instance_exec { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
lambda do
|
||||
-> do
|
||||
:foo.instance_exec { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
end
|
||||
|
@ -97,10 +97,10 @@ quarantine! do # Not clean, leaves cvars lying around to break other specs
|
|||
end
|
||||
|
||||
it "raises a TypeError when defining methods on numerics" do
|
||||
lambda do
|
||||
-> do
|
||||
(1.0).instance_exec { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
lambda do
|
||||
-> do
|
||||
(1 << 64).instance_exec { def foo; end }
|
||||
end.should raise_error(TypeError)
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ describe 'Binding#local_variable_defined?' do
|
|||
|
||||
it 'returns true when a local variable is defined in a parent scope' do
|
||||
foo = 10
|
||||
lambda {
|
||||
-> {
|
||||
binding.local_variable_defined?(:foo)
|
||||
}.call.should == true
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ describe "Binding#local_variable_get" do
|
|||
it "raises a NameError for missing variables" do
|
||||
bind = BindingSpecs::Demo.new(1).get_empty_binding
|
||||
|
||||
lambda {
|
||||
-> {
|
||||
bind.local_variable_get(:no_such_variable)
|
||||
}.should raise_error(NameError)
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ describe "Binding#local_variable_get" do
|
|||
it "reads variables added later to the binding" do
|
||||
bind = BindingSpecs::Demo.new(1).get_empty_binding
|
||||
|
||||
lambda {
|
||||
-> {
|
||||
bind.local_variable_get(:a)
|
||||
}.should raise_error(NameError)
|
||||
|
||||
|
@ -31,7 +31,7 @@ describe "Binding#local_variable_get" do
|
|||
it 'gets a local variable defined in a parent scope' do
|
||||
number = 10
|
||||
|
||||
lambda {
|
||||
-> {
|
||||
binding.local_variable_get(:number)
|
||||
}.call.should == 10
|
||||
end
|
||||
|
@ -45,12 +45,12 @@ describe "Binding#local_variable_get" do
|
|||
|
||||
it "raises a NameError on global access" do
|
||||
bind = binding
|
||||
lambda { bind.local_variable_get(:$0) }.should raise_error(NameError)
|
||||
-> { bind.local_variable_get(:$0) }.should raise_error(NameError)
|
||||
end
|
||||
|
||||
it "raises a NameError on special variable access" do
|
||||
bind = binding
|
||||
lambda { bind.local_variable_get(:$~) }.should raise_error(NameError)
|
||||
lambda { bind.local_variable_get(:$_) }.should raise_error(NameError)
|
||||
-> { bind.local_variable_get(:$~) }.should raise_error(NameError)
|
||||
-> { bind.local_variable_get(:$_) }.should raise_error(NameError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ describe "Binding#local_variable_set" do
|
|||
bind = binding
|
||||
bind.local_variable_set(:number, 10)
|
||||
|
||||
lambda { number }.should raise_error(NameError)
|
||||
-> { number }.should raise_error(NameError)
|
||||
end
|
||||
|
||||
it 'overwrites an existing local variable defined before a Binding' do
|
||||
|
@ -59,13 +59,13 @@ describe "Binding#local_variable_set" do
|
|||
|
||||
it "raises a NameError on global access" do
|
||||
bind = binding
|
||||
lambda { bind.local_variable_set(:$0, "") }.should raise_error(NameError)
|
||||
-> { bind.local_variable_set(:$0, "") }.should raise_error(NameError)
|
||||
end
|
||||
|
||||
it "raises a NameError on special variable access" do
|
||||
bind = binding
|
||||
lambda { bind.local_variable_set(:$~, "") }.should raise_error(NameError)
|
||||
lambda { bind.local_variable_set(:$_, "") }.should raise_error(NameError)
|
||||
-> { bind.local_variable_set(:$~, "") }.should raise_error(NameError)
|
||||
-> { bind.local_variable_set(:$_, "") }.should raise_error(NameError)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ describe "Class#allocate" do
|
|||
|
||||
it "throws an exception when calling a method on a new instance" do
|
||||
klass = Class.allocate
|
||||
lambda do
|
||||
-> do
|
||||
klass.new
|
||||
end.should raise_error(Exception)
|
||||
end
|
||||
|
@ -34,7 +34,7 @@ describe "Class#allocate" do
|
|||
end
|
||||
|
||||
it "raises TypeError for #superclass" do
|
||||
lambda do
|
||||
-> do
|
||||
Class.allocate.superclass
|
||||
end.should raise_error(TypeError)
|
||||
end
|
||||
|
|
|
@ -92,10 +92,10 @@ describe "Class.inherited" do
|
|||
end
|
||||
|
||||
class << top; private :inherited; end
|
||||
lambda { Class.new(top) }.should_not raise_error
|
||||
-> { Class.new(top) }.should_not raise_error
|
||||
|
||||
class << top; protected :inherited; end
|
||||
lambda { Class.new(top) }.should_not raise_error
|
||||
-> { Class.new(top) }.should_not raise_error
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,18 +6,18 @@ describe "Class#initialize" do
|
|||
end
|
||||
|
||||
it "raises a TypeError when called on already initialized classes" do
|
||||
lambda{
|
||||
->{
|
||||
Fixnum.send :initialize
|
||||
}.should raise_error(TypeError)
|
||||
|
||||
lambda{
|
||||
->{
|
||||
Object.send :initialize
|
||||
}.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
# See [redmine:2601]
|
||||
it "raises a TypeError when called on BasicObject" do
|
||||
lambda{
|
||||
->{
|
||||
BasicObject.send :initialize
|
||||
}.should raise_error(TypeError)
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ describe "Class#initialize" do
|
|||
end
|
||||
|
||||
it "raises a TypeError" do
|
||||
lambda{@uninitialized.send(:initialize, Class)}.should raise_error(TypeError)
|
||||
->{@uninitialized.send(:initialize, Class)}.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ describe "Class.new" do
|
|||
it "raises a TypeError if passed a metaclass" do
|
||||
obj = mock("Class.new metaclass")
|
||||
meta = obj.singleton_class
|
||||
lambda { Class.new meta }.should raise_error(TypeError)
|
||||
-> { Class.new meta }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "creates a class without a name" do
|
||||
|
@ -96,11 +96,11 @@ describe "Class.new" do
|
|||
|
||||
it "raises a TypeError when given a non-Class" do
|
||||
error_msg = /superclass must be a Class/
|
||||
lambda { Class.new("") }.should raise_error(TypeError, error_msg)
|
||||
lambda { Class.new(1) }.should raise_error(TypeError, error_msg)
|
||||
lambda { Class.new(:symbol) }.should raise_error(TypeError, error_msg)
|
||||
lambda { Class.new(mock('o')) }.should raise_error(TypeError, error_msg)
|
||||
lambda { Class.new(Module.new) }.should raise_error(TypeError, error_msg)
|
||||
-> { Class.new("") }.should raise_error(TypeError, error_msg)
|
||||
-> { Class.new(1) }.should raise_error(TypeError, error_msg)
|
||||
-> { Class.new(:symbol) }.should raise_error(TypeError, error_msg)
|
||||
-> { Class.new(mock('o')) }.should raise_error(TypeError, error_msg)
|
||||
-> { Class.new(Module.new) }.should raise_error(TypeError, error_msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ require_relative 'fixtures/classes'
|
|||
describe 'Comparable#clamp' do
|
||||
it 'raises an Argument error unless given 2 parameters' do
|
||||
c = ComparableSpecs::Weird.new(0)
|
||||
lambda { c.clamp(c) }.should raise_error(ArgumentError)
|
||||
lambda { c.clamp(c, c, c) }.should raise_error(ArgumentError)
|
||||
-> { c.clamp(c) }.should raise_error(ArgumentError)
|
||||
-> { c.clamp(c, c, c) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it 'raises an Argument error unless the 2 parameters are correctly ordered' do
|
||||
|
@ -13,9 +13,9 @@ describe 'Comparable#clamp' do
|
|||
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
|
||||
c = ComparableSpecs::Weird.new(3)
|
||||
|
||||
lambda { c.clamp(two, one) }.should raise_error(ArgumentError)
|
||||
-> { c.clamp(two, one) }.should raise_error(ArgumentError)
|
||||
one.should_receive(:<=>).any_number_of_times.and_return(nil)
|
||||
lambda { c.clamp(one, two) }.should raise_error(ArgumentError)
|
||||
-> { c.clamp(one, two) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it 'returns self if within the given parameters' do
|
||||
|
|
|
@ -49,7 +49,7 @@ describe "Comparable#==" do
|
|||
end
|
||||
|
||||
it "raises an ArgumentError" do
|
||||
lambda { (a == b) }.should raise_error(ArgumentError)
|
||||
-> { (a == b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -60,7 +60,7 @@ describe "Comparable#==" do
|
|||
end
|
||||
|
||||
it "lets it go through" do
|
||||
lambda { (a == b) }.should raise_error(StandardError)
|
||||
-> { (a == b) }.should raise_error(StandardError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -71,13 +71,13 @@ describe "Comparable#==" do
|
|||
end
|
||||
|
||||
it "lets it go through" do
|
||||
lambda { (a == b) }.should raise_error(TypeError)
|
||||
-> { (a == b) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
||||
it "lets it go through if it is not a StandardError" do
|
||||
a.should_receive(:<=>).once.and_raise(Exception)
|
||||
lambda { (a == b) }.should raise_error(Exception)
|
||||
-> { (a == b) }.should raise_error(Exception)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -38,6 +38,6 @@ describe "Comparable#>" do
|
|||
b = ComparableSpecs::Weird.new(20)
|
||||
|
||||
a.should_receive(:<=>).any_number_of_times.and_return(nil)
|
||||
lambda { (a > b) }.should raise_error(ArgumentError)
|
||||
-> { (a > b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,6 +42,6 @@ describe "Comparable#>=" do
|
|||
b = ComparableSpecs::Weird.new(20)
|
||||
|
||||
a.should_receive(:<=>).any_number_of_times.and_return(nil)
|
||||
lambda { (a >= b) }.should raise_error(ArgumentError)
|
||||
-> { (a >= b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,6 +38,6 @@ describe "Comparable#<" do
|
|||
b = ComparableSpecs::Weird.new(20)
|
||||
|
||||
a.should_receive(:<=>).any_number_of_times.and_return(nil)
|
||||
lambda { (a < b) }.should raise_error(ArgumentError)
|
||||
-> { (a < b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -41,6 +41,6 @@ describe "Comparable#<=" do
|
|||
b = ComparableSpecs::Weird.new(20)
|
||||
|
||||
a.should_receive(:<=>).any_number_of_times.and_return(nil)
|
||||
lambda { (a <= b) }.should raise_error(ArgumentError)
|
||||
-> { (a <= b) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,18 +53,18 @@ describe "Complex#coerce" do
|
|||
it "raises TypeError when other is a Numeric which responds to #real? with false" do
|
||||
other = mock_numeric('other')
|
||||
other.should_receive(:real?).any_number_of_times.and_return(false)
|
||||
lambda { @one.coerce(other) }.should raise_error(TypeError)
|
||||
-> { @one.coerce(other) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when other is a String" do
|
||||
lambda { @one.coerce("20") }.should raise_error(TypeError)
|
||||
-> { @one.coerce("20") }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when other is nil" do
|
||||
lambda { @one.coerce(nil) }.should raise_error(TypeError)
|
||||
-> { @one.coerce(nil) }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError when other is false" do
|
||||
lambda { @one.coerce(false) }.should raise_error(TypeError)
|
||||
-> { @one.coerce(false) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,21 +2,21 @@ require_relative '../../spec_helper'
|
|||
|
||||
describe "Complex#fdiv" do
|
||||
it "accepts a numeric argument" do
|
||||
lambda { Complex(20).fdiv(2) }.should_not raise_error(TypeError)
|
||||
lambda { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError)
|
||||
lambda { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError)
|
||||
-> { Complex(20).fdiv(2) }.should_not raise_error(TypeError)
|
||||
-> { Complex(20).fdiv(2.0) }.should_not raise_error(TypeError)
|
||||
-> { Complex(20).fdiv(bignum_value) }.should_not raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "accepts a negative numeric argument" do
|
||||
lambda { Complex(20).fdiv(-2) }.should_not raise_error(TypeError)
|
||||
lambda { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError)
|
||||
lambda { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError)
|
||||
-> { Complex(20).fdiv(-2) }.should_not raise_error(TypeError)
|
||||
-> { Complex(20).fdiv(-2.0) }.should_not raise_error(TypeError)
|
||||
-> { Complex(20).fdiv(-bignum_value) }.should_not raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "raises a TypeError if passed a non-numeric argument" do
|
||||
lambda { Complex(20).fdiv([]) }.should raise_error(TypeError)
|
||||
lambda { Complex(20).fdiv(:sym) }.should raise_error(TypeError)
|
||||
lambda { Complex(20).fdiv('s') }.should raise_error(TypeError)
|
||||
-> { Complex(20).fdiv([]) }.should raise_error(TypeError)
|
||||
-> { Complex(20).fdiv(:sym) }.should raise_error(TypeError)
|
||||
-> { Complex(20).fdiv('s') }.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "sets the real part to NaN if self's real part is NaN" do
|
||||
|
|
|
@ -6,7 +6,7 @@ describe "Complex#negative?" do
|
|||
|
||||
c.methods.should_not include(:negative?)
|
||||
|
||||
lambda {
|
||||
-> {
|
||||
c.negative?
|
||||
}.should raise_error(NoMethodError)
|
||||
end
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue