summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-04 03:34:55 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-04 03:34:55 +0000
commitf1fb989f1a17c63af1062ea402ed50f0d6cb4efa (patch)
tree8df231ea81ad5df2a408c9a5a431421f42516ea9 /test/ruby
parent53d3fe0643c591a9083e22ccea62e49f451fd450 (diff)
enumerator.c: make arith_seq_first support nil begin
* enumerator.c: (arith_seq_first): support nil begin. * test/ruby/test_arithmetic_sequence.rb (test_first): add assertions for beginless and endless arithmetic sequences. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_arithmetic_sequence.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_arithmetic_sequence.rb b/test/ruby/test_arithmetic_sequence.rb
index c9779808ca..5817631944 100644
--- a/test/ruby/test_arithmetic_sequence.rb
+++ b/test/ruby/test_arithmetic_sequence.rb
@@ -170,6 +170,16 @@ class TestArithmeticSequence < Test::Unit::TestCase
assert_equal(10.0, seq.first)
assert_equal([10.0], seq.first(1))
assert_equal([10.0, 8.0, 6.0], seq.first(3))
+
+ seq = (1..).step(2)
+ assert_equal(1, seq.first)
+ assert_equal([1], seq.first(1))
+ assert_equal([1, 3, 5], seq.first(3))
+
+ seq = (..10).step(2)
+ assert_equal(nil, seq.first)
+ assert_raise(TypeError) { seq.first(1) }
+ assert_raise(TypeError) { seq.first(3) }
end
def test_first_bug15518