Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7906a102779f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 767c13b0f36d
Choose a head ref
  • 2 commits
  • 521 files changed
  • 1 contributor

Commits on Mar 24, 2015

  1. Squashed 'spec/ruby/' changes from 2e07d5c..19ff319

    19ff319 Dir#close no longer raises an IOError if already closed
    88b128c Revert "filesystem encoding is fixed on Windows and Darwin"
    d3dc4c7 fix indentation
    8bad4cf Fix a couple version guards to be simpler.
    d098f8d Removed outdated version guards in language.
    ee056dc Removed outdated version guards in core.
    3ceb9ae Remove old rational library specs.
    7454d72 Remove outdated complex library specs.
    750c6f5 Removed outdated version guards.
    6fd11ee Restore ruby_bug guard #8342 as it is not yet fixed.
    24a9aec Restore ruby_bug guard #10894 as it is not yet fixed.
    29da602 Remove outdated ruby_bug in commented code.
    2ec6fc2 Remove ruby_bug guards for ruby <= 2.0.
    96205bd Fix the encoding the e acute in Dir#pwd spec.
    22b206d filesystem encoding is fixed on Windows and Darwin
    01ec347 RuntimeError is correct
    d56d83a Fix references to methods not defined on Object but on Kernel.
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 19ff31914df0f1e653c53d0909ae300382c2b60a
    eregon committed Mar 24, 2015
    Copy the full SHA
    4eaa190 View commit details
  2. Copy the full SHA
    767c13b View commit details
Showing 521 changed files with 4,256 additions and 9,073 deletions.
10 changes: 4 additions & 6 deletions spec/ruby/core/argf/close_spec.rb
Original file line number Diff line number Diff line change
@@ -26,12 +26,10 @@

ruby_version_is ""..."2.3" do
# This passes on 1.9 and 1.8 HEAD, but fails on 1.8.7 and 1.8.6
ruby_bug "#1633", "1.8.7.174" do
it "raises an IOError if called on a closed stream" do
argv [@file1_name] do
lambda { ARGF.close }.should_not raise_error
lambda { ARGF.close }.should raise_error(IOError)
end
it "raises an IOError if called on a closed stream" do
argv [@file1_name] do
lambda { ARGF.close }.should_not raise_error
lambda { ARGF.close }.should raise_error(IOError)
end
end
end
16 changes: 7 additions & 9 deletions spec/ruby/core/argf/lineno_spec.rb
Original file line number Diff line number Diff line change
@@ -26,15 +26,13 @@
end
end

ruby_bug "#1693", "1.8" do
it "resets to 0 after the stream is rewound" do
argv [@file1, @file2, @file1, @file2] do
ARGF.lineno = 0
ARGF.lineno.should == 0
ARGF.readline
ARGF.rewind
ARGF.lineno.should == 0
end
it "resets to 0 after the stream is rewound" do
argv [@file1, @file2, @file1, @file2] do
ARGF.lineno = 0
ARGF.lineno.should == 0
ARGF.readline
ARGF.rewind
ARGF.lineno.should == 0
end
end

16 changes: 7 additions & 9 deletions spec/ruby/core/argf/rewind_spec.rb
Original file line number Diff line number Diff line change
@@ -28,15 +28,13 @@
end
end

ruby_bug "#1693", "1.8" do
it "resets ARGF.lineno to 0" do
argv [@file2_name] do
ARGF.lineno = 0
ARGF.gets;
ARGF.lineno.should > 0
ARGF.rewind;
ARGF.lineno.should == 0
end
it "resets ARGF.lineno to 0" do
argv [@file2_name] do
ARGF.lineno = 0
ARGF.gets;
ARGF.lineno.should > 0
ARGF.rewind;
ARGF.lineno.should == 0
end
end

28 changes: 12 additions & 16 deletions spec/ruby/core/array/comparison_spec.rb
Original file line number Diff line number Diff line change
@@ -64,21 +64,19 @@
(lhs <=> rhs).should == +1
end

ruby_bug "#", "1.8.6.277" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty <=> empty).should == 0
(empty <=> []).should == 1
([] <=> empty).should == -1
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty <=> empty).should == 0
(empty <=> []).should == 1
([] <=> empty).should == -1

(ArraySpecs.recursive_array <=> []).should == 1
([] <=> ArraySpecs.recursive_array).should == -1
(ArraySpecs.recursive_array <=> []).should == 1
([] <=> ArraySpecs.recursive_array).should == -1

(ArraySpecs.recursive_array <=> ArraySpecs.empty_recursive_array).should == nil
(ArraySpecs.recursive_array <=> ArraySpecs.empty_recursive_array).should == nil

array = ArraySpecs.recursive_array
(array <=> array).should == 0
end
array = ArraySpecs.recursive_array
(array <=> array).should == 0
end

it "tries to convert the passed argument to an Array using #to_ary" do
@@ -93,9 +91,7 @@
([5, 6, 7] <=> obj).should == 0
end

ruby_bug "redmine:2276", "1.9.1" do
it "returns nil when the argument is not array-like" do
([] <=> false).should be_nil
end
it "returns nil when the argument is not array-like" do
([] <=> false).should be_nil
end
end
54 changes: 22 additions & 32 deletions spec/ruby/core/array/fill_spec.rb
Original file line number Diff line number Diff line change
@@ -54,9 +54,7 @@
it "raises an ArgumentError if 4 or more arguments are passed when no block given" do
lambda { [].fill('a') }.should_not raise_error(ArgumentError)

ruby_bug "#", "1.8.6.277" do
lambda { [].fill('a', 1) }.should_not raise_error(ArgumentError)
end
lambda { [].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)
@@ -69,9 +67,7 @@
it "raises an ArgumentError if 3 or more arguments are passed when a block given" do
lambda { [].fill() {|i|} }.should_not raise_error(ArgumentError)

ruby_bug "#", "1.8.6.277" do
lambda { [].fill(1) {|i|} }.should_not raise_error(ArgumentError)
end
lambda { [].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)
@@ -163,41 +159,35 @@
[1, 2, 3, 4, 5].fill('a', 2, 0).should == [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5].fill('a', -2, 0).should == [1, 2, 3, 4, 5]

ruby_bug "#", "1.8.6.277" do
[1, 2, 3, 4, 5].fill('a', 2, -2).should == [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5].fill('a', -2, -2).should == [1, 2, 3, 4, 5]
end
[1, 2, 3, 4, 5].fill('a', 2, -2).should == [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5].fill('a', -2, -2).should == [1, 2, 3, 4, 5]

[1, 2, 3, 4, 5].fill(2, 0, &@never_passed).should == [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5].fill(-2, 0, &@never_passed).should == [1, 2, 3, 4, 5]

ruby_bug "#", "1.8.6.277" do
[1, 2, 3, 4, 5].fill(2, -2, &@never_passed).should == [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5].fill(-2, -2, &@never_passed).should == [1, 2, 3, 4, 5]
end
[1, 2, 3, 4, 5].fill(2, -2, &@never_passed).should == [1, 2, 3, 4, 5]
[1, 2, 3, 4, 5].fill(-2, -2, &@never_passed).should == [1, 2, 3, 4, 5]
end

ruby_bug "#", "1.8.6.277" 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)
# 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)

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)
end
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)
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)
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)

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)
end
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)
end

it "tries to convert the second and third arguments to Integers using #to_int" do
42 changes: 19 additions & 23 deletions spec/ruby/core/array/hash_spec.rb
Original file line number Diff line number Diff line change
@@ -11,33 +11,29 @@
end
end

ruby_bug "#", "1.8.6.277" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty.hash.should be_kind_of(Fixnum)
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty.hash.should be_kind_of(Fixnum)

array = ArraySpecs.recursive_array
array.hash.should be_kind_of(Fixnum)
end
array = ArraySpecs.recursive_array
array.hash.should be_kind_of(Fixnum)
end

ruby_bug "redmine #1852", "1.9.1" do
it "returns the same hash for equal recursive arrays" do
rec = []; rec << rec
rec.hash.should == [rec].hash
rec.hash.should == [[rec]].hash
# This is because rec.eql?([[rec]])
# Remember that if two objects are eql?
# then the need to have the same hash
# Check the Array#eql? specs!
end
it "returns the same hash for equal recursive arrays" do
rec = []; rec << rec
rec.hash.should == [rec].hash
rec.hash.should == [[rec]].hash
# This is because rec.eql?([[rec]])
# Remember that if two objects are eql?
# then the need to have the same hash
# Check the Array#eql? specs!
end

it "returns the same hash for equal recursive arrays through hashes" do
h = {} ; rec = [h] ; h[:x] = rec
rec.hash.should == [h].hash
rec.hash.should == [{:x => rec}].hash
# Like above, this is because rec.eql?([{:x => rec}])
end
it "returns the same hash for equal recursive arrays through hashes" do
h = {} ; rec = [h] ; h[:x] = rec
rec.hash.should == [h].hash
rec.hash.should == [{:x => rec}].hash
# Like above, this is because rec.eql?([{:x => rec}])
end

# Too much of an implementation detail? -rue
14 changes: 6 additions & 8 deletions spec/ruby/core/array/intersection_spec.rb
Original file line number Diff line number Diff line change
@@ -23,16 +23,14 @@
a.should == [1, 1, 3, 5]
end

ruby_bug "ruby-core #1448", "1.9.1" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty & empty).should == empty
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty & empty).should == empty

(ArraySpecs.recursive_array & []).should == []
([] & ArraySpecs.recursive_array).should == []
(ArraySpecs.recursive_array & []).should == []
([] & ArraySpecs.recursive_array).should == []

(ArraySpecs.recursive_array & ArraySpecs.recursive_array).should == [1, 'two', 3.0, ArraySpecs.recursive_array]
end
(ArraySpecs.recursive_array & ArraySpecs.recursive_array).should == [1, 'two', 3.0, ArraySpecs.recursive_array]
end

it "tries to convert the passed argument to an Array using #to_ary" do
14 changes: 6 additions & 8 deletions spec/ruby/core/array/minus_spec.rb
Original file line number Diff line number Diff line change
@@ -12,16 +12,14 @@
([1, 1, 2, 2, 3, 3, 4, 5] - [1, 2, 4]).should == [3, 3, 5]
end

ruby_bug "#", "1.8.6.277" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty - empty).should == []
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty - empty).should == []

([] - ArraySpecs.recursive_array).should == []
([] - ArraySpecs.recursive_array).should == []

array = ArraySpecs.recursive_array
(array - array).should == []
end
array = ArraySpecs.recursive_array
(array - array).should == []
end

it "tries to convert the passed arguments to Arrays using #to_ary" do
6 changes: 2 additions & 4 deletions spec/ruby/core/array/pack/m_spec.rb
Original file line number Diff line number Diff line change
@@ -179,10 +179,8 @@
[1.0].pack("M").should == "1.0=\n"
end

ruby_bug "#3273", "1.8.7" do
it "converts Floats to the minimum unique representation" do
[1.0 / 3.0].pack("M").should == "0.3333333333333333=\n"
end
it "converts Floats to the minimum unique representation" do
[1.0 / 3.0].pack("M").should == "0.3333333333333333=\n"
end

it "sets the output string to US-ASCII encoding" do
76 changes: 8 additions & 68 deletions spec/ruby/core/array/pack/shared/float.rb
Original file line number Diff line number Diff line change
@@ -13,23 +13,8 @@
[8].pack(pack_format).should == "\x00\x00\x00A"
end

ruby_version_is ""..."1.9" do
it "converts a String representation of a floating point number to a Float" do
["13"].pack(pack_format).should == "\x00\x00PA"
end

it "calls #to_f to convert an object to a float" do
obj = mock("pack float")
obj.should_receive(:to_f).and_return(7.2)

[obj].pack(pack_format).should == "ff\xe6@"
end
end

ruby_version_is "1.9" do
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
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)
end

it "encodes the number of array elements specified by the count modifier" do
@@ -90,23 +75,8 @@
[8].pack(pack_format).should == "A\x00\x00\x00"
end

ruby_version_is ""..."1.9" do
it "converts a String representation of a floating point number to a Float" do
["13"].pack(pack_format).should == "AP\x00\x00"
end

it "calls #to_f to convert an object to a float" do
obj = mock("pack float")
obj.should_receive(:to_f).and_return(7.2)

[obj].pack(pack_format).should == "@\xe6ff"
end
end

ruby_version_is "1.9" do
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
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)
end

it "encodes the number of array elements specified by the count modifier" do
@@ -167,23 +137,8 @@
[8].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\x20@"
end

ruby_version_is ""..."1.9" do
it "converts a String representation of a floating point number to a Float" do
["13"].pack(pack_format).should == "\x00\x00\x00\x00\x00\x00\x2a@"
end

it "calls #to_f to convert an object to a float" do
obj = mock("pack float")
obj.should_receive(:to_f).and_return(7.2)

[obj].pack(pack_format).should == "\xcd\xcc\xcc\xcc\xcc\xcc\x1c@"
end
end

ruby_version_is "1.9" do
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
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)
end

it "encodes the number of array elements specified by the count modifier" do
@@ -244,23 +199,8 @@
[8].pack(pack_format).should == "@\x20\x00\x00\x00\x00\x00\x00"
end

ruby_version_is ""..."1.9" do
it "converts a String representation of a floating point number to a Float" do
["13"].pack(pack_format).should == "@\x2a\x00\x00\x00\x00\x00\x00"
end

it "calls #to_f to convert an object to a float" do
obj = mock("pack float")
obj.should_receive(:to_f).and_return(7.2)

[obj].pack(pack_format).should == "@\x1c\xcc\xcc\xcc\xcc\xcc\xcd"
end
end

ruby_version_is "1.9" do
it "raises a TypeError if passed a String representation of a floating point number" do
lambda { ["13"].pack(pack_format) }.should raise_error(TypeError)
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)
end

it "encodes the number of array elements specified by the count modifier" do
42 changes: 20 additions & 22 deletions spec/ruby/core/array/sample_spec.rb
Original file line number Diff line number Diff line change
@@ -112,33 +112,31 @@
end

describe "when the object returned by #rand is not a Fixnum but responds to #to_int" do
ruby_bug "GH-379", "2.0.0.322" do
it "calls #to_int on the Object" do
value = mock("array_sample_random_value")
value.should_receive(:to_int).and_return(1)
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)
it "calls #to_int on the Object" do
value = mock("array_sample_random_value")
value.should_receive(:to_int).and_return(1)
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)

[1, 2].sample(:random => random).should == 2
end
[1, 2].sample(:random => random).should == 2
end

it "raises a RangeError if the value is less than zero" do
value = mock("array_sample_random_value")
value.should_receive(:to_int).and_return(-1)
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)
it "raises a RangeError if the value is less than zero" do
value = mock("array_sample_random_value")
value.should_receive(:to_int).and_return(-1)
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)

lambda { [1, 2].sample(:random => random) }.should raise_error(RangeError)
end
lambda { [1, 2].sample(:random => random) }.should raise_error(RangeError)
end

it "raises a RangeError if the value is equal to the Array size" do
value = mock("array_sample_random_value")
value.should_receive(:to_int).and_return(2)
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)
it "raises a RangeError if the value is equal to the Array size" do
value = mock("array_sample_random_value")
value.should_receive(:to_int).and_return(2)
random = mock("array_sample_random")
random.should_receive(:rand).and_return(value)

lambda { [1, 2].sample(:random => random) }.should raise_error(RangeError)
end
lambda { [1, 2].sample(:random => random) }.should raise_error(RangeError)
end
end
end
90 changes: 44 additions & 46 deletions spec/ruby/core/array/shared/eql.rb
Original file line number Diff line number Diff line change
@@ -25,52 +25,50 @@
[obj] .send(@method, [] ).should be_false
end

ruby_bug "ruby-core #1448", "1.9.1" do
it "handles well recursive arrays" do
a = ArraySpecs.empty_recursive_array
a .send(@method, [a] ).should be_true
a .send(@method, [[a]] ).should be_true
[a] .send(@method, a ).should be_true
[[a]] .send(@method, a ).should be_true
# These may be surprising, but no difference can be
# found between these arrays, so they are ==.
# There is no "path" that will lead to a difference
# (contrary to other examples below)

a2 = ArraySpecs.empty_recursive_array
a .send(@method, a2 ).should be_true
a .send(@method, [a2] ).should be_true
a .send(@method, [[a2]] ).should be_true
[a] .send(@method, a2 ).should be_true
[[a]] .send(@method, a2 ).should be_true

back = []
forth = [back]; back << forth;
back .send(@method, a ).should be_true

x = []; x << x << x
x .send(@method, a ).should be_false # since x.size != a.size
x .send(@method, [a, a] ).should be_false # since x[0].size != [a, a][0].size
x .send(@method, [x, a] ).should be_false # since x[1].size != [x, a][1].size
[x, a] .send(@method, [a, x] ).should be_false # etc...
x .send(@method, [x, x] ).should be_true
x .send(@method, [[x, x], [x, x]] ).should be_true

tree = [];
branch = []; branch << tree << tree; tree << branch
tree2 = [];
branch2 = []; branch2 << tree2 << tree2; tree2 << branch2
forest = [tree, branch, :bird, a]; forest << forest
forest2 = [tree2, branch2, :bird, a2]; forest2 << forest2

forest .send(@method, forest2 ).should be_true
forest .send(@method, [tree2, branch, :bird, a, forest2]).should be_true

diffforest = [branch2, tree2, :bird, a2]; diffforest << forest2
forest .send(@method, diffforest ).should be_false # since forest[0].size == 1 != 3 == diffforest[0]
forest .send(@method, [nil] ).should be_false
forest .send(@method, [forest] ).should be_false
end
it "handles well recursive arrays" do
a = ArraySpecs.empty_recursive_array
a .send(@method, [a] ).should be_true
a .send(@method, [[a]] ).should be_true
[a] .send(@method, a ).should be_true
[[a]] .send(@method, a ).should be_true
# These may be surprising, but no difference can be
# found between these arrays, so they are ==.
# There is no "path" that will lead to a difference
# (contrary to other examples below)

a2 = ArraySpecs.empty_recursive_array
a .send(@method, a2 ).should be_true
a .send(@method, [a2] ).should be_true
a .send(@method, [[a2]] ).should be_true
[a] .send(@method, a2 ).should be_true
[[a]] .send(@method, a2 ).should be_true

back = []
forth = [back]; back << forth;
back .send(@method, a ).should be_true

x = []; x << x << x
x .send(@method, a ).should be_false # since x.size != a.size
x .send(@method, [a, a] ).should be_false # since x[0].size != [a, a][0].size
x .send(@method, [x, a] ).should be_false # since x[1].size != [x, a][1].size
[x, a] .send(@method, [a, x] ).should be_false # etc...
x .send(@method, [x, x] ).should be_true
x .send(@method, [[x, x], [x, x]] ).should be_true

tree = [];
branch = []; branch << tree << tree; tree << branch
tree2 = [];
branch2 = []; branch2 << tree2 << tree2; tree2 << branch2
forest = [tree, branch, :bird, a]; forest << forest
forest2 = [tree2, branch2, :bird, a2]; forest2 << forest2

forest .send(@method, forest2 ).should be_true
forest .send(@method, [tree2, branch, :bird, a, forest2]).should be_true

diffforest = [branch2, tree2, :bird, a2]; diffforest << forest2
forest .send(@method, diffforest ).should be_false # since forest[0].size == 1 != 3 == diffforest[0]
forest .send(@method, [nil] ).should be_false
forest .send(@method, [forest] ).should be_false
end

it "does not call #to_ary on its argument" do
12 changes: 4 additions & 8 deletions spec/ruby/core/array/shared/join.rb
Original file line number Diff line number Diff line change
@@ -132,10 +132,8 @@ class << obj; undef :to_s; end
[].send(@method, @sep).tainted?.should be_false
end

ruby_bug "5902", "2.0" do
it "does not taint the result if the array has only one element" do
[1].send(@method, @sep).tainted?.should be_false
end
it "does not taint the result if the array has only one element" do
[1].send(@method, @sep).tainted?.should be_false
end

it "taints the result if the array has two or more elements" do
@@ -152,10 +150,8 @@ class << obj; undef :to_s; end
[].send(@method, @sep).untrusted?.should be_false
end

ruby_bug "5902", "2.0" do
it "does not untrust the result if the array has only one element" do
[1].send(@method, @sep).untrusted?.should be_false
end
it "does not untrust the result if the array has only one element" do
[1].send(@method, @sep).untrusted?.should be_false
end

it "untrusts the result if the array has two or more elements" do
18 changes: 8 additions & 10 deletions spec/ruby/core/array/union_spec.rb
Original file line number Diff line number Diff line change
@@ -17,17 +17,15 @@
([ 1, 2, 3, 1 ] | [ 1, 3, 4, 5 ]).should == [1, 2, 3, 4, 5]
end

ruby_bug "#", "1.8.6.277" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty | empty).should == empty
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
(empty | empty).should == empty

array = ArraySpecs.recursive_array
(array | []).should == [1, 'two', 3.0, array]
([] | array).should == [1, 'two', 3.0, array]
(array | array).should == [1, 'two', 3.0, array]
(array | empty).should == [1, 'two', 3.0, array, empty]
end
array = ArraySpecs.recursive_array
(array | []).should == [1, 'two', 3.0, array]
([] | array).should == [1, 'two', 3.0, array]
(array | array).should == [1, 'two', 3.0, array]
(array | empty).should == [1, 'two', 3.0, array, empty]
end

it "tries to convert the passed argument to an Array using #to_ary" do
32 changes: 14 additions & 18 deletions spec/ruby/core/array/uniq_spec.rb
Original file line number Diff line number Diff line change
@@ -6,14 +6,12 @@
["a", "a", "b", "b", "c"].uniq.should == ["a", "b", "c"]
end

ruby_bug "#", "1.8.6.277" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty.uniq.should == [empty]
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty.uniq.should == [empty]

array = ArraySpecs.recursive_array
array.uniq.should == [1, 'two', 3.0, array]
end
array = ArraySpecs.recursive_array
array.uniq.should == [1, 'two', 3.0, array]
end

it "uses eql? semantics" do
@@ -114,18 +112,16 @@ def self.eql?(o) taint; o.taint; true; end
a.should equal(a.uniq!)
end

ruby_bug "#", "1.8.6.277" do
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty_dup = empty.dup
empty.uniq!
empty.should == empty_dup
it "properly handles recursive arrays" do
empty = ArraySpecs.empty_recursive_array
empty_dup = empty.dup
empty.uniq!
empty.should == empty_dup

array = ArraySpecs.recursive_array
expected = array[0..3]
array.uniq!
array.should == expected
end
array = ArraySpecs.recursive_array
expected = array[0..3]
array.uniq!
array.should == expected
end

it "returns nil if no changes are made to the array" do
24 changes: 10 additions & 14 deletions spec/ruby/core/bignum/comparison_spec.rb
Original file line number Diff line number Diff line change
@@ -130,23 +130,19 @@
end

# The tests below are taken from matz's revision 23730 for Ruby trunk
ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.7.334" do
it "returns 1 when self is Infinity and other is a Bignum" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end
it "returns 1 when self is Infinity and other is a Bignum" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end

it "returns -1 when self is negative and other is Infinty" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end
it "returns -1 when self is negative and other is Infinty" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end

ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.7.302" do
it "returns 1 when self is negative and other is -Infinity" do
(-Float::MAX.to_i*2 <=> -infinity_value).should == 1
end
it "returns 1 when self is negative and other is -Infinity" do
(-Float::MAX.to_i*2 <=> -infinity_value).should == 1
end

it "returns -1 when self is -Infinity and other is negative" do
(-infinity_value <=> -Float::MAX.to_i*2).should == -1
end
it "returns -1 when self is -Infinity and other is negative" do
(-infinity_value <=> -Float::MAX.to_i*2).should == -1
end
end
36 changes: 5 additions & 31 deletions spec/ruby/core/comparable/equal_value_spec.rb
Original file line number Diff line number Diff line change
@@ -40,16 +40,8 @@
a.should_receive(:<=>).once.and_return(nil)
end

ruby_version_is ""..."1.9" do
it "returns nil" do
(a == b).should == nil
end
end

ruby_version_is "1.9" do
it "returns false" do
(a == b).should be_false
end
it "returns false" do
(a == b).should be_false
end
end

@@ -58,13 +50,7 @@
a.should_receive(:<=>).once.and_return("abc")
end

ruby_version_is ""..."1.9" do
it "returns nil" do
(a == b).should == nil
end
end

ruby_version_is "1.9"...no_silent_rescue do
ruby_version_is ""...no_silent_rescue do
it "returns false" do
(a == b).should be_false
end
@@ -83,13 +69,7 @@
a.should_receive(:<=>).once.and_raise(StandardError)
end

ruby_version_is ""..."1.9" do
it "returns nil" do
(a == b).should == nil
end
end

ruby_version_is "1.9"...no_silent_rescue do
ruby_version_is ""...no_silent_rescue do
# Behaviour confirmed by MRI test suite
it "returns false" do
(a == b).should be_false
@@ -109,13 +89,7 @@
a.should_receive(:<=>).once.and_raise(TypeError)
end

ruby_version_is ""..."1.9" do
it "returns nil" do
(a == b).should == nil
end
end

ruby_version_is "1.9"...no_silent_rescue do
ruby_version_is ""...no_silent_rescue do
it "returns false" do
(a == b).should be_false
end
10 changes: 4 additions & 6 deletions spec/ruby/core/complex/rationalize_spec.rb
Original file line number Diff line number Diff line change
@@ -12,12 +12,10 @@
Complex(2<<63+5).rationalize.should == Rational(2<<63+5,1)
end

ruby_bug "redmine #5178", "1.9.3.0" do
it "sends #rationalize to the real part" do
real = mock_numeric('real')
real.should_receive(:rationalize).with(0.1).and_return(:result)
Complex(real, 0).rationalize(0.1).should == :result
end
it "sends #rationalize to the real part" do
real = mock_numeric('real')
real.should_receive(:rationalize).with(0.1).and_return(:result)
Complex(real, 0).rationalize(0.1).should == :result
end

it "ignores a single argument" do
18 changes: 16 additions & 2 deletions spec/ruby/core/dir/close_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/common', __FILE__)
require File.expand_path('../shared/closed', __FILE__)
ruby_version_is ''...'2.3' do
require File.expand_path('../shared/closed', __FILE__)
end

describe "Dir#close" do
before :all do
@@ -11,5 +13,17 @@
DirSpecs.delete_mock_dirs
end

it_behaves_like :dir_closed, :close
ruby_version_is ''...'2.3' do
it_behaves_like :dir_closed, :close
end

ruby_version_is '2.3' do
it "does not raise an IOError even if the Dir instance is closed" do
dir = Dir.open DirSpecs.mock_dir
dir.close
lambda {
dir.close
}.should_not raise_error(IOError)
end
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/dir/pwd_spec.rb
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
DirSpecs.clear_dirs

begin
str = [0xe9].pack 'U' #Unicode é
str = [0xe9].pack 'U' # Unicode é
Dir.mkdir str
File.exist?(str).should == true

106 changes: 47 additions & 59 deletions spec/ruby/core/encoding/compatible_spec.rb
Original file line number Diff line number Diff line change
@@ -39,12 +39,10 @@
].should be_computed_by(:compatible?)
end

ruby_bug "#5968", "2.0" do
it "returns the first's Encoding if the second is ASCII compatible and ASCII only" do
[ [Encoding, "abc".force_encoding("ASCII-8BIT"), "123".force_encoding("US-ASCII"), Encoding::ASCII_8BIT],
[Encoding, "123".force_encoding("US-ASCII"), "abc".force_encoding("ASCII-8BIT"), Encoding::US_ASCII]
].should be_computed_by(:compatible?)
end
it "returns the first's Encoding if the second is ASCII compatible and ASCII only" do
[ [Encoding, "abc".force_encoding("ASCII-8BIT"), "123".force_encoding("US-ASCII"), Encoding::ASCII_8BIT],
[Encoding, "123".force_encoding("US-ASCII"), "abc".force_encoding("ASCII-8BIT"), Encoding::US_ASCII]
].should be_computed_by(:compatible?)
end

it "returns the second's Encoding if the second is ASCII compatible but not ASCII only" do
@@ -154,27 +152,25 @@
end

describe "Encoding.compatible? String, Symbol" do
ruby_bug "#5921", "1.9.3.0" do
it "returns US-ASCII if both are ASCII only" do
str = "abc".force_encoding("us-ascii")
Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
end
it "returns US-ASCII if both are ASCII only" do
str = "abc".force_encoding("us-ascii")
Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
end

it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do
[ [Encoding, "abc", Encoding::ASCII_8BIT],
[Encoding, "abc".encode("utf-8"), Encoding::UTF_8],
[Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP],
[Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS],
].should be_computed_by(:compatible?, :abc)
end
it "returns the String's Encoding if it is not US-ASCII but both are ASCII only" do
[ [Encoding, "abc", Encoding::ASCII_8BIT],
[Encoding, "abc".encode("utf-8"), Encoding::UTF_8],
[Encoding, "abc".encode("euc-jp"), Encoding::EUC_JP],
[Encoding, "abc".encode("shift_jis"), Encoding::Shift_JIS],
].should be_computed_by(:compatible?, :abc)
end

it "returns the String's Encoding if the String is not ASCII only" do
[ [Encoding, "\xff", Encoding::ASCII_8BIT],
[Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
[Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
[Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
].should be_computed_by(:compatible?, :abc)
end
it "returns the String's Encoding if the String is not ASCII only" do
[ [Encoding, "\xff", Encoding::ASCII_8BIT],
[Encoding, "\u3042".encode("utf-8"), Encoding::UTF_8],
[Encoding, "\xa4\xa2".force_encoding("euc-jp"), Encoding::EUC_JP],
[Encoding, "\x82\xa0".force_encoding("shift_jis"), Encoding::Shift_JIS],
].should be_computed_by(:compatible?, :abc)
end
end

@@ -205,23 +201,19 @@
Encoding.compatible?(/abc/, :def).should == Encoding::US_ASCII
end

ruby_bug "#5921", "1.9.3.0" do
it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do
[ [Encoding, Regexp.new("\xff"), Encoding::ASCII_8BIT],
[Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8],
[Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP],
[Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS],
].should be_computed_by(:compatible?, /abc/)
end
it "returns the first's Encoding if it is not US-ASCII and not ASCII only" do
[ [Encoding, Regexp.new("\xff"), Encoding::ASCII_8BIT],
[Encoding, Regexp.new("\u3042".encode("utf-8")), Encoding::UTF_8],
[Encoding, Regexp.new("\xa4\xa2".force_encoding("euc-jp")), Encoding::EUC_JP],
[Encoding, Regexp.new("\x82\xa0".force_encoding("shift_jis")), Encoding::Shift_JIS],
].should be_computed_by(:compatible?, /abc/)
end
end

describe "Encoding.compatible? Symbol, String" do
ruby_bug "#5921", "1.9.3.0" do
it "returns US-ASCII if both are ASCII only" do
str = "abc".force_encoding("us-ascii")
Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
end
it "returns US-ASCII if both are ASCII only" do
str = "abc".force_encoding("us-ascii")
Encoding.compatible?(str, :abc).should == Encoding::US_ASCII
end
end

@@ -230,19 +222,17 @@
Encoding.compatible?(:abc, /def/).should == Encoding::US_ASCII
end

ruby_bug "#5921", "1.9.3.0" do
it "returns the Regexp's Encoding if it is not US-ASCII and not ASCII only" do
a = Regexp.new("\xff")
b = Regexp.new("\u3042".encode("utf-8"))
c = Regexp.new("\xa4\xa2".force_encoding("euc-jp"))
d = Regexp.new("\x82\xa0".force_encoding("shift_jis"))

[ [Encoding, :abc, a, Encoding::ASCII_8BIT],
[Encoding, :abc, b, Encoding::UTF_8],
[Encoding, :abc, c, Encoding::EUC_JP],
[Encoding, :abc, d, Encoding::Shift_JIS],
].should be_computed_by(:compatible?)
end
it "returns the Regexp's Encoding if it is not US-ASCII and not ASCII only" do
a = Regexp.new("\xff")
b = Regexp.new("\u3042".encode("utf-8"))
c = Regexp.new("\xa4\xa2".force_encoding("euc-jp"))
d = Regexp.new("\x82\xa0".force_encoding("shift_jis"))

[ [Encoding, :abc, a, Encoding::ASCII_8BIT],
[Encoding, :abc, b, Encoding::UTF_8],
[Encoding, :abc, c, Encoding::EUC_JP],
[Encoding, :abc, d, Encoding::Shift_JIS],
].should be_computed_by(:compatible?)
end
end

@@ -251,14 +241,12 @@
Encoding.compatible?(:abc, :def).should == Encoding::US_ASCII
end

ruby_bug "#5921", "1.9.3.0" do
it "returns the first's Encoding if it is not ASCII only" do
[ [Encoding, "\xff".to_sym, Encoding::ASCII_8BIT],
[Encoding, "\u3042".encode("utf-8").to_sym, Encoding::UTF_8],
[Encoding, "\xa4\xa2".force_encoding("euc-jp").to_sym, Encoding::EUC_JP],
[Encoding, "\x82\xa0".force_encoding("shift_jis").to_sym, Encoding::Shift_JIS],
].should be_computed_by(:compatible?, :abc)
end
it "returns the first's Encoding if it is not ASCII only" do
[ [Encoding, "\xff".to_sym, Encoding::ASCII_8BIT],
[Encoding, "\u3042".encode("utf-8").to_sym, Encoding::UTF_8],
[Encoding, "\xa4\xa2".force_encoding("euc-jp").to_sym, Encoding::EUC_JP],
[Encoding, "\x82\xa0".force_encoding("shift_jis").to_sym, Encoding::Shift_JIS],
].should be_computed_by(:compatible?, :abc)
end
end

16 changes: 7 additions & 9 deletions spec/ruby/core/enumerable/shared/take.rb
Original file line number Diff line number Diff line change
@@ -52,14 +52,12 @@
multi.send(@method, 1).should == [[1, 2]]
end

ruby_bug "#1554", "1.9.1" do
it "consumes only what is needed" do
thrower = EnumerableSpecs::ThrowingEach.new
thrower.send(@method, 0).should == []
counter = EnumerableSpecs::EachCounter.new(1,2,3,4)
counter.send(@method, 2).should == [1,2]
counter.times_called.should == 1
counter.times_yielded.should == 2
end
it "consumes only what is needed" do
thrower = EnumerableSpecs::ThrowingEach.new
thrower.send(@method, 0).should == []
counter = EnumerableSpecs::EachCounter.new(1,2,3,4)
counter.send(@method, 2).should == [1,2]
counter.times_called.should == 1
counter.times_yielded.should == 2
end
end
10 changes: 4 additions & 6 deletions spec/ruby/core/enumerator/lazy/zip_spec.rb
Original file line number Diff line number Diff line change
@@ -33,12 +33,10 @@
end
end

ruby_bug "#8735", "2.0.0.305" do
it "calls the block with a gathered array when yield with multiple arguments" do
yields = @yieldsmixed.zip(EnumeratorLazySpecs::YieldsMixed.new.to_enum).force
yields.should == [EnumeratorLazySpecs::YieldsMixed.gathered_yields,
EnumeratorLazySpecs::YieldsMixed.gathered_yields].transpose
end
it "calls the block with a gathered array when yield with multiple arguments" do
yields = @yieldsmixed.zip(EnumeratorLazySpecs::YieldsMixed.new.to_enum).force
yields.should == [EnumeratorLazySpecs::YieldsMixed.gathered_yields,
EnumeratorLazySpecs::YieldsMixed.gathered_yields].transpose
end

it "returns a Lazy when no arguments given" do
10 changes: 4 additions & 6 deletions spec/ruby/core/file/join_spec.rb
Original file line number Diff line number Diff line change
@@ -101,12 +101,10 @@
end

# TODO: See MRI svn r23306. Add patchlevel when there is a release.
ruby_bug "redmine #1418", "1.8.8" do
it "raises an ArgumentError if passed a recursive array" do
a = ["a"]
a << a
lambda { File.join a }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if passed a recursive array" do
a = ["a"]
a << a
lambda { File.join a }.should raise_error(ArgumentError)
end

it "raises a TypeError exception when args are nil" do
20 changes: 9 additions & 11 deletions spec/ruby/core/file/new_spec.rb
Original file line number Diff line number Diff line change
@@ -97,18 +97,16 @@
File.exist?(@file).should == true
end

ruby_bug "[ruby-dev:40397]", "1.8.8" do
it "returns a new File when use File::APPEND mode" do
@fh = File.new(@file, File::APPEND)
@fh.should be_kind_of(File)
File.exist?(@file).should == true
end
it "returns a new File when use File::APPEND mode" do
@fh = File.new(@file, File::APPEND)
@fh.should be_kind_of(File)
File.exist?(@file).should == true
end

it "returns a new File when use File::RDONLY|File::APPEND mode" do
@fh = File.new(@file, File::RDONLY|File::APPEND)
@fh.should be_kind_of(File)
File.exist?(@file).should == true
end
it "returns a new File when use File::RDONLY|File::APPEND mode" do
@fh = File.new(@file, File::RDONLY|File::APPEND)
@fh.should be_kind_of(File)
File.exist?(@file).should == true
end

it "returns a new File when use File::RDONLY|File::WRONLY mode" do
90 changes: 37 additions & 53 deletions spec/ruby/core/file/open_spec.rb
Original file line number Diff line number Diff line change
@@ -158,23 +158,13 @@
@fh = File.open(@file)
@fh.should be_kind_of(File)

ruby_version_is ''...'2.0' do
lambda {
File.open(@fh.fileno) do |fh|
@fd = fh.fileno
@fh.close
end
lambda { File.open(@fd) }.should raise_error(SystemCallError)
end

ruby_version_is '2.0' do
lambda {
File.open(@fh.fileno) do |fh|
@fd = fh.fileno
@fh.close
end
}.should raise_error(Errno::EBADF)
lambda { File.open(@fd) }.should raise_error(SystemCallError)
end
}.should raise_error(Errno::EBADF)
lambda { File.open(@fd) }.should raise_error(SystemCallError)

File.exist?(@file).should == true
end
@@ -326,14 +316,12 @@
end
end

ruby_bug "#", "1.8.7.299" do
it "raises an IOError when read in a block opened with File::RDONLY|File::APPEND mode" do
lambda {
File.open(@file, File::RDONLY|File::APPEND ) do |f|
f.puts("writing")
end
}.should raise_error(IOError)
end
it "raises an IOError when read in a block opened with File::RDONLY|File::APPEND mode" do
lambda {
File.open(@file, File::RDONLY|File::APPEND ) do |f|
f.puts("writing")
end
}.should raise_error(IOError)
end

it "can read and write in a block when call open with RDWR mode" do
@@ -395,14 +383,12 @@
end
end

ruby_bug "#", "1.8.7.299" do
it "raises an IOError if the file exists when open with File::RDONLY|File::APPEND" do
lambda {
File.open(@file, File::RDONLY|File::APPEND) do |f|
f.puts("writing").should == nil
end
}.should raise_error(IOError)
end
it "raises an IOError if the file exists when open with File::RDONLY|File::APPEND" do
lambda {
File.open(@file, File::RDONLY|File::APPEND) do |f|
f.puts("writing").should == nil
end
}.should raise_error(IOError)
end

platform_is_not :openbsd do
@@ -559,35 +545,33 @@
end

platform_is_not :windows do
ruby_bug '#7908', '1.8.7' do
describe "on a FIFO" do
before :each do
@fifo = tmp("File_open_fifo")
system "mkfifo #{@fifo}"
end
describe "on a FIFO" do
before :each do
@fifo = tmp("File_open_fifo")
system "mkfifo #{@fifo}"
end

after :each do
rm_r @fifo
end
after :each do
rm_r @fifo
end

it "opens it as a normal file" do
file_w, file_r, read_bytes, written_length = nil
it "opens it as a normal file" do
file_w, file_r, read_bytes, written_length = nil

# open in threads, due to blocking open and writes
Thread.new do
file_w = File.open(@fifo, 'w')
written_length = file_w.syswrite('hello')
end
Thread.new do
file_r = File.open(@fifo, 'r')
read_bytes = file_r.sysread(5)
end
# open in threads, due to blocking open and writes
Thread.new do
file_w = File.open(@fifo, 'w')
written_length = file_w.syswrite('hello')
end
Thread.new do
file_r = File.open(@fifo, 'r')
read_bytes = file_r.sysread(5)
end

Thread.pass until read_bytes && written_length
Thread.pass until read_bytes && written_length

written_length.should == 5
read_bytes.should == 'hello'
end
written_length.should == 5
read_bytes.should == 'hello'
end
end
end
10 changes: 4 additions & 6 deletions spec/ruby/core/fixnum/element_reference_spec.rb
Original file line number Diff line number Diff line change
@@ -49,13 +49,11 @@
lambda { 3[obj] }.should raise_error(TypeError)
end

ruby_bug "#", "1.8.6" do # Fixed at MRI 1.8.7
it "calls #to_int to coerce a String to a Bignum and returns 0" do
obj = mock('bignum value')
obj.should_receive(:to_int).and_return(bignum_value())
it "calls #to_int to coerce a String to a Bignum and returns 0" do
obj = mock('bignum value')
obj.should_receive(:to_int).and_return(bignum_value())

3[obj].should == 0
end
3[obj].should == 0
end

it "returns 0 when passed a Float in the range of a Bignum" do
72 changes: 34 additions & 38 deletions spec/ruby/core/float/comparison_spec.rb
Original file line number Diff line number Diff line change
@@ -17,43 +17,39 @@
end

# TODO: Remove duplicate ruby_bug guards when ruby_bug is fixed.
ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.7" do
# The 4 tests below are taken from matz's revision 23730 for Ruby trunk
#
it "returns 1 when self is Infinity and other is a Bignum" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end

it "returns -1 when self is negative and other is Infinty" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end

it "returns -1 when self is -Infinity and other is negative" do
(-infinity_value <=> -Float::MAX.to_i*2).should == -1
end

it "returns 1 when self is negative and other is -Infinity" do
(-Float::MAX.to_i*2 <=> -infinity_value).should == 1
end
end

ruby_bug "[ruby-dev:38672] [Bug #1645]", "1.8.7.302" do
# The 4 tests below are taken from matz's revision 23730 for Ruby trunk
#
it "returns 1 when self is Infinity and other is a Bignum" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end

it "returns -1 when self is negative and other is Infinty" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end

it "returns -1 when self is -Infinity and other is negative" do
(-infinity_value <=> -Float::MAX.to_i*2).should == -1
end

it "returns 1 when self is negative and other is -Infinity" do
(-Float::MAX.to_i*2 <=> -infinity_value).should == 1
end
# The 4 tests below are taken from matz's revision 23730 for Ruby trunk
#
it "returns 1 when self is Infinity and other is a Bignum" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end

it "returns -1 when self is negative and other is Infinty" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end

it "returns -1 when self is -Infinity and other is negative" do
(-infinity_value <=> -Float::MAX.to_i*2).should == -1
end

it "returns 1 when self is negative and other is -Infinity" do
(-Float::MAX.to_i*2 <=> -infinity_value).should == 1
end

# The 4 tests below are taken from matz's revision 23730 for Ruby trunk
#
it "returns 1 when self is Infinity and other is a Bignum" do
(infinity_value <=> Float::MAX.to_i*2).should == 1
end

it "returns -1 when self is negative and other is Infinty" do
(-Float::MAX.to_i*2 <=> infinity_value).should == -1
end

it "returns -1 when self is -Infinity and other is negative" do
(-infinity_value <=> -Float::MAX.to_i*2).should == -1
end

it "returns 1 when self is negative and other is -Infinity" do
(-Float::MAX.to_i*2 <=> -infinity_value).should == 1
end
end
8 changes: 3 additions & 5 deletions spec/ruby/core/float/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -33,11 +33,9 @@
Float::MAX.should == eval("179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0")
end

ruby_bug "", "1.8.6.362" do
not_compliant_on :jruby do
it "the MIN is 2.2250738585072e-308" do
Float::MIN.should == eval("2.225073858507201383090232717332404064219215980462331830553327416887204434813918195854283159012511020564067339731035811005152434161553460108856012385377718821130777993532002330479610147442583636071921565046942503734208375250806650616658158948720491179968591639648500635908770118304874799780887753749949451580451605050915399856582470818645113537935804992115981085766051992433352114352390148795699609591288891602992641511063466313393663477586513029371762047325631781485664350872122828637642044846811407613911477062801689853244110024161447421618567166150540154285084716752901903161322778896729707373123334086988983175067838846926092773977972858659654941091369095406136467568702398678315290680984617210924625396728515625e-308")
end
not_compliant_on :jruby do
it "the MIN is 2.2250738585072e-308" do
Float::MIN.should == eval("2.225073858507201383090232717332404064219215980462331830553327416887204434813918195854283159012511020564067339731035811005152434161553460108856012385377718821130777993532002330479610147442583636071921565046942503734208375250806650616658158948720491179968591639648500635908770118304874799780887753749949451580451605050915399856582470818645113537935804992115981085766051992433352114352390148795699609591288891602992641511063466313393663477586513029371762047325631781485664350872122828637642044846811407613911477062801689853244110024161447421618567166150540154285084716752901903161322778896729707373123334086988983175067838846926092773977972858659654941091369095406136467568702398678315290680984617210924625396728515625e-308")
end
end

8 changes: 3 additions & 5 deletions spec/ruby/core/gc/profiler/enabled_spec.rb
Original file line number Diff line number Diff line change
@@ -9,11 +9,9 @@
@status ? GC::Profiler.enable : GC::Profiler.disable
end

ruby_bug "#6821", "1.9" do
it "reports as enabled when enabled" do
GC::Profiler.enable
GC::Profiler.enabled?.should be_true
end
it "reports as enabled when enabled" do
GC::Profiler.enable
GC::Profiler.enabled?.should be_true
end

it "reports as disabled when disabled" do
15 changes: 3 additions & 12 deletions spec/ruby/core/hash/constructor_spec.rb
Original file line number Diff line number Diff line change
@@ -43,18 +43,9 @@
hash_class[ary].should == new_hash(:a => :b)
end

ruby_version_is '1.8.6'...'1.8.7' do
it "raises error when elements are not arrays" do
lambda { hash_class[[:a]] }.should raise_error(ArgumentError)
lambda { hash_class[[:nil]] }.should raise_error(ArgumentError)
end
end

ruby_version_is '1.8.7' do
it "ignores elements that are not arrays" do
hash_class[[:a]].should == new_hash
hash_class[[:nil]].should == new_hash
end
it "ignores elements that are not arrays" do
hash_class[[:a]].should == new_hash
hash_class[[:nil]].should == new_hash
end

it "raises an ArgumentError for arrays of more than 2 elements" do
30 changes: 14 additions & 16 deletions spec/ruby/core/hash/hash_spec.rb
Original file line number Diff line number Diff line change
@@ -18,22 +18,20 @@
(h.hash == h[:a].hash).should == true
end

ruby_bug "redmine #1852", "1.9.1" do
it "returns the same hash for recursive hashes" do
h = {} ; h[:x] = h
h.hash.should == {:x => h}.hash
h.hash.should == {:x => {:x => h}}.hash
# This is because h.eql?(:x => h)
# Remember that if two objects are eql?
# then the need to have the same hash.
# Check the Hash#eql? specs!
end
it "returns the same hash for recursive hashes" do
h = {} ; h[:x] = h
h.hash.should == {:x => h}.hash
h.hash.should == {:x => {:x => h}}.hash
# This is because h.eql?(:x => h)
# Remember that if two objects are eql?
# then the need to have the same hash.
# Check the Hash#eql? specs!
end

it "returns the same hash for recursive hashes through arrays" do
h = {} ; rec = [h] ; h[:x] = rec
h.hash.should == {:x => rec}.hash
h.hash.should == {:x => [h]}.hash
# Like above, because h.eql?(:x => [h])
end
it "returns the same hash for recursive hashes through arrays" do
h = {} ; rec = [h] ; h[:x] = rec
h.hash.should == {:x => rec}.hash
h.hash.should == {:x => [h]}.hash
# Like above, because h.eql?(:x => [h])
end
end
78 changes: 38 additions & 40 deletions spec/ruby/core/hash/shared/eql.rb
Original file line number Diff line number Diff line change
@@ -51,47 +51,45 @@ def mock_hash.to_hash() new_hash end
new_hash.send(@method, mock_hash).should be_false
end

ruby_bug "redmine #2448", "1.9.1" do
it "computes equality for complex recursive hashes" do
a, b = {}, {}
a.merge! :self => a, :other => b
b.merge! :self => b, :other => a
a.send(@method, b).should be_true # they both have the same structure!

c = {}
c.merge! :other => c, :self => c
c.send(@method, a).should be_true # subtle, but they both have the same structure!
a[:delta] = c[:delta] = a
c.send(@method, a).should be_false # not quite the same structure, as a[:other][:delta] = nil
c[:delta] = 42
c.send(@method, a).should be_false
a[:delta] = 42
c.send(@method, a).should be_false
b[:delta] = 42
c.send(@method, a).should be_true
end
it "computes equality for complex recursive hashes" do
a, b = {}, {}
a.merge! :self => a, :other => b
b.merge! :self => b, :other => a
a.send(@method, b).should be_true # they both have the same structure!

c = {}
c.merge! :other => c, :self => c
c.send(@method, a).should be_true # subtle, but they both have the same structure!
a[:delta] = c[:delta] = a
c.send(@method, a).should be_false # not quite the same structure, as a[:other][:delta] = nil
c[:delta] = 42
c.send(@method, a).should be_false
a[:delta] = 42
c.send(@method, a).should be_false
b[:delta] = 42
c.send(@method, a).should be_true
end

it "computes equality for recursive hashes & arrays" do
x, y, z = [], [], []
a, b, c = {:foo => x, :bar => 42}, {:foo => y, :bar => 42}, {:foo => z, :bar => 42}
x << a
y << c
z << b
b.send(@method, c).should be_true # they clearly have the same structure!
y.send(@method, z).should be_true
a.send(@method, b).should be_true # subtle, but they both have the same structure!
x.send(@method, y).should be_true
y << x
y.send(@method, z).should be_false
z << x
y.send(@method, z).should be_true

a[:foo], a[:bar] = a[:bar], a[:foo]
a.send(@method, b).should be_false
b[:bar] = b[:foo]
b.send(@method, c).should be_false
end
end # ruby_bug
it "computes equality for recursive hashes & arrays" do
x, y, z = [], [], []
a, b, c = {:foo => x, :bar => 42}, {:foo => y, :bar => 42}, {:foo => z, :bar => 42}
x << a
y << c
z << b
b.send(@method, c).should be_true # they clearly have the same structure!
y.send(@method, z).should be_true
a.send(@method, b).should be_true # subtle, but they both have the same structure!
x.send(@method, y).should be_true
y << x
y.send(@method, z).should be_false
z << x
y.send(@method, z).should be_true

a[:foo], a[:bar] = a[:bar], a[:foo]
a.send(@method, b).should be_false
b[:bar] = b[:foo]
b.send(@method, c).should be_false
end
end

# All these tests are true for ==, and for eql? when Ruby >= 1.8.7
74 changes: 36 additions & 38 deletions spec/ruby/core/hash/shared/equal.rb
Original file line number Diff line number Diff line change
@@ -48,45 +48,43 @@ def y.hash() 1 end
(h == h[:a]).should be_true
end

ruby_bug "redmine #2448", "1.9.1" do
it "computes equality for complex recursive hashes" do
a, b = {}, {}
a.merge! :self => a, :other => b
b.merge! :self => b, :other => a
a.send(@method, b).should be_true # they both have the same structure!
it "computes equality for complex recursive hashes" do
a, b = {}, {}
a.merge! :self => a, :other => b
b.merge! :self => b, :other => a
a.send(@method, b).should be_true # they both have the same structure!

c = {}
c.merge! :other => c, :self => c
c.send(@method, a).should be_true # subtle, but they both have the same structure!
a[:delta] = c[:delta] = a
c.send(@method, a).should be_false # not quite the same structure, as a[:other][:delta] = nil
c[:delta] = 42
c.send(@method, a).should be_false
a[:delta] = 42
c.send(@method, a).should be_false
b[:delta] = 42
c.send(@method, a).should be_true
end
c = {}
c.merge! :other => c, :self => c
c.send(@method, a).should be_true # subtle, but they both have the same structure!
a[:delta] = c[:delta] = a
c.send(@method, a).should be_false # not quite the same structure, as a[:other][:delta] = nil
c[:delta] = 42
c.send(@method, a).should be_false
a[:delta] = 42
c.send(@method, a).should be_false
b[:delta] = 42
c.send(@method, a).should be_true
end

it "computes equality for recursive hashes & arrays" do
x, y, z = [], [], []
a, b, c = {:foo => x, :bar => 42}, {:foo => y, :bar => 42}, {:foo => z, :bar => 42}
x << a
y << c
z << b
b.send(@method, c).should be_true # they clearly have the same structure!
y.send(@method, z).should be_true
a.send(@method, b).should be_true # subtle, but they both have the same structure!
x.send(@method, y).should be_true
y << x
y.send(@method, z).should be_false
z << x
y.send(@method, z).should be_true
it "computes equality for recursive hashes & arrays" do
x, y, z = [], [], []
a, b, c = {:foo => x, :bar => 42}, {:foo => y, :bar => 42}, {:foo => z, :bar => 42}
x << a
y << c
z << b
b.send(@method, c).should be_true # they clearly have the same structure!
y.send(@method, z).should be_true
a.send(@method, b).should be_true # subtle, but they both have the same structure!
x.send(@method, y).should be_true
y << x
y.send(@method, z).should be_false
z << x
y.send(@method, z).should be_true

a[:foo], a[:bar] = a[:bar], a[:foo]
a.send(@method, b).should be_false
b[:bar] = b[:foo]
b.send(@method, c).should be_false
end
end # ruby_bug
a[:foo], a[:bar] = a[:bar], a[:foo]
a.send(@method, b).should be_false
b[:bar] = b[:foo]
b.send(@method, c).should be_false
end
end
6 changes: 2 additions & 4 deletions spec/ruby/core/io/binmode_spec.rb
Original file line number Diff line number Diff line change
@@ -16,10 +16,8 @@
@io.binmode.should equal(@io)
end

ruby_bug "#2046", "1.8.7.174" do
it "raises an IOError on closed stream" do
lambda { IOSpecs.closed_io.binmode }.should raise_error(IOError)
end
it "raises an IOError on closed stream" do
lambda { IOSpecs.closed_io.binmode }.should raise_error(IOError)
end

it "sets external encoding to binary" do
10 changes: 4 additions & 6 deletions spec/ruby/core/io/reopen_spec.rb
Original file line number Diff line number Diff line change
@@ -229,12 +229,10 @@ def @io.to_io; flunk; end
@io.gets.should == "Line 1\n"
end

ruby_bug '#', '1.8' do
it "reads from the current position of the other IO's stream" do
@other_io.gets.should == "Line 1\n"
@io.reopen @other_io
@io.gets.should == "Line 2\n"
end
it "reads from the current position of the other IO's stream" do
@other_io.gets.should == "Line 1\n"
@io.reopen @other_io
@io.gets.should == "Line 2\n"
end
end

10 changes: 4 additions & 6 deletions spec/ruby/core/io/set_encoding_spec.rb
Original file line number Diff line number Diff line change
@@ -150,12 +150,10 @@
@io.internal_encoding.should be_nil
end

ruby_bug "http://redmine.ruby-lang.org/issues/5568", "1.9.3" do
it "ignores the internal encoding if the same as external when passed Encoding objects" do
@io.set_encoding(Encoding::UTF_8, Encoding::UTF_8)
@io.external_encoding.should == Encoding::UTF_8
@io.internal_encoding.should be_nil
end
it "ignores the internal encoding if the same as external when passed Encoding objects" do
@io.set_encoding(Encoding::UTF_8, Encoding::UTF_8)
@io.external_encoding.should == Encoding::UTF_8
@io.internal_encoding.should be_nil
end

it "ignores the internal encoding if the same as external when passed encoding names separanted by ':'" do
8 changes: 3 additions & 5 deletions spec/ruby/core/kernel/__dir___spec.rb
Original file line number Diff line number Diff line change
@@ -5,11 +5,9 @@
__dir__.should == File.realpath(File.dirname(__FILE__))
end

ruby_bug "#8346", "2.0" do
context "when used in eval with top level binding" do
it "returns the real name of the directory containing the currently-executing file" do
eval("__dir__", binding).should == File.realpath(File.dirname(__FILE__))
end
context "when used in eval with top level binding" do
it "returns the real name of the directory containing the currently-executing file" do
eval("__dir__", binding).should == File.realpath(File.dirname(__FILE__))
end
end
end
30 changes: 14 additions & 16 deletions spec/ruby/core/kernel/define_singleton_method_spec.rb
Original file line number Diff line number Diff line change
@@ -17,25 +17,23 @@ class DefineSingletonMethodSpecClass
DefineSingletonMethodSpecClass.should have_method(:another_test_method)
end

ruby_bug "redmine:2117", "1.8.7" do
it "defines any Child class method from any Parent's class methods" do
um = KernelSpecs::Parent.method(:parent_class_method).unbind
KernelSpecs::Child.send :define_singleton_method, :child_class_method, um
KernelSpecs::Child.child_class_method.should == :foo
lambda{KernelSpecs::Parent.child_class_method}.should raise_error(NoMethodError)
end
it "defines any Child class method from any Parent's class methods" do
um = KernelSpecs::Parent.method(:parent_class_method).unbind
KernelSpecs::Child.send :define_singleton_method, :child_class_method, um
KernelSpecs::Child.child_class_method.should == :foo
lambda{KernelSpecs::Parent.child_class_method}.should raise_error(NoMethodError)
end

it "will raise when attempting to define an object's singleton method from another object's singleton method" do
other = KernelSpecs::Parent.new
p = KernelSpecs::Parent.new
class << p
def singleton_method
:single
end
it "will raise when attempting to define an object's singleton method from another object's singleton method" do
other = KernelSpecs::Parent.new
p = KernelSpecs::Parent.new
class << p
def singleton_method
:single
end
um = p.method(:singleton_method).unbind
lambda{ other.send :define_singleton_method, :other_singleton_method, um }.should raise_error(TypeError)
end
um = p.method(:singleton_method).unbind
lambda{ other.send :define_singleton_method, :other_singleton_method, um }.should raise_error(TypeError)
end

end
30 changes: 14 additions & 16 deletions spec/ruby/core/kernel/eval_spec.rb
Original file line number Diff line number Diff line change
@@ -200,22 +200,20 @@ class Object
lambda { eval("return :eval") }.call.should == :eval
end

ruby_bug "#", "1.9" do
# TODO: investigate this further on 1.8.7. This is one oddity:
#
# In a script body:
#
# lambda { return }
# works as expected
#
# def quix; yield; end
# lambda { quix { return } }
# raises a LocalJumpError

it "unwinds through a Proc-style closure and returns from a lambda-style closure in the closure chain" do
code = fixture __FILE__, "eval_return_with_lambda.rb"
ruby_exe(code).chomp.should == "a,b,c,eval,f"
end
# TODO: investigate this further on 1.8.7. This is one oddity:
#
# In a script body:
#
# lambda { return }
# works as expected
#
# def quix; yield; end
# lambda { quix { return } }
# raises a LocalJumpError

it "unwinds through a Proc-style closure and returns from a lambda-style closure in the closure chain" do
code = fixture __FILE__, "eval_return_with_lambda.rb"
ruby_exe(code).chomp.should == "a,b,c,eval,f"
end

it "raises a LocalJumpError if there is no lambda-style closure in the chain" do
2 changes: 1 addition & 1 deletion spec/ruby/core/kernel/protected_methods_spec.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

# TODO: rewrite

# The reason why having include() and ruby_version_is is to show the specification explicitly.
# The reason why having include() is to show the specification explicitly.
# You should use have_protected_method() with the exception of this spec.
describe "Kernel#protected_methods" do
it "returns a list of the names of protected methods accessible in the object" do
26 changes: 12 additions & 14 deletions spec/ruby/core/kernel/shared/method.rb
Original file line number Diff line number Diff line change
@@ -38,20 +38,18 @@ class KernelSpecs::Foo; def self.bar; 'done'; end; end
lambda { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
end

ruby_bug "redmine:1151", "1.8.7" do
it "changes the method called for super on a target aliased method" do
c1 = Class.new do
def a; 'a'; end
def b; 'b'; end
end
c2 = Class.new(c1) do
def a; super; end
alias b a
end

c2.new.a.should == 'a'
c2.new.b.should == 'a'
c2.new.send(@method, :b).call.should == 'a'
it "changes the method called for super on a target aliased method" do
c1 = Class.new do
def a; 'a'; end
def b; 'b'; end
end
c2 = Class.new(c1) do
def a; super; end
alias b a
end

c2.new.a.should == 'a'
c2.new.b.should == 'a'
c2.new.send(@method, :b).call.should == 'a'
end
end
8 changes: 3 additions & 5 deletions spec/ruby/core/kernel/system_spec.rb
Original file line number Diff line number Diff line change
@@ -49,11 +49,9 @@
end

platform_is :windows do
ruby_bug 'redmine:4393', '1.9.3' do
it "runs commands starting with @ using shell (as comments)" do
# unsure of a better way to confirm this, since success means it does nothing
@object.system('@does_not_exist').should == true
end
it "runs commands starting with @ using shell (as comments)" do
# unsure of a better way to confirm this, since success means it does nothing
@object.system('@does_not_exist').should == true
end
end
end
11 changes: 1 addition & 10 deletions spec/ruby/core/kernel/taint_spec.rb
Original file line number Diff line number Diff line change
@@ -53,16 +53,7 @@
end
end

ruby_version_is ""..."2.0" do
it "has no effect on immediate values" do
[1].each do |v|
v.taint
v.tainted?.should == false
end
end
end

ruby_version_is "2.0"..."2.2" do
ruby_version_is ""..."2.2" do
it "raises error on fixnum values" do
[1].each do |v|
lambda { v.taint }.should raise_error(RuntimeError)
2 changes: 1 addition & 1 deletion spec/ruby/core/kernel/untrusted_spec.rb
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
c.untrusted?.should == false
end

ruby_version_is "2.0"..."2.2" do
ruby_version_is ""..."2.2" do
it "has no effect on immediate values" do
d = 1
lambda { d.untrust }.should raise_error(RuntimeError)
24 changes: 11 additions & 13 deletions spec/ruby/core/module/autoload_spec.rb
Original file line number Diff line number Diff line change
@@ -284,19 +284,17 @@ class Y
lambda { ModuleSpecs.autoload "a name", @non_existent }.should raise_error(NameError)
end

ruby_bug "redmine #620", "1.8.6.322" do
it "shares the autoload request across dup'ed copies of modules" do
filename = fixture(__FILE__, "autoload_t.rb")
mod1 = Module.new { autoload :T, filename }
ModuleSpecs::Autoload::S = mod1
mod2 = mod1.dup

mod1.autoload?(:T).should == filename
mod2.autoload?(:T).should == filename

mod1::T.should == :autoload_t
lambda { mod2::T }.should raise_error(NameError)
end
it "shares the autoload request across dup'ed copies of modules" do
filename = fixture(__FILE__, "autoload_t.rb")
mod1 = Module.new { autoload :T, filename }
ModuleSpecs::Autoload::S = mod1
mod2 = mod1.dup

mod1.autoload?(:T).should == filename
mod2.autoload?(:T).should == filename

mod1::T.should == :autoload_t
lambda { mod2::T }.should raise_error(NameError)
end

it "raises a TypeError if opening a class with a different superclass than the class defined in the autoload file" do
6 changes: 2 additions & 4 deletions spec/ruby/core/module/prepend_features_spec.rb
Original file line number Diff line number Diff line change
@@ -41,10 +41,8 @@ def self.prepend_features(mod)
end

describe "on Class" do
ruby_bug "GH-376", "2.0.0.312" do
it "is undefined" do
Class.should_not have_private_instance_method(:prepend_features, true)
end
it "is undefined" do
Class.should_not have_private_instance_method(:prepend_features, true)
end

it "raises a TypeError if calling after rebinded to Class" do
16 changes: 7 additions & 9 deletions spec/ruby/core/module/private_constant_spec.rb
Original file line number Diff line number Diff line change
@@ -11,16 +11,14 @@
end.should raise_error(NameError)
end

ruby_bug "[ruby-list:48559]", "1.9.3" do
it "accepts multiple names" do
mod = Module.new
mod.const_set :Foo, true
mod.const_set :Bar, true
it "accepts multiple names" do
mod = Module.new
mod.const_set :Foo, true
mod.const_set :Bar, true

mod.send :private_constant, :Foo, :Bar
mod.send :private_constant, :Foo, :Bar

lambda {mod::Foo}.should raise_error(NameError)
lambda {mod::Bar}.should raise_error(NameError)
end
lambda {mod::Foo}.should raise_error(NameError)
lambda {mod::Bar}.should raise_error(NameError)
end
end
22 changes: 10 additions & 12 deletions spec/ruby/core/mutex/lock_spec.rb
Original file line number Diff line number Diff line change
@@ -31,18 +31,16 @@

# Unable to find a specific ticket but behavior change may be
# related to this ML thread.
ruby_bug "[ruby-core:23457]", "1.8.7.174" do
it "raises a ThreadError when used recursively" do
m = Mutex.new

th = Thread.new do
m.lock
m.lock
end

lambda do
th.join
end.should raise_error(ThreadError)
it "raises a ThreadError when used recursively" do
m = Mutex.new

th = Thread.new do
m.lock
m.lock
end

lambda do
th.join
end.should raise_error(ThreadError)
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/numeric/quo_spec.rb
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@
end
end

ruby_version_is "1.9"..."2.1" do
ruby_version_is ""..."2.1" do
it "returns the result of calling self#/ with other" do
obj = NumericSpecs::Subclass.new
obj.should_receive(:coerce).twice.and_return([19,19])
140 changes: 64 additions & 76 deletions spec/ruby/core/numeric/step_spec.rb
Original file line number Diff line number Diff line change
@@ -150,12 +150,10 @@
ScratchPad.recorded.should == []
end

ruby_bug "redmine #4576", "1.9.3" do
it "is careful about not yielding a value greater than limit" do
# As 9*1.3+1.0 == 12.700000000000001 > 12.7, we test:
1.0.step(12.7, 1.3, &@prc)
ScratchPad.recorded.should eql [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7]
end
it "is careful about not yielding a value greater than limit" do
# As 9*1.3+1.0 == 12.700000000000001 > 12.7, we test:
1.0.step(12.7, 1.3, &@prc)
ScratchPad.recorded.should eql [1.0, 2.3, 3.6, 4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7]
end
end

@@ -175,84 +173,74 @@
ScratchPad.recorded.should == []
end

ruby_bug "redmine #4576", "1.9.3" do
it "is careful about not yielding a value smaller than limit" do
# As -9*1.3-1.0 == -12.700000000000001 < -12.7, we test:
-1.0.step(-12.7, -1.3, &@prc)
ScratchPad.recorded.should eql [-1.0, -2.3, -3.6, -4.9, -6.2, -7.5, -8.8, -10.1, -11.4, -12.7]
end
it "is careful about not yielding a value smaller than limit" do
# As -9*1.3-1.0 == -12.700000000000001 < -12.7, we test:
-1.0.step(-12.7, -1.3, &@prc)
ScratchPad.recorded.should eql [-1.0, -2.3, -3.6, -4.9, -6.2, -7.5, -8.8, -10.1, -11.4, -12.7]
end
end

describe "Numeric#step with [stop, +Infinity]" do
ruby_bug "#781", "1.8.7" do
it "yields once if self < stop" do
42.step(100, infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when stop is Infinity" do
42.step(infinity_value, infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self equals stop" do
42.step(42, infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self and stop are Infinity" do
(infinity_value).step(infinity_value, infinity_value, &@prc)
ScratchPad.recorded.should == [infinity_value]
end
end

ruby_bug "#3945", "1.9.2.135" do
it "does not yield when self > stop" do
100.step(42, infinity_value, &@prc)
ScratchPad.recorded.should == []
end

it "does not yield when stop is -Infinity" do
42.step(-infinity_value, infinity_value, &@prc)
ScratchPad.recorded.should == []
end
it "yields once if self < stop" do
42.step(100, infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when stop is Infinity" do
42.step(infinity_value, infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self equals stop" do
42.step(42, infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self and stop are Infinity" do
(infinity_value).step(infinity_value, infinity_value, &@prc)
ScratchPad.recorded.should == [infinity_value]
end

it "does not yield when self > stop" do
100.step(42, infinity_value, &@prc)
ScratchPad.recorded.should == []
end

it "does not yield when stop is -Infinity" do
42.step(-infinity_value, infinity_value, &@prc)
ScratchPad.recorded.should == []
end
end

describe "Numeric#step with [stop, -infinity]" do
ruby_bug "#3945", "1.9.2.135" do
it "yields once if self > stop" do
42.step(6, -infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once if stop is -Infinity" do
42.step(-infinity_value, -infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self equals stop" do
42.step(42, -infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self and stop are Infinity" do
(infinity_value).step(infinity_value, -infinity_value, &@prc)
ScratchPad.recorded.should == [infinity_value]
end
end

ruby_bug "#781", "1.8.7" do
it "does not yield when self > stop" do
42.step(100, -infinity_value, &@prc)
ScratchPad.recorded.should == []
end

it "does not yield when stop is Infinity" do
42.step(infinity_value, -infinity_value, &@prc)
ScratchPad.recorded.should == []
end
it "yields once if self > stop" do
42.step(6, -infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once if stop is -Infinity" do
42.step(-infinity_value, -infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self equals stop" do
42.step(42, -infinity_value, &@prc)
ScratchPad.recorded.should == [42]
end

it "yields once when self and stop are Infinity" do
(infinity_value).step(infinity_value, -infinity_value, &@prc)
ScratchPad.recorded.should == [infinity_value]
end

it "does not yield when self > stop" do
42.step(100, -infinity_value, &@prc)
ScratchPad.recorded.should == []
end

it "does not yield when stop is Infinity" do
42.step(infinity_value, -infinity_value, &@prc)
ScratchPad.recorded.should == []
end
end

22 changes: 9 additions & 13 deletions spec/ruby/core/range/step_spec.rb
Original file line number Diff line number Diff line change
@@ -102,13 +102,11 @@
ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5, 1.0])
end

ruby_bug "redmine #4576", "1.9.3" do
it "returns Float values of 'step * n + begin <= end'" do
(1.0..6.4).step(1.8) { |x| ScratchPad << x }
(1.0..12.7).step(1.3) { |x| ScratchPad << x }
ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 6.4, 1.0, 2.3, 3.6,
4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7])
end
it "returns Float values of 'step * n + begin <= end'" do
(1.0..6.4).step(1.8) { |x| ScratchPad << x }
(1.0..12.7).step(1.3) { |x| ScratchPad << x }
ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 6.4, 1.0, 2.3, 3.6,
4.9, 6.2, 7.5, 8.8, 10.1, 11.4, 12.7])
end
end

@@ -206,12 +204,10 @@
ScratchPad.recorded.should eql([-1.0, -0.5, 0.0, 0.5])
end

ruby_bug "redmine #4576", "1.9.3" do
it "returns Float values of 'step * n + begin < end'" do
(1.0...6.4).step(1.8) { |x| ScratchPad << x }
(1.0...55.6).step(18.2) { |x| ScratchPad << x }
ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 1.0, 19.2, 37.4])
end
it "returns Float values of 'step * n + begin < end'" do
(1.0...6.4).step(1.8) { |x| ScratchPad << x }
(1.0...55.6).step(18.2) { |x| ScratchPad << x }
ScratchPad.recorded.should eql([1.0, 2.8, 4.6, 1.0, 19.2, 37.4])
end
end

4 changes: 2 additions & 2 deletions spec/ruby/core/string/inspect_spec.rb
Original file line number Diff line number Diff line change
@@ -313,7 +313,7 @@
].should be_computed_by(:inspect)
end

ruby_version_is "1.9".."2.1" do
ruby_version_is "".."2.1" do
it "returns a string with a NUL character replaced by \\x notation" do
0.chr.inspect.should == '"\\x00"'
end
@@ -387,7 +387,7 @@
].should be_computed_by(:inspect)
end

ruby_version_is "1.9".."2.1" do
ruby_version_is "".."2.1" do
it "returns a string with a NUL character replaced by \\u notation" do
0.chr('utf-8').inspect.should == '"\\u0000"'
end
10 changes: 4 additions & 6 deletions spec/ruby/core/string/partition_spec.rb
Original file line number Diff line number Diff line change
@@ -21,12 +21,10 @@
$2.should == "lo"
end

ruby_bug "redmine #1510", '1.9.1' do
it "converts its argument using :to_str" do
find = mock('l')
find.should_receive(:to_str).and_return("l")
"hello".partition(find).should == ["he","l","lo"]
end
it "converts its argument using :to_str" do
find = mock('l')
find.should_receive(:to_str).and_return("l")
"hello".partition(find).should == ["he","l","lo"]
end

it "raises an error if not convertible to string" do
20 changes: 9 additions & 11 deletions spec/ruby/core/string/rindex_spec.rb
Original file line number Diff line number Diff line change
@@ -15,17 +15,15 @@
lambda { "hello".rindex(obj) }.should raise_error(TypeError)
end

ruby_bug "#", "1.8.6" do # Fixed at MRI 1.8.7
it "tries to convert obj to a string via to_str" do
obj = mock('lo')
def obj.to_str() "lo" end
"hello".rindex(obj).should == "hello".rindex("lo")

obj = mock('o')
def obj.respond_to?(arg, *) true end
def obj.method_missing(*args) "o" end
"hello".rindex(obj).should == "hello".rindex("o")
end
it "tries to convert obj to a string via to_str" do
obj = mock('lo')
def obj.to_str() "lo" end
"hello".rindex(obj).should == "hello".rindex("lo")

obj = mock('o')
def obj.respond_to?(arg, *) true end
def obj.method_missing(*args) "o" end
"hello".rindex(obj).should == "hello".rindex("o")
end
end

10 changes: 4 additions & 6 deletions spec/ruby/core/string/rpartition_spec.rb
Original file line number Diff line number Diff line change
@@ -20,12 +20,10 @@
matched_string.should == $~[0]
end

ruby_bug "redmine #1510", '1.9.1' do
it "converts its argument using :to_str" do
find = mock('l')
find.should_receive(:to_str).and_return("l")
"hello".rpartition(find).should == ["hel","l","o"]
end
it "converts its argument using :to_str" do
find = mock('l')
find.should_receive(:to_str).and_return("l")
"hello".rpartition(find).should == ["hel","l","o"]
end

it "raises an error if not convertible to string" do
14 changes: 5 additions & 9 deletions spec/ruby/core/string/scan_spec.rb
Original file line number Diff line number Diff line change
@@ -74,11 +74,9 @@
lambda { "cruel world".scan(mock('x')) }.should raise_error(TypeError)
end

ruby_bug "#4087", "1.9.2.135" do
it "taints the results if the String argument is tainted" do
a = "hello hello hello".scan("hello".taint)
a.each { |m| m.tainted?.should be_true }
end
it "taints the results if the String argument is tainted" do
a = "hello hello hello".scan("hello".taint)
a.each { |m| m.tainted?.should be_true }
end

it "taints the results when passed a String argument if self is tainted" do
@@ -177,10 +175,8 @@
$~.should == nil
end

ruby_bug "#4087", "1.9.2.135" do
it "taints the results if the String argument is tainted" do
"hello hello hello".scan("hello".taint).each { |m| m.tainted?.should be_true }
end
it "taints the results if the String argument is tainted" do
"hello hello hello".scan("hello".taint).each { |m| m.tainted?.should be_true }
end

it "taints the results when passed a String argument if self is tainted" do
8 changes: 3 additions & 5 deletions spec/ruby/core/string/shared/chars.rb
Original file line number Diff line number Diff line change
@@ -9,11 +9,9 @@
a.should == ['h', 'e', 'l', 'l', 'o']
end

ruby_bug 'redmine #1487', '1.9.1' do
it "returns self" do
s = StringSpecs::MyString.new "hello"
s.send(@method){}.should equal(s)
end
it "returns self" do
s = StringSpecs::MyString.new "hello"
s.send(@method){}.should equal(s)
end


8 changes: 3 additions & 5 deletions spec/ruby/core/string/shared/concat.rb
Original file line number Diff line number Diff line change
@@ -152,11 +152,9 @@
end
end

ruby_bug "#", "1.9.3" do
describe "when self is ASCII-8BIT and argument is US-ASCII" do
it "uses ASCII-8BIT encoding" do
"abc".encode("ASCII-8BIT").send(@method, "123".encode("US-ASCII")).encoding.should == Encoding::ASCII_8BIT
end
describe "when self is ASCII-8BIT and argument is US-ASCII" do
it "uses ASCII-8BIT encoding" do
"abc".encode("ASCII-8BIT").send(@method, "123".encode("US-ASCII")).encoding.should == Encoding::ASCII_8BIT
end
end
end
6 changes: 2 additions & 4 deletions spec/ruby/core/string/split_spec.rb
Original file line number Diff line number Diff line change
@@ -349,10 +349,8 @@
# When split is called with a limit of -1, empty fields are not suppressed
# and a final empty field is *alawys* created (who knows why). This empty
# string is not tainted (again, who knows why) on 1.8 but is on 1.9.
ruby_bug "#", "1.8" do
it "taints an empty string if self is tainted" do
":".taint.split(//, -1).last.tainted?.should be_true
end
it "taints an empty string if self is tainted" do
":".taint.split(//, -1).last.tainted?.should be_true
end

it "doesn't taints the resulting strings if the Regexp is tainted" do
28 changes: 12 additions & 16 deletions spec/ruby/core/string/unpack/shared/integer.rb
Original file line number Diff line number Diff line change
@@ -255,14 +255,12 @@
end

describe :string_unpack_64bit_le_extra, :shared => true do
ruby_bug "#", "1.8.7" do
it "adds nil for each element requested beyond the end of the String" do
[ ["", [nil, nil, nil]],
["abcdefgh", [7523094288207667809, nil, nil]],
["abcdefghcdefab", [7523094288207667809, nil, nil]],
["abcdefghcdefabde", [7523094288207667809, 7306072665971057763, nil]]
].should be_computed_by(:unpack, unpack_format(3))
end
it "adds nil for each element requested beyond the end of the String" do
[ ["", [nil, nil, nil]],
["abcdefgh", [7523094288207667809, nil, nil]],
["abcdefghcdefab", [7523094288207667809, nil, nil]],
["abcdefghcdefabde", [7523094288207667809, 7306072665971057763, nil]]
].should be_computed_by(:unpack, unpack_format(3))
end
end

@@ -319,14 +317,12 @@
end

describe :string_unpack_64bit_be_extra, :shared => true do
ruby_bug "#", "1.8.7" do
it "adds nil for each element requested beyond the end of the String" do
[ ["", [nil, nil, nil]],
["hgfedcba", [7523094288207667809, nil, nil]],
["hgfedcbacdefab", [7523094288207667809, nil, nil]],
["hgfedcbaedbafedc", [7523094288207667809, 7306072665971057763, nil]]
].should be_computed_by(:unpack, unpack_format(3))
end
it "adds nil for each element requested beyond the end of the String" do
[ ["", [nil, nil, nil]],
["hgfedcba", [7523094288207667809, nil, nil]],
["hgfedcbacdefab", [7523094288207667809, nil, nil]],
["hgfedcbaedbafedc", [7523094288207667809, 7306072665971057763, nil]]
].should be_computed_by(:unpack, unpack_format(3))
end
end

20 changes: 9 additions & 11 deletions spec/ruby/core/struct/hash_spec.rb
Original file line number Diff line number Diff line change
@@ -31,17 +31,15 @@ def hash
s.new.hash.should == "different"
end

ruby_bug "redmine #1852", "1.9.1" do
it "returns the same hash for recursive structs" do
car = StructClasses::Car.new("Honda", "Accord", "1998")
similar_car = StructClasses::Car.new("Honda", "Accord", "1998")
car[:make] = car
similar_car[:make] = car
car.hash.should == similar_car.hash
# This is because car.eql?(similar_car).
# Objects that are eql? must return the same hash.
# See the Struct#eql? specs
end
it "returns the same hash for recursive structs" do
car = StructClasses::Car.new("Honda", "Accord", "1998")
similar_car = StructClasses::Car.new("Honda", "Accord", "1998")
car[:make] = car
similar_car[:make] = car
car.hash.should == similar_car.hash
# This is because car.eql?(similar_car).
# Objects that are eql? must return the same hash.
# See the Struct#eql? specs
end

it_behaves_like :struct_accessor, :hash
22 changes: 10 additions & 12 deletions spec/ruby/core/struct/shared/equal_value.rb
Original file line number Diff line number Diff line change
@@ -16,18 +16,16 @@
car.send(@method, different_car).should == false
end

ruby_bug "redmine #1885", "1.8" do
it "handles recursive structures by returning false if a difference can be found" do
MyClass = Struct.new(:foo)
x = StructClasses::Car.new("Honda", "Accord", "1998")
x[:make] = x
stepping = StructClasses::Car.new("Honda", "Accord", "1998")
stone = StructClasses::Car.new(stepping, "Accord", "1998")
stepping[:make] = stone
x.send(@method, stepping).should == true
it "handles recursive structures by returning false if a difference can be found" do
MyClass = Struct.new(:foo)
x = StructClasses::Car.new("Honda", "Accord", "1998")
x[:make] = x
stepping = StructClasses::Car.new("Honda", "Accord", "1998")
stone = StructClasses::Car.new(stepping, "Accord", "1998")
stepping[:make] = stone
x.send(@method, stepping).should == true

stone[:year] = "1999" # introduce a difference
x.send(@method, stepping).should == false
end
stone[:year] = "1999" # introduce a difference
x.send(@method, stepping).should == false
end
end
4 changes: 2 additions & 2 deletions spec/ruby/core/time/new_spec.rb
Original file line number Diff line number Diff line change
@@ -65,14 +65,14 @@
end
end

ruby_version_is ""..."2.2.0" do
ruby_version_is ""..."2.2" do
it "adds one hour if the offset minute value is greater than 59" do
Time.new(2000, 1, 1, 0, 0, 0, "+01:60").should == Time.new(2000, 1, 1, 0, 0, 0, "+02:00")
Time.new(2000, 1, 1, 0, 0, 0, "+01:99").should == Time.new(2000, 1, 1, 0, 0, 0, "+02:39")
end
end

ruby_version_is "2.2.0" do
ruby_version_is "2.2" do
# [Bug #8679], r47676
it "disallows a value for minutes greater than 59" do
lambda {
20 changes: 8 additions & 12 deletions spec/ruby/core/time/shared/time_params.rb
Original file line number Diff line number Diff line change
@@ -99,11 +99,9 @@
Time.send(@method, 2008, 1, 1, 0, m).should == Time.send(@method, 2008, 1, 1, 0, 1)
end

ruby_bug "6193", "2.0" do
it "handles a String second" do
Time.send(@method, 2000, 12, 1, 1, 1, "8").should ==
Time.send(@method, 2000, 12, 1, 1, 1, 8)
end
it "handles a String second" do
Time.send(@method, 2000, 12, 1, 1, 1, "8").should ==
Time.send(@method, 2000, 12, 1, 1, 1, 8)
end

it "coerces the second with #to_int" do
@@ -112,13 +110,11 @@
Time.send(@method, 2008, 1, 1, 0, 0, m).should == Time.send(@method, 2008, 1, 1, 0, 0, 1)
end

ruby_bug "6193", "2.0" do
it "interprets all numerals as base 10" do
Time.send(@method, "2000", "08", "08", "08", "08", "08").should ==
Time.send(@method, 2000, 8, 8, 8, 8, 8)
Time.send(@method, "2000", "09", "09", "09", "09", "09").should ==
Time.send(@method, 2000, 9, 9, 9, 9, 9)
end
it "interprets all numerals as base 10" do
Time.send(@method, "2000", "08", "08", "08", "08", "08").should ==
Time.send(@method, 2000, 8, 8, 8, 8, 8)
Time.send(@method, "2000", "09", "09", "09", "09", "09").should ==
Time.send(@method, 2000, 9, 9, 9, 9, 9)
end

it "handles fractional seconds as a Float" do
30 changes: 14 additions & 16 deletions spec/ruby/core/unboundmethod/bind_spec.rb
Original file line number Diff line number Diff line change
@@ -39,23 +39,21 @@
@normal_um.bind(obj).call.should == obj.foo
end

ruby_bug "redmine:2117", "1.8.7" do
it "binds a Parent's class method to any Child's class methods" do
m = UnboundMethodSpecs::Parent.method(:class_method).unbind.bind(UnboundMethodSpecs::Child1)
m.should be_an_instance_of(Method)
m.call.should == "I am UnboundMethodSpecs::Child1"
end

it "will raise when binding a an object singleton's method to another object" do
other = UnboundMethodSpecs::Parent.new
p = UnboundMethodSpecs::Parent.new
class << p
def singleton_method
:single
end
it "binds a Parent's class method to any Child's class methods" do
m = UnboundMethodSpecs::Parent.method(:class_method).unbind.bind(UnboundMethodSpecs::Child1)
m.should be_an_instance_of(Method)
m.call.should == "I am UnboundMethodSpecs::Child1"
end

it "will raise when binding a an object singleton's method to another object" do
other = UnboundMethodSpecs::Parent.new
p = UnboundMethodSpecs::Parent.new
class << p
def singleton_method
:single
end
um = p.method(:singleton_method).unbind
lambda{ um.bind(other) }.should raise_error(TypeError)
end
um = p.method(:singleton_method).unbind
lambda{ um.bind(other) }.should raise_error(TypeError)
end
end
10 changes: 4 additions & 6 deletions spec/ruby/language/array_spec.rb
Original file line number Diff line number Diff line change
@@ -79,12 +79,10 @@
[1, 2, *splatted_array].should == [1, 2, 3, 4, 5]
end

ruby_bug "#5124", "1.9.3.194" do
it "returns a new array containing the same values when applied to an array inside an empty array" do
splatted_array = [3, 4, 5]
[*splatted_array].should == splatted_array
[*splatted_array].should_not equal(splatted_array)
end
it "returns a new array containing the same values when applied to an array inside an empty array" do
splatted_array = [3, 4, 5]
[*splatted_array].should == splatted_array
[*splatted_array].should_not equal(splatted_array)
end

it "unpacks the start and count arguments in an array slice assignment" do
2 changes: 1 addition & 1 deletion spec/ruby/language/def_spec.rb
Original file line number Diff line number Diff line change
@@ -174,7 +174,7 @@ def foo(a, b = 2, *args)
foo(2,3,3).should == [2,3,[3]]
end

ruby_version_is "2.0"..."2.2" do
ruby_version_is ""..."2.2" do
it "calls a method with the same name as the local" do
def bar
1
2 changes: 1 addition & 1 deletion spec/ruby/language/hash_spec.rb
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@
{a: 1, **h, c: 4}.should == {a: 1, b: 2, c: 4}
end

ruby_version_is "2.0"..."2.2" do
ruby_version_is ""..."2.2" do
it "expands an '**{}' element with containing Hash literal keys taking precedence" do
{a: 1, **{a: 2, b: 3, c: 1}, c: 3}.should == {a: 1, b: 3, c: 3}
end
50 changes: 24 additions & 26 deletions spec/ruby/language/order_spec.rb
Original file line number Diff line number Diff line change
@@ -45,33 +45,31 @@ def @obj.foo4(a, b, c, d, &e)
a.should == 10
end

ruby_bug "redmine #1034", "1.8" do
it "evaluates block pass after arguments" do
a = 0
p = proc {true}
@obj.foo1(a += 1, &(a += 1; p)).should == [1, true]
@obj.foo2(a += 1, a += 1, &(a += 1; p)).should == [3, 4, true]
@obj.foo3(a += 1, a += 1, a += 1, &(a += 1; p)).should == [6, 7, 8, true]
@obj.foo4(a += 1, a += 1, a += 1, a += 1, &(a += 1; p)).should == [10, 11, 12, 13, true]
a.should == 14
end
it "evaluates block pass after arguments" do
a = 0
p = proc {true}
@obj.foo1(a += 1, &(a += 1; p)).should == [1, true]
@obj.foo2(a += 1, a += 1, &(a += 1; p)).should == [3, 4, true]
@obj.foo3(a += 1, a += 1, a += 1, &(a += 1; p)).should == [6, 7, 8, true]
@obj.foo4(a += 1, a += 1, a += 1, a += 1, &(a += 1; p)).should == [10, 11, 12, 13, true]
a.should == 14
end

it "evaluates block pass after receiver" do
p1 = proc {true}
p2 = proc {false}
p1.should_not == p2
it "evaluates block pass after receiver" do
p1 = proc {true}
p2 = proc {false}
p1.should_not == p2

p = p1
(p = p2; @obj).foo0(&p).should == [false]
p = p1
(p = p2; @obj).foo1(1, &p).should == [1, false]
p = p1
(p = p2; @obj).foo2(1, 1, &p).should == [1, 1, false]
p = p1
(p = p2; @obj).foo3(1, 1, 1, &p).should == [1, 1, 1, false]
p = p1
(p = p2; @obj).foo4(1, 1, 1, 1, &p).should == [1, 1, 1, 1, false]
p = p1
end
p = p1
(p = p2; @obj).foo0(&p).should == [false]
p = p1
(p = p2; @obj).foo1(1, &p).should == [1, false]
p = p1
(p = p2; @obj).foo2(1, 1, &p).should == [1, 1, false]
p = p1
(p = p2; @obj).foo3(1, 1, 1, &p).should == [1, 1, 1, false]
p = p1
(p = p2; @obj).foo4(1, 1, 1, 1, &p).should == [1, 1, 1, 1, false]
p = p1
end
end
26 changes: 12 additions & 14 deletions spec/ruby/language/super_spec.rb
Original file line number Diff line number Diff line change
@@ -62,23 +62,21 @@
Super::S4::B.new.foo([],"test").should == ["B#foo(a,test)", "A#foo"]
end

ruby_bug "#1151 [ruby-core:22040]", "1.8.7.174" do
it "raises an error error when super method does not exist" do
sup = Class.new
sub_normal = Class.new(sup) do
def foo
super()
end
it "raises an error error when super method does not exist" do
sup = Class.new
sub_normal = Class.new(sup) do
def foo
super()
end
sub_zsuper = Class.new(sup) do
def foo
super
end
end
sub_zsuper = Class.new(sup) do
def foo
super
end

lambda {sub_normal.new.foo}.should raise_error(NoMethodError, /super/)
lambda {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/)
end

lambda {sub_normal.new.foo}.should raise_error(NoMethodError, /super/)
lambda {sub_zsuper.new.foo}.should raise_error(NoMethodError, /super/)
end

it "calls the superclass method when in a block" do
36 changes: 0 additions & 36 deletions spec/ruby/library/base64/b64encode_spec.rb

This file was deleted.

19 changes: 0 additions & 19 deletions spec/ruby/library/base64/decode_b_spec.rb

This file was deleted.

35 changes: 8 additions & 27 deletions spec/ruby/library/bigdecimal/ceil_spec.rb
Original file line number Diff line number Diff line change
@@ -21,21 +21,12 @@
@zero_neg = BigDecimal("-0")
end

ruby_version_is "" ... "1.9" do
it "returns a BigDecimal" do
@mixed.ceil.kind_of?(BigDecimal).should == true
@pos_int.ceil(2).kind_of?(BigDecimal).should == true
end
it "returns an Integer, if n is unspecified" do
@mixed.ceil.kind_of?(Integer).should == true
end

ruby_version_is "1.9" do
it "returns an Integer, if n is unspecified" do
@mixed.ceil.kind_of?(Integer).should == true
end

it "returns a BigDecimal, if n is specified" do
@pos_int.ceil(2).kind_of?(BigDecimal).should == true
end
it "returns a BigDecimal, if n is specified" do
@pos_int.ceil(2).kind_of?(BigDecimal).should == true
end

it "returns the smallest integer greater or equal to self, if n is unspecified" do
@@ -56,20 +47,10 @@
BigDecimal('-2.9999').ceil.should == -2
end

ruby_version_is "" ... "1.9" do
it "returns the same value, if self is special value" do
@infinity.ceil.should == @infinity
@infinity_neg.ceil.should == @infinity_neg
@nan.ceil.nan?.should == true
end
end

ruby_version_is "1.9" do
it "raise exception, if self is special value" do
lambda { @infinity.ceil }.should raise_error(FloatDomainError)
lambda { @infinity_neg.ceil }.should raise_error(FloatDomainError)
lambda { @nan.ceil }.should raise_error(FloatDomainError)
end
it "raise exception, if self is special value" do
lambda { @infinity.ceil }.should raise_error(FloatDomainError)
lambda { @infinity_neg.ceil }.should raise_error(FloatDomainError)
lambda { @nan.ceil }.should raise_error(FloatDomainError)
end

it "returns n digits right of the decimal point if given n > 0" do
100 changes: 28 additions & 72 deletions spec/ruby/library/bigdecimal/div_spec.rb
Original file line number Diff line number Diff line change
@@ -42,28 +42,14 @@
}
end

ruby_version_is "" ... "1.9" do
it "returns NaN if NaN is involved" do
@one.div(@nan).nan?.should == true
@nan.div(@one).nan?.should == true
end

it "returns NaN if divided by Infinity and no precision given" do
@zero.div(@infinity).nan?.should == true
@frac_2.div(@infinity).nan?.should == true
end
it "raises FloatDomainError if NaN is involved" do
lambda { @one.div(@nan) }.should raise_error(FloatDomainError)
lambda { @nan.div(@one) }.should raise_error(FloatDomainError)
end

ruby_version_is "1.9" do
it "raises FloatDomainError if NaN is involved" do
lambda { @one.div(@nan) }.should raise_error(FloatDomainError)
lambda { @nan.div(@one) }.should raise_error(FloatDomainError)
end

it "returns 0 if divided by Infinity and no precision given" do
@zero.div(@infinity).should == 0
@frac_2.div(@infinity).should == 0
end
it "returns 0 if divided by Infinity and no precision given" do
@zero.div(@infinity).should == 0
@frac_2.div(@infinity).should == 0
end

it "returns 0 if divided by Infinity with given precision" do
@@ -73,60 +59,30 @@
@frac_2.div(@infinity, 100000).should == 0
end

ruby_version_is "" ... "1.9" do
it "returns NaN if divided by zero and no precision given" do
@one.div(@zero).nan?.should == true
@one.div(@zero_plus).nan?.should == true
@one.div(@zero_minus).nan?.should == true
end

it "returns NaN if zero is divided by zero" do
@zero.div(@zero).nan?.should == true
@zero_minus.div(@zero_plus).nan?.should == true
@zero_plus.div(@zero_minus).nan?.should == true

@zero.div(@zero, 0).nan?.should == true
@zero_minus.div(@zero_plus, 0).nan?.should == true
@zero_plus.div(@zero_minus, 0).nan?.should == true

@zero.div(@zero, 10).nan?.should == true
@zero_minus.div(@zero_plus, 10).nan?.should == true
@zero_plus.div(@zero_minus, 10).nan?.should == true
end

it "returns NaN if (+|-) Infinity divided by 1 and no precision given" do
@infinity_minus.div(@one).nan?.should == true
@infinity.div(@one).nan?.should == true
@infinity_minus.div(@one_minus).nan?.should == true
end
it "raises ZeroDivisionError if divided by zero and no precision given" do
lambda { @one.div(@zero) }.should raise_error(ZeroDivisionError)
lambda { @one.div(@zero_plus) }.should raise_error(ZeroDivisionError)
lambda { @one.div(@zero_minus) }.should raise_error(ZeroDivisionError)

lambda { @zero.div(@zero) }.should raise_error(ZeroDivisionError)
lambda { @zero_minus.div(@zero_plus) }.should raise_error(ZeroDivisionError)
lambda { @zero_plus.div(@zero_minus) }.should raise_error(ZeroDivisionError)
end

it "returns NaN if zero is divided by zero" do
@zero.div(@zero, 0).nan?.should == true
@zero_minus.div(@zero_plus, 0).nan?.should == true
@zero_plus.div(@zero_minus, 0).nan?.should == true

@zero.div(@zero, 10).nan?.should == true
@zero_minus.div(@zero_plus, 10).nan?.should == true
@zero_plus.div(@zero_minus, 10).nan?.should == true
end

ruby_version_is "1.9" do
it "raises ZeroDivisionError if divided by zero and no precision given" do
lambda { @one.div(@zero) }.should raise_error(ZeroDivisionError)
lambda { @one.div(@zero_plus) }.should raise_error(ZeroDivisionError)
lambda { @one.div(@zero_minus) }.should raise_error(ZeroDivisionError)

lambda { @zero.div(@zero) }.should raise_error(ZeroDivisionError)
lambda { @zero_minus.div(@zero_plus) }.should raise_error(ZeroDivisionError)
lambda { @zero_plus.div(@zero_minus) }.should raise_error(ZeroDivisionError)
end

it "returns NaN if zero is divided by zero" do
@zero.div(@zero, 0).nan?.should == true
@zero_minus.div(@zero_plus, 0).nan?.should == true
@zero_plus.div(@zero_minus, 0).nan?.should == true

@zero.div(@zero, 10).nan?.should == true
@zero_minus.div(@zero_plus, 10).nan?.should == true
@zero_plus.div(@zero_minus, 10).nan?.should == true
end

it "raises FloatDomainError if (+|-) Infinity divided by 1 and no precision given" do
lambda { @infinity_minus.div(@one) }.should raise_error(FloatDomainError)
lambda { @infinity.div(@one) }.should raise_error(FloatDomainError)
lambda { @infinity_minus.div(@one_minus) }.should raise_error(FloatDomainError)
end
it "raises FloatDomainError if (+|-) Infinity divided by 1 and no precision given" do
lambda { @infinity_minus.div(@one) }.should raise_error(FloatDomainError)
lambda { @infinity.div(@one) }.should raise_error(FloatDomainError)
lambda { @infinity_minus.div(@one_minus) }.should raise_error(FloatDomainError)
end

it "returns (+|-)Infinity if (+|-)Infinity by 1 and precision given" do
140 changes: 46 additions & 94 deletions spec/ruby/library/bigdecimal/divmod_spec.rb
Original file line number Diff line number Diff line change
@@ -35,24 +35,12 @@ class BigDecimal

it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod

ruby_version_is "" ... "1.9" do
it "does NOT raise ZeroDivisionError if other is zero" do
bd5667 = BigDecimal.new("5667.19")
it "raises ZeroDivisionError if other is zero" do
bd5667 = BigDecimal.new("5667.19")

bd5667.send(@method, 0).nan?.should == true
bd5667.send(@method, BigDecimal("0")).nan?.should == true
@zero.send(@method, @zero).nan?.should == true
end
end

ruby_version_is "1.9" do
it "raises ZeroDivisionError if other is zero" do
bd5667 = BigDecimal.new("5667.19")

lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
lambda { @zero.send(@method, @zero) }.should raise_error(ZeroDivisionError)
end
lambda { bd5667.send(@method, 0) }.should raise_error(ZeroDivisionError)
lambda { bd5667.send(@method, BigDecimal("0")) }.should raise_error(ZeroDivisionError)
lambda { @zero.send(@method, @zero) }.should raise_error(ZeroDivisionError)
end
end

@@ -123,98 +111,62 @@ class BigDecimal
# TODO: file MRI bug:
# BigDecimal('1').divmod(BigDecimal('3E-9'))[0] #=> 0.3E9,
# but really should be 0.333333333E9
ruby_bug "#206", "1.8" do #MRI's precision is very low in some cases
values << BigDecimal('1E-10')
values << BigDecimal('-1E-10')
values << BigDecimal('2E55')
values << BigDecimal('-2E55')
values << BigDecimal('2E-5555')
values << BigDecimal('-2E-5555')


values_and_zeroes = values + @zeroes
values_and_zeroes.each do |val1|
values.each do |val2|
res = val1.divmod(val2)
DivmodSpecs::check_both_bigdecimal(res)
res[0].should == ((val1/val2).floor)
res[1].should == (val1 - res[0] * val2)
end
values << BigDecimal('1E-10')
values << BigDecimal('-1E-10')
values << BigDecimal('2E55')
values << BigDecimal('-2E55')
values << BigDecimal('2E-5555')
values << BigDecimal('-2E-5555')


values_and_zeroes = values + @zeroes
values_and_zeroes.each do |val1|
values.each do |val2|
res = val1.divmod(val2)
DivmodSpecs::check_both_bigdecimal(res)
res[0].should == ((val1/val2).floor)
res[1].should == (val1 - res[0] * val2)
end
end
end

ruby_version_is "" ... "1.9" do
it "properly handles special values" do
values = @special_vals + @zeroes
values.each do |val1|
values.each do |val2|
DivmodSpecs::check_both_nan(val1.divmod(val2))
end
end

@special_vals.each do |val1|
@regular_vals.each do |val2|
DivmodSpecs::check_both_nan(val1.divmod(val2))
end
end

@regular_vals.each do |val1|
@special_vals.each do |val2|
DivmodSpecs::check_both_nan(val1.divmod(val2))
end
end
end

it "returns an array of two NaNs if the argument is zero" do
values = @regular_vals + @special_vals
values.each do |val1|
@zeroes.each do |val2|
DivmodSpecs::check_both_nan(val1.divmod(val2))
end
end
it "returns an array of two NaNs if NaN is involved" do
(@special_vals + @regular_vals + @zeroes).each do |val|
DivmodSpecs::check_both_nan(val.divmod(@nan))
DivmodSpecs::check_both_nan(@nan.divmod(val))
end
end

ruby_version_is "1.9" do
it "returns an array of two NaNs if NaN is involved" do
(@special_vals + @regular_vals + @zeroes).each do |val|
DivmodSpecs::check_both_nan(val.divmod(@nan))
DivmodSpecs::check_both_nan(@nan.divmod(val))
it "raises ZeroDivisionError if the divisor is zero" do
(@special_vals + @regular_vals + @zeroes - [@nan]).each do |val|
@zeroes.each do |zero|
lambda { val.divmod(zero) }.should raise_error(ZeroDivisionError)
end
end
end

it "raises ZeroDivisionError if the divisor is zero" do
(@special_vals + @regular_vals + @zeroes - [@nan]).each do |val|
@zeroes.each do |zero|
lambda { val.divmod(zero) }.should raise_error(ZeroDivisionError)
end
end
it "returns an array of Infinity and NaN if the dividend is Infinity" do
@regular_vals.each do |val|
array = @infinity.divmod(val)
array.length.should == 2
array[0].infinite?.should == (val > 0 ? 1 : -1)
array[1].nan?.should == true
end
end

it "returns an array of Infinity and NaN if the dividend is Infinity" do
@regular_vals.each do |val|
array = @infinity.divmod(val)
array.length.should == 2
array[0].infinite?.should == (val > 0 ? 1 : -1)
array[1].nan?.should == true
end
it "returns an array of zero and the dividend if the divisor is Infinity" do
@regular_vals.each do |val|
array = val.divmod(@infinity)
array.length.should == 2
array[0].should == @zero
array[1].should == val
end
end

it "returns an array of zero and the dividend if the divisor is Infinity" do
it "returns an array of two zero if the diviend is zero" do
@zeroes.each do |zero|
@regular_vals.each do |val|
array = val.divmod(@infinity)
array.length.should == 2
array[0].should == @zero
array[1].should == val
end
end

it "returns an array of two zero if the diviend is zero" do
@zeroes.each do |zero|
@regular_vals.each do |val|
zero.divmod(val).should == [@zero, @zero]
end
zero.divmod(val).should == [@zero, @zero]
end
end
end
18 changes: 4 additions & 14 deletions spec/ruby/library/bigdecimal/floor_spec.rb
Original file line number Diff line number Diff line change
@@ -40,20 +40,10 @@
BigDecimal('-0.8').floor.should == -1
end

ruby_version_is "" ... "1.9" do
it "returns the same value, if self is special value" do
@infinity.floor.should == @infinity
@infinity_neg.floor.should == @infinity_neg
@nan.floor.nan?.should == true
end
end

ruby_version_is "1.9" do
it "raise exception, if self is special value" do
lambda { @infinity.floor }.should raise_error(FloatDomainError)
lambda { @infinity_neg.floor }.should raise_error(FloatDomainError)
lambda { @nan.floor }.should raise_error(FloatDomainError)
end
it "raise exception, if self is special value" do
lambda { @infinity.floor }.should raise_error(FloatDomainError)
lambda { @infinity_neg.floor }.should raise_error(FloatDomainError)
lambda { @nan.floor }.should raise_error(FloatDomainError)
end

it "returns n digits right of the decimal point if given n > 0" do
30 changes: 13 additions & 17 deletions spec/ruby/library/bigdecimal/gt_spec.rb
Original file line number Diff line number Diff line change
@@ -64,24 +64,20 @@ def > (other)
(@infinity_neg > @infinity).should == false
end

ruby_bug "redmine:2349", "1.8.7" do
it "properly handles NaN values" do
@values += [@infinity, @infinity_neg, @nan]
@values.each { |val|
(@nan > val).should == false
(val > @nan).should == false
}
end
it "properly handles NaN values" do
@values += [@infinity, @infinity_neg, @nan]
@values.each { |val|
(@nan > val).should == false
(val > @nan).should == false
}
end

ruby_bug "redmine:2349", "1.8.7" do
it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
lambda {@zero > nil }.should raise_error(ArgumentError)
lambda {@infinity > nil }.should raise_error(ArgumentError)
lambda {@infinity_neg > nil }.should raise_error(ArgumentError)
lambda {@mixed > nil }.should raise_error(ArgumentError)
lambda {@pos_int > nil }.should raise_error(ArgumentError)
lambda {@neg_frac > nil }.should raise_error(ArgumentError)
end
it "raises an ArgumentError if the argument can't be coerced into a BigDecimal" do
lambda {@zero > nil }.should raise_error(ArgumentError)
lambda {@infinity > nil }.should raise_error(ArgumentError)
lambda {@infinity_neg > nil }.should raise_error(ArgumentError)
lambda {@mixed > nil }.should raise_error(ArgumentError)
lambda {@pos_int > nil }.should raise_error(ArgumentError)
lambda {@neg_frac > nil }.should raise_error(ArgumentError)
end
end
30 changes: 13 additions & 17 deletions spec/ruby/library/bigdecimal/gte_spec.rb
Original file line number Diff line number Diff line change
@@ -68,24 +68,20 @@ def >= (other)
(@infinity_neg >= @infinity).should == false
end

ruby_bug "redmine:2349", "1.8.7" do
it "properly handles NaN values" do
@values += [@infinity, @infinity_neg, @nan]
@values.each { |val|
(@nan >= val).should == false
(val >= @nan).should == false
}
end
it "properly handles NaN values" do
@values += [@infinity, @infinity_neg, @nan]
@values.each { |val|
(@nan >= val).should == false
(val >= @nan).should == false
}
end

ruby_bug "redmine:2349", "1.8.7" do
it "returns nil if the argument is nil" do
lambda {@zero >= nil }.should raise_error(ArgumentError)
lambda {@infinity >= nil }.should raise_error(ArgumentError)
lambda {@infinity_neg >= nil }.should raise_error(ArgumentError)
lambda {@mixed >= nil }.should raise_error(ArgumentError)
lambda {@pos_int >= nil }.should raise_error(ArgumentError)
lambda {@neg_frac >= nil }.should raise_error(ArgumentError)
end
it "returns nil if the argument is nil" do
lambda {@zero >= nil }.should raise_error(ArgumentError)
lambda {@infinity >= nil }.should raise_error(ArgumentError)
lambda {@infinity_neg >= nil }.should raise_error(ArgumentError)
lambda {@mixed >= nil }.should raise_error(ArgumentError)
lambda {@pos_int >= nil }.should raise_error(ArgumentError)
lambda {@neg_frac >= nil }.should raise_error(ArgumentError)
end
end
37 changes: 0 additions & 37 deletions spec/ruby/library/bigdecimal/induced_from_spec.rb

This file was deleted.

Loading