Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions spec/core/exception/errno_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
# From http://jira.codehaus.org/browse/JRUBY-4747
it "is the same class as Errno::EWOULDBLOCK if they represent the same errno value" do
if Errno::EAGAIN::Errno == Errno::EWOULDBLOCK::Errno
NATFIXME 'it is the same class as Errno::EWOULDBLOCK if they represent the same errno value', exception: SpecFailedException do
Errno::EAGAIN.should == Errno::EWOULDBLOCK
end
Errno::EAGAIN.should == Errno::EWOULDBLOCK
else
Errno::EAGAIN.should_not == Errno::EWOULDBLOCK
end
Expand All @@ -54,9 +52,7 @@

it "is the same class as Errno::EOPNOTSUPP if they represent the same errno value" do
if Errno::ENOTSUP::Errno == Errno::EOPNOTSUPP::Errno
NATFIXME 'it is the same class as Errno::EOPNOTSUPP if they represent the same errno value', exception: SpecFailedException do
Errno::ENOTSUP.should == Errno::EOPNOTSUPP
end
Errno::ENOTSUP.should == Errno::EOPNOTSUPP
else
Errno::ENOTSUP.should_not == Errno::EOPNOTSUPP
end
Expand Down
12 changes: 9 additions & 3 deletions src/errno.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,13 @@ module Errno
end

SystemCallError::ERRORS.each do |name, (number, _desc)|
klass = Class.new(SystemCallError)
klass.const_set(:Errno, number)
Errno.const_set(name, klass)
first_name, = SystemCallError::ERRORS.find { |_name, (number2, _desc)| number == number2 }
if first_name != name
klass = Errno.const_get(first_name)
Errno.const_set(name, klass)
else
klass = Class.new(SystemCallError)
klass.const_set(:Errno, number)
Errno.const_set(name, klass)
end
end
15 changes: 10 additions & 5 deletions src/io.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,17 @@ class EAGAINWaitWritable < Errno::EAGAIN
include IO::WaitWritable
end

class EWOULDBLOCKWaitReadable < Errno::EWOULDBLOCK
include IO::WaitReadable
end
if Errno::EAGAIN.equal?(Errno::EWOULDBLOCK)
EWOULDBLOCKWaitReadable = EAGAINWaitReadable
EWOULDBLOCKWaitWritable = EAGAINWaitWritable
else
class EWOULDBLOCKWaitReadable < Errno::EWOULDBLOCK
include IO::WaitReadable
end

class EWOULDBLOCKWaitWritable < Errno::EWOULDBLOCK
include IO::WaitWritable
class EWOULDBLOCKWaitWritable < Errno::EWOULDBLOCK
include IO::WaitWritable
end
end

class EINPROGRESSWaitReadable < Errno::EINPROGRESS
Expand Down
Loading