File: range.rb

package info (click to toggle)
nghttp2 1.68.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,592 kB
  • sloc: ansic: 104,233; cpp: 55,792; ruby: 30,108; yacc: 7,083; sh: 4,643; makefile: 1,506; python: 806
file content (26 lines) | stat: -rw-r--r-- 833 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
assert('Range#max') do
  # returns the maximum value in the range when called with no arguments
  assert_equal 'l', ('f'..'l').max
  assert_equal 'e', ('a'...'f').max

  # returns nil when the endpoint is less than the start point
  assert_equal nil, ('z'..'l').max
end

assert('Range#max given a block') do
  # returns nil when the endpoint is less than the start point
  assert_equal nil, (('z'..'l').max { |x, y| x <=> y })
end

assert('Range#min') do
  # returns the minimum value in the range when called with no arguments
  assert_equal 'f', ('f'..'l').min

  # returns nil when the start point is greater than the endpoint
  assert_equal nil, ('z'..'l').min
end

assert('Range#min given a block') do
  # returns nil when the start point is greater than the endpoint
  assert_equal nil, (('z'..'l').min { |x, y| x <=> y })
end