diff options
author | Kenta Murata <[email protected]> | 2020-12-09 18:48:59 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-09 18:48:59 +0900 |
commit | fad3023e94c45e7f03478732f7641b6f39ba9d12 (patch) | |
tree | a53e562ae444a5b3f8d76308af62afd2f5c5c985 /test/ruby/test_arithmetic_sequence.rb | |
parent | cacdf2681dcc7c431973f33a18979b10566ec2f9 (diff) |
Fix ArithmeticSequence#last and ArithmeticSequence#each for non-integer sequences (#3870)
[Bug #17218]
[ruby-core:100312]
Notes
Notes:
Merged-By: mrkn <[email protected]>
Diffstat (limited to 'test/ruby/test_arithmetic_sequence.rb')
-rw-r--r-- | test/ruby/test_arithmetic_sequence.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_arithmetic_sequence.rb b/test/ruby/test_arithmetic_sequence.rb index 70ec113e61..a1193637ef 100644 --- a/test/ruby/test_arithmetic_sequence.rb +++ b/test/ruby/test_arithmetic_sequence.rb @@ -264,6 +264,11 @@ class TestArithmeticSequence < Test::Unit::TestCase assert_instance_of Integer, res[1] end + def test_last_bug17218 + seq = (1.0997r .. 1.1r).step(0.0001r) + assert_equal(1.1r, seq.last, '[ruby-core:100312] [Bug #17218]') + end + def test_to_a assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 1.step(10).to_a) assert_equal([1, 3, 5, 7, 9], 1.step(10, 2).to_a) @@ -279,6 +284,11 @@ class TestArithmeticSequence < Test::Unit::TestCase '[ruby-core:90648] [Bug #15444]') end + def test_last_bug17218 + seq = (1.0997r .. 1.1r).step(0.0001r) + assert_equal([1.0997r, 1.0998r, 1.0999r, 1.1r], seq.to_a, '[ruby-core:100312] [Bug #17218]') + end + def test_slice seq = 1.step(10, 2) assert_equal([[1, 3, 5], [7, 9]], seq.each_slice(3).to_a) |