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
ddfc4eb5
Commit
ddfc4eb5
authored
Jun 19, 2014
by
Tomoyuki Sahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IO#read(0) should return "" immediately. fixes iij/mruby-socket#13.
parent
d894de86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
mrblib/io.rb
mrblib/io.rb
+10
-5
test/io.rb
test/io.rb
+1
-0
No files found.
mrblib/io.rb
View file @
ddfc4eb5
...
...
@@ -171,11 +171,16 @@ class IO
end
def
read
(
length
=
nil
)
unless
length
.
nil?
or
length
.
class
==
Fixnum
raise
TypeError
.
new
"can't convert
#{
length
.
class
}
into Integer"
end
if
length
&&
length
<
0
raise
ArgumentError
.
new
"negative length:
#{
length
}
given"
unless
length
.
nil?
unless
length
.
is_a?
Fixnum
raise
TypeError
.
new
"can't convert
#{
length
.
class
}
into Integer"
end
if
length
<
0
raise
ArgumentError
.
new
"negative length:
#{
length
}
given"
end
if
length
==
0
return
""
# easy case
end
end
str
=
''
...
...
test/io.rb
View file @
ddfc4eb5
...
...
@@ -93,6 +93,7 @@ assert('IO#read', '15.2.20.5.14') do
assert_raise
(
TypeError
)
{
io
.
read
(
"str"
)
}
len
=
$mrbtest_io_msg
.
length
assert_equal
''
,
io
.
read
(
0
)
assert_equal
'mruby'
,
io
.
read
(
5
)
assert_equal
$mrbtest_io_msg
[
5
,
len
],
io
.
read
(
len
)
...
...
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