Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
fe9a58c1
Commit
fe9a58c1
authored
Jul 27, 2019
by
KOBAYASHI Shuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop dependency from `mruby-enum-chain` to `mruby-enum-ext`
parent
2f0a9576
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
mrbgems/mruby-enum-chain/mrblib/chain.rb
mrbgems/mruby-enum-chain/mrblib/chain.rb
+4
-1
mrbgems/mruby-enum-chain/test/enum_chain.rb
mrbgems/mruby-enum-chain/test/enum_chain.rb
+17
-7
No files found.
mrbgems/mruby-enum-chain/mrblib/chain.rb
View file @
fe9a58c1
...
...
@@ -40,8 +40,11 @@ class Enumerator
end
def
rewind
@enums
.
reverse_each
do
|
e
|
i
=
@enums
.
size
-
1
while
0
<=
i
e
=
@enums
[
i
]
e
.
rewind
if
e
.
respond_to?
(
:rewind
)
i
-=
1
end
self
...
...
mrbgems/mruby-enum-chain/test/enum_chain.rb
View file @
fe9a58c1
...
...
@@ -14,7 +14,7 @@ end
assert
(
"Enumerable#+"
)
do
a
=
[].
each
b
=
{}.
reverse_
each
b
=
{}.
each
c
=
Object
.
new
# not has #each method
assert_kind_of
Enumerator
::
Chain
,
a
+
b
...
...
@@ -46,13 +46,13 @@ assert("Enumerator::Chain#each") do
assert_kind_of
Enumerator
,
aa
.
each
assert_equal
[
1
,
2
,
3
,
1
,
2
,
3
],
aa
.
each
.
to_a
aa
=
a
.
chain
(
a
.
reverse_each
)
aa
=
a
.
chain
(
6
..
9
)
assert_kind_of
Enumerator
,
aa
.
each
assert_equal
[
1
,
2
,
3
,
3
,
2
,
1
],
aa
.
each
.
to_a
assert_equal
[
1
,
2
,
3
,
6
,
7
,
8
,
9
],
aa
.
each
.
to_a
aa
=
a
.
chain
(
a
.
reverse_each
,
a
)
aa
=
a
.
chain
(
(
-
3
..-
2
).
each_with_index
,
a
)
assert_kind_of
Enumerator
,
aa
.
each
assert_equal
[
1
,
2
,
3
,
3
,
2
,
1
,
1
,
2
,
3
],
aa
.
each
.
to_a
assert_equal
[
1
,
2
,
3
,
[
-
3
,
0
],
[
-
2
,
1
]
,
1
,
2
,
3
],
aa
.
each
.
to_a
aa
=
a
.
chain
(
Object
.
new
)
assert_kind_of
Enumerator
,
aa
.
each
...
...
@@ -65,12 +65,22 @@ assert("Enumerator::Chain#size") do
aa
=
a
.
chain
(
a
)
assert_equal
6
,
aa
.
size
aa
=
a
.
chain
(
a
.
reverse_each
)
aa
=
a
.
chain
(
3
..
4
)
assert_nil
aa
.
size
aa
=
a
.
chain
(
a
.
reverse_each
,
a
)
aa
=
a
.
chain
(
3
..
4
,
a
)
assert_nil
aa
.
size
aa
=
a
.
chain
(
Object
.
new
)
assert_nil
aa
.
size
end
assert
(
"Enumerator::Chain#rewind"
)
do
rewound
=
[]
e1
=
[
1
,
2
]
e2
=
(
4
..
6
)
(
class
<<
e1
;
self
end
).
define_method
(
:rewind
)
{
rewound
<<
__id__
}
(
class
<<
e2
;
self
end
).
define_method
(
:rewind
)
{
rewound
<<
__id__
}
c
=
e1
.
chain
(
e2
).
each
{}.
rewind
assert_equal
[
e2
.
__id__
,
e1
.
__id__
],
rewound
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment