diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-07-22 00:58:48 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-07-23 16:57:26 +0900 |
commit | 6b3cff12f6add831c678ce7a5288097714bc6850 (patch) | |
tree | ac311f01d7d539c9577945e97314c81a9205b12b /test/ruby/test_lazy_enumerator.rb | |
parent | 89a86788e66def6f2778926528f63e353935574b (diff) |
Improved Enumerable::Lazy#flat_map
| |compare-ruby|built-ruby|
|:-------|-----------:|---------:|
|num3 | 96.333k| 160.732k|
| | -| 1.67x|
|num10 | 96.615k| 159.150k|
| | -| 1.65x|
|ary2 | 103.836k| 172.787k|
| | -| 1.66x|
|ary10 | 109.249k| 177.252k|
| | -| 1.62x|
|ary20 | 106.628k| 177.371k|
| | -| 1.66x|
|ary50 | 107.135k| 162.282k|
| | -| 1.51x|
|ary100 | 106.513k| 177.626k|
| | -| 1.67x|
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3339
Diffstat (limited to 'test/ruby/test_lazy_enumerator.rb')
-rw-r--r-- | test/ruby/test_lazy_enumerator.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb index 6e5c1714a5..3f5a05555b 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -160,6 +160,10 @@ class TestLazyEnumerator < Test::Unit::TestCase assert_equal([{?a=>97}, {?b=>98}, {?c=>99}], [?a, ?b, ?c].lazy.flat_map {|x| {x=>x.ord}}.force) end + def test_flat_map_take + assert_equal([1,2]*3, [[1,2]].cycle.lazy.take(3).flat_map {|x| x}.to_a) + end + def test_reject a = Step.new(1..6) assert_equal(4, a.reject {|x| x < 4}.first) |