| 1 |
assert('Range#max') do |
| 2 |
# returns the maximum value in the range when called with no arguments |
| 3 |
assert_equal 'l', ('f'..'l').max |
| 4 |
assert_equal 'e', ('a'...'f').max |
| 5 |
|
| 6 |
# returns nil when the endpoint is less than the start point |
| 7 |
assert_equal nil, ('z'..'l').max |
| 8 |
end |
| 9 |
|
| 10 |
assert('Range#max given a block') do |
| 11 |
# returns nil when the endpoint is less than the start point |
| 12 |
assert_equal nil, (('z'..'l').max { |x, y| x <=> y }) |
| 13 |
end |
| 14 |
|
| 15 |
assert('Range#min') do |
| 16 |
# returns the minimum value in the range when called with no arguments |
| 17 |
assert_equal 'f', ('f'..'l').min |
| 18 |
|
| 19 |
# returns nil when the start point is greater than the endpoint |
| 20 |
assert_equal nil, ('z'..'l').min |
| 21 |
end |
| 22 |
|
| 23 |
assert('Range#min given a block') do |
| 24 |
# returns nil when the start point is greater than the endpoint |
| 25 |
assert_equal nil, (('z'..'l').min { |x, y| x <=> y }) |
| 26 |
end |