|
9 | 9 | it_behaves_like :enumeratorized_with_unknown_size, :bsearch, (1..3)
|
10 | 10 |
|
11 | 11 | it "raises a TypeError if the block returns an Object" do
|
12 |
| - -> { (0..1).bsearch { Object.new } }.should raise_error(TypeError) |
| 12 | + -> { (0..1).bsearch { Object.new } }.should raise_error(TypeError, "wrong argument type Object (must be numeric, true, false or nil)") |
13 | 13 | end
|
14 | 14 |
|
15 |
| - it "raises a TypeError if the block returns a String" do |
16 |
| - -> { (0..1).bsearch { "1" } }.should raise_error(TypeError) |
| 15 | + it "raises a TypeError if the block returns a String and boundaries are Integer values" do |
| 16 | + -> { (0..1).bsearch { "1" } }.should raise_error(TypeError, "wrong argument type String (must be numeric, true, false or nil)") |
| 17 | + end |
| 18 | + |
| 19 | + it "raises a TypeError if the block returns a String and boundaries are Float values" do |
| 20 | + -> { (0.0..1.0).bsearch { "1" } }.should raise_error(TypeError, "wrong argument type String (must be numeric, true, false or nil)") |
17 | 21 | end
|
18 | 22 |
|
19 | 23 | it "raises a TypeError if the Range has Object values" do
|
20 | 24 | value = mock("range bsearch")
|
21 | 25 | r = Range.new value, value
|
22 | 26 |
|
23 |
| - -> { r.bsearch { true } }.should raise_error(TypeError) |
| 27 | + -> { r.bsearch { true } }.should raise_error(TypeError, "can't do binary search for MockObject") |
24 | 28 | end
|
25 | 29 |
|
26 | 30 | it "raises a TypeError if the Range has String values" do
|
27 |
| - -> { ("a".."e").bsearch { true } }.should raise_error(TypeError) |
| 31 | + -> { ("a".."e").bsearch { true } }.should raise_error(TypeError, "can't do binary search for String") |
28 | 32 | end
|
29 | 33 |
|
30 | 34 | it "raises TypeError when non-Numeric begin/end and block not passed" do
|
31 |
| - -> { ("a".."e").bsearch }.should raise_error(TypeError) |
| 35 | + -> { ("a".."e").bsearch }.should raise_error(TypeError, "can't do binary search for String") |
32 | 36 | end
|
33 | 37 |
|
34 | 38 | context "with Integer values" do
|
|
0 commit comments