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
d9c53037
Commit
d9c53037
authored
Jul 09, 2019
by
Ryan Lopopolo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove attempt at spec-compliant Range#max and Range#min from core
parent
4085709a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
105 deletions
+0
-105
mrblib/range.rb
mrblib/range.rb
+0
-63
test/t/range.rb
test/t/range.rb
+0
-42
No files found.
mrblib/range.rb
View file @
d9c53037
...
...
@@ -65,67 +65,4 @@ end
# ISO 15.2.14.3
class
Range
include
Enumerable
def
max
(
&
block
)
val
=
self
.
first
last
=
self
.
last
# numerics are special
if
(
val
.
kind_of?
(
Fixnum
)
||
val
.
kind_of?
(
Float
))
&&
(
last
.
kind_of?
(
Fixnum
)
||
last
.
kind_of?
(
Float
))
return
nil
if
val
>
last
return
nil
if
val
==
last
&&
exclude_end?
max
=
last
max
-=
1
if
exclude_end?
max
=
val
if
block
&&
block
.
call
(
val
,
last
)
>
0
return
max
end
max
=
nil
each
do
|
item
|
max
=
if
max
.
nil?
item
elsif
block
&&
block
.
call
(
max
,
item
)
>
0
item
elsif
item
>
max
item
else
max
end
end
max
end
def
min
(
&
block
)
val
=
self
.
first
last
=
self
.
last
# numerics are special
if
(
val
.
kind_of?
(
Fixnum
)
||
val
.
kind_of?
(
Float
))
&&
(
last
.
kind_of?
(
Fixnum
)
||
last
.
kind_of?
(
Float
))
return
nil
if
val
>
last
return
nil
if
val
==
last
&&
exclude_end?
min
=
val
if
block
&&
block
.
call
(
val
,
last
)
>
0
min
=
last
min
-=
1
if
exclude_end?
end
return
min
end
min
=
nil
each
do
|
item
|
min
=
if
min
.
nil?
item
elsif
block
&&
block
.
call
(
min
,
item
)
<
0
item
elsif
item
<
min
item
else
min
end
end
min
end
end
test/t/range.rb
View file @
d9c53037
...
...
@@ -110,45 +110,3 @@ assert('Range#dup') do
assert_equal
r
.
end
,
"z"
assert_true
r
.
exclude_end?
end
assert
(
'Range#max'
)
do
assert_equal
10
,
(
1
..
10
).
max
assert_equal
9
,
(
1
...
10
).
max
assert_equal
nil
,
(
10
..
1
).
max
assert_equal
nil
,
(
10
...
1
).
max
# equal endpoints
assert_equal
5
,
(
5
..
5
).
max
assert_equal
nil
,
(
5
...
5
).
max
# block overrides comparison
assert_equal
(
10
,
(
1
..
10
).
max
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
9
,
(
1
...
10
).
max
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
nil
,
(
10
..
1
).
max
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
nil
,
(
10
...
1
).
max
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
1
,
(
1
..
10
).
max
{
|
a
,
b
|
b
<=>
a
})
assert_equal
(
1
,
(
1
...
10
).
max
{
|
a
,
b
|
b
<=>
a
})
assert_equal
(
nil
,
(
10
..
1
).
max
{
|
a
,
b
|
b
<=>
a
})
assert_equal
(
nil
,
(
10
...
1
).
max
{
|
a
,
b
|
b
<=>
a
})
end
assert
(
'Range#min'
)
do
assert_equal
1
,
(
1
..
10
).
min
assert_equal
1
,
(
1
...
10
).
min
assert_equal
nil
,
(
10
..
1
).
min
assert_equal
nil
,
(
10
...
1
).
min
# equal endpoints
assert_equal
7
,
(
7
..
7
).
min
assert_equal
nil
,
(
7
...
7
).
min
# block overrides comparison
assert_equal
(
1
,
(
1
..
10
).
min
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
1
,
(
1
...
10
).
min
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
nil
,
(
10
..
1
).
min
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
nil
,
(
10
...
1
).
min
{
|
a
,
b
|
a
<=>
b
})
assert_equal
(
10
,
(
1
..
10
).
min
{
|
a
,
b
|
b
<=>
a
})
assert_equal
(
9
,
(
1
...
10
).
min
{
|
a
,
b
|
b
<=>
a
})
assert_equal
(
nil
,
(
10
..
1
).
min
{
|
a
,
b
|
b
<=>
a
})
assert_equal
(
nil
,
(
10
...
1
).
min
{
|
a
,
b
|
b
<=>
a
})
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