From eab07daf92c9a8a2836923656d9e8f58583a52ba Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Tue, 9 Jul 2019 01:41:10 -0700 Subject: Add Range#max and Range#min tests from Ruby Spec --- mrbgems/mruby-string-ext/test/range.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'mrbgems/mruby-string-ext') diff --git a/mrbgems/mruby-string-ext/test/range.rb b/mrbgems/mruby-string-ext/test/range.rb index 4b42cd3a6..80c286850 100644 --- a/mrbgems/mruby-string-ext/test/range.rb +++ b/mrbgems/mruby-string-ext/test/range.rb @@ -1,12 +1,26 @@ assert('Range#max') do - # string Range depends on String#upto + # 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 - # string Range depends on String#upto + # 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 -- cgit v1.2.3