diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-07-09 18:44:53 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-09 18:44:53 +0900 |
| commit | 59a76d48f878c74be2d45a2024ba287cf3c5c003 (patch) | |
| tree | b3248d88dc2e534cd753527b918194b14a4818c0 /mrbgems/mruby-string-ext/test/range.rb | |
| parent | 9add4a66c0cccf0f9ce738ea5dda4d8e960fff7b (diff) | |
| parent | 3b77b5fd394f9c9ba841e7bea8ea62dc6e8a3a1b (diff) | |
| download | mruby-59a76d48f878c74be2d45a2024ba287cf3c5c003.tar.gz mruby-59a76d48f878c74be2d45a2024ba287cf3c5c003.zip | |
Merge pull request #4560 from lopopolo/range-max-min-hang
Specialize Enumerable#max and Enumerable#min for Range
Diffstat (limited to 'mrbgems/mruby-string-ext/test/range.rb')
| -rw-r--r-- | mrbgems/mruby-string-ext/test/range.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mrbgems/mruby-string-ext/test/range.rb b/mrbgems/mruby-string-ext/test/range.rb new file mode 100644 index 000000000..80c286850 --- /dev/null +++ b/mrbgems/mruby-string-ext/test/range.rb @@ -0,0 +1,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 |
