diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-25 05:42:28 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-25 05:42:28 +0000 |
commit | 9c5a4caf72e0674f19e346487f6acb0dafab22c1 (patch) | |
tree | a0586302c5b27b99a5dfad0851a19877f0c92952 /test | |
parent | 689cc98238867859689928d07f9355dd181274ff (diff) | |
download | ruby-9c5a4caf72e0674f19e346487f6acb0dafab22c1.tar.gz |
* range.c (range_max): treat end exclusion without iteration if
the end value is an integer. [ruby-talk:167433]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_range.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index f0e0da2fd6..31f7e29de4 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -31,4 +31,24 @@ class TestRange < Test::Unit::TestCase def test_duckrange assert_equal("bc", "abcd"[DuckRange.new(1,2)]) end + + def test_min + assert_equal(1, (1..2).min) + assert_equal(nil, (2..1).min) + assert_equal(1, (1...2).min) + + assert_equal(1.0, (1.0..2.0).min) + assert_equal(nil, (2.0..1.0).min) + assert_equal(1, (1.0...2.0).min) + end + + def test_max + assert_equal(2, (1..2).max) + assert_equal(nil, (2..1).max) + assert_equal(1, (1...2).max) + + assert_equal(2.0, (1.0..2.0).max) + assert_equal(nil, (2.0..1.0).max) + assert_raise(TypeError) { (1.0...2.0).max } + end end |