summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 15:59:13 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 15:59:13 +0000
commit97a75996f13e71014fe4dd91f9cacf7fd21079ce (patch)
treee53fdcc1bf18aae6a76a8670e7c589c9c44d104a
parent12f8717110b15fc6b4b69935a9b41d3695c5d9c9 (diff)
downloadruby-97a75996f13e71014fe4dd91f9cacf7fd21079ce.tar.gz
(merged partially from r42781)
* test/ruby/test_numeric.rb (assert_step): introduce assert_step. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_numeric.rb65
-rw-r--r--version.h2
3 files changed, 43 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 5789fa2fb2..c719dfb0d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Mar 3 00:43:33 2014 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
+
+ (merged partially from r42781)
+ * test/ruby/test_numeric.rb (assert_step): introduce assert_step.
+
Mon Mar 3 00:24:38 2014 Zachary Scott <e@zzak.io>
* README.EXT.ja: [DOC] Fix typo "macro macro" @utenmiki [Fixes GH-551]
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index 5cd0de66e8..b99ce988a1 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -213,41 +213,50 @@ class TestNumeric < Test::Unit::TestCase
end
end
- def test_step
- a = []
- 1.step(10) {|x| a << x }
- assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], a)
-
- a = []
- 1.step(10, 2) {|x| a << x }
- assert_equal([1, 3, 5, 7, 9], a)
+ def assert_step(expected, (from, *args), inf: false)
+ enum = from.step(*args)
+ size = enum.size
+ xsize = expected.size
+
+ if inf
+ assert_send [size, :infinite?], "step size: +infinity"
+ assert_send [size, :>, 0], "step size: +infinity"
+
+ a = []
+ from.step(*args) { |x| a << x; break if a.size == xsize }
+ assert_equal expected, a, "step"
+
+ a = []
+ enum.each { |x| a << x; break if a.size == xsize }
+ assert_equal expected, a, "step enumerator"
+ else
+ assert_equal expected.size, size, "step size"
+
+ a = []
+ from.step(*args) { |x| a << x }
+ assert_equal expected, a, "step"
+
+ a = []
+ enum.each { |x| a << x }
+ assert_equal expected, a, "step enumerator"
+ end
+ end
+ def test_step
assert_raise(ArgumentError) { 1.step(10, 1, 0) { } }
assert_raise(ArgumentError) { 1.step(10, 0) { } }
- a = []
- 10.step(1, -2) {|x| a << x }
- assert_equal([10, 8, 6, 4, 2], a)
-
- a = []
- 1.0.step(10.0, 2.0) {|x| a << x }
- assert_equal([1.0, 3.0, 5.0, 7.0, 9.0], a)
-
- a = []
- 1.step(10, 2**32) {|x| a << x }
- assert_equal([1], a)
+ assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 10]
+ assert_step [1, 3, 5, 7, 9], [1, 10, 2]
- a = []
- 10.step(1, -(2**32)) {|x| a << x }
- assert_equal([10], a)
+ assert_step [10, 8, 6, 4, 2], [10, 1, -2]
+ assert_step [1.0, 3.0, 5.0, 7.0, 9.0], [1.0, 10.0, 2.0]
+ assert_step [1], [1, 10, 2**32]
- a = []
- 1.step(0, Float::INFINITY) {|x| a << x }
- assert_equal([], a)
+ assert_step [10], [10, 1, -(2**32)]
- a = []
- 0.step(1, -Float::INFINITY) {|x| a << x }
- assert_equal([], a)
+ assert_step [], [1, 0, Float::INFINITY]
+ assert_step [], [0, 1, -Float::INFINITY]
end
def test_num2long
diff --git a/version.h b/version.h
index 20f837a7ba..8e446ea6b3 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2014-03-03"
-#define RUBY_PATCHLEVEL 452
+#define RUBY_PATCHLEVEL 453
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 3