mruby-cmath: add README.md
[mruby.git] / mrbgems / mruby-string-ext / test / range.rb
blob80c286850a66474abee58d75872b874236052e79
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
6   # returns nil when the endpoint is less than the start point
7   assert_equal nil, ('z'..'l').max
8 end
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
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
19   # returns nil when the start point is greater than the endpoint
20   assert_equal nil, ('z'..'l').min
21 end
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