summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-string-ext/test
diff options
context:
space:
mode:
authorRyan Lopopolo <[email protected]>2019-07-09 01:41:10 -0700
committerRyan Lopopolo <[email protected]>2019-07-09 01:41:10 -0700
commiteab07daf92c9a8a2836923656d9e8f58583a52ba (patch)
tree03aac1f676cd10d5f8690b14dbac7797bdfc1b7f /mrbgems/mruby-string-ext/test
parentd9c530379343ef0dd0f314c982ddeedea8eb1a60 (diff)
downloadmruby-eab07daf92c9a8a2836923656d9e8f58583a52ba.tar.gz
mruby-eab07daf92c9a8a2836923656d9e8f58583a52ba.zip
Add Range#max and Range#min tests from Ruby Spec
Diffstat (limited to 'mrbgems/mruby-string-ext/test')
-rw-r--r--mrbgems/mruby-string-ext/test/range.rb18
1 files changed, 16 insertions, 2 deletions
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