Skip to content

Commit

Permalink
Showing 98 changed files with 2,173 additions and 70 deletions.
34 changes: 6 additions & 28 deletions core/src/main/java/org/jruby/runtime/load/LoadService.java
Original file line number Diff line number Diff line change
@@ -393,43 +393,17 @@ public SearchState findFileForLoad(String file) {
}

public boolean require(String requireName) {
return requireCommon(requireName, true) == RequireState.LOADED;
return smartLoadInternal(requireName, true) == RequireState.LOADED;
}

public boolean autoloadRequire(String requireName) {
return requireCommon(requireName, false) != RequireState.CIRCULAR;
return smartLoadInternal(requireName, false) != RequireState.CIRCULAR;
}

private enum RequireState {
LOADED, ALREADY_LOADED, CIRCULAR
}

private RequireState requireCommon(String file, boolean circularRequireWarning) {
checkEmptyLoad(file);

// check with short name
if (featureAlreadyLoaded(file)) {
return RequireState.ALREADY_LOADED;
}

SearchState state = findFileForLoad(file);

if (state.library == null) {
throw runtime.newLoadError("no such file to load -- " + state.searchFile, state.searchFile);
}

// check with long name
if (featureAlreadyLoaded(state.loadName)) {
return RequireState.ALREADY_LOADED;
}

if (!runtime.getProfile().allowRequire(file)) {
throw runtime.newLoadError("no such file to load -- " + file, file);
}

return smartLoadInternal(file, circularRequireWarning);
}

private final RequireLocks requireLocks = new RequireLocks();

private static final class RequireLocks {
@@ -519,6 +493,10 @@ private RequireState smartLoadInternal(String file, boolean circularRequireWarni
return RequireState.ALREADY_LOADED;
}

if (!runtime.getProfile().allowRequire(file)) {
throw runtime.newLoadError("no such file to load -- " + file, file);
}

if (!requireLocks.lock(state.loadName)) {
if (circularRequireWarning && runtime.isVerbose()) {
warnCircularRequire(state.loadName);
1 change: 1 addition & 0 deletions spec/mspec/lib/mspec/matchers.rb
Original file line number Diff line number Diff line change
@@ -36,3 +36,4 @@
require 'mspec/matchers/output_to_fd'
require 'mspec/matchers/respond_to'
require 'mspec/matchers/signed_zero'
require 'mspec/matchers/block_caller'
35 changes: 35 additions & 0 deletions spec/mspec/lib/mspec/matchers/block_caller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class BlockingMatcher
def matches?(block)
started = false
blocking = true

thread = Thread.new do
started = true
block.call

blocking = false
end

while !started and status = thread.status and status != "sleep"
Thread.pass
end
thread.kill
thread.join

blocking
end

def failure_message
['Expected the given Proc', 'to block the caller']
end

def negative_failure_message
['Expected the given Proc', 'to not block the caller']
end
end

class Object
def block_caller(timeout = 0.1)
BlockingMatcher.new
end
end
13 changes: 13 additions & 0 deletions spec/mspec/spec/matchers/block_caller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'spec_helper'
require 'mspec/expectations/expectations'
require 'mspec/matchers'

describe BlockingMatcher do
it 'matches when a Proc blocks the caller' do
BlockingMatcher.new.matches?(proc { sleep }).should == true
end

it 'does not match when a Proc does not block the caller' do
BlockingMatcher.new.matches?(proc { 1 }).should == false
end
end
3 changes: 3 additions & 0 deletions spec/ruby/.travis.yml
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@ rvm:
- 2.2.4
- 2.3.0
- ruby-head
matrix:
allow_failures:
- rvm: ruby-head
install:
- git clone https://github.com/ruby/mspec.git ../mspec
script:
34 changes: 34 additions & 0 deletions spec/ruby/core/kernel/public_send_spec.rb
Original file line number Diff line number Diff line change
@@ -44,6 +44,40 @@ def bar
}.should raise_error(NoMethodError)
end

context 'called from own public method' do
before do
class << @receiver = Object.new
def call_protected_method
public_send :protected_method
end

def call_private_method
public_send :private_method
end

protected

def protected_method
raise 'Should not called'
end

private

def private_method
raise 'Should not called'
end
end
end

it "raises a NoMethodError if the method is protected" do
lambda { @receiver.call_protected_method }.should raise_error(NoMethodError)
end

it "raises a NoMethodError if the method is private" do
lambda { @receiver.call_private_method }.should raise_error(NoMethodError)
end
end

it "raises a NoMethodError if the named method is an alias of a private method" do
class KernelSpecs::Foo
private
17 changes: 17 additions & 0 deletions spec/ruby/core/module/define_method_spec.rb
Original file line number Diff line number Diff line change
@@ -266,6 +266,23 @@ def foo
}.should raise_error(TypeError)
end

it "accepts an UnboundMethod from an attr_accessor method" do
class DefineMethodSpecClass
attr_accessor :accessor_method
end

m = DefineMethodSpecClass.instance_method(:accessor_method)
o = DefineMethodSpecClass.new

DefineMethodSpecClass.send(:undef_method, :accessor_method)
lambda { o.accessor_method }.should raise_error(NoMethodError)

DefineMethodSpecClass.send(:define_method, :accessor_method, m)

o.accessor_method = :abc
o.accessor_method.should == :abc
end

it "accepts a proc from a method" do
class ProcFromMethod
attr_accessor :data
10 changes: 9 additions & 1 deletion spec/ruby/core/numeric/step_spec.rb
Original file line number Diff line number Diff line change
@@ -72,6 +72,14 @@
it "should return infinity_value when step is 0.0" do
1.step(to: 2, by: 0.0).size.should == infinity_value
end

it "should return infinity_value when the limit is Float::INFINITY" do
1.step(to: Float::INFINITY, by: 42).size.should == infinity_value
end

it "should return 1 when the both limit and step are Float::INFINITY" do
1.step(to: Float::INFINITY, by: Float::INFINITY).size.should == 1
end
end
end
end
@@ -130,7 +138,7 @@
# a mix of positional and keyword arguments.
# It's needed to test numeric_step behaviour with positional mixed with
# keyword arguments.
@step_args = ->(*args) do
@step_args = ->(*args) do
if args.size == 2
[args[0], {by: args[1]}]
else
105 changes: 72 additions & 33 deletions spec/ruby/core/string/dump_spec.rb
Original file line number Diff line number Diff line change
@@ -343,39 +343,78 @@
].should be_computed_by(:dump)
end

it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do
[ [0200.chr('utf-8'), '"\u{80}"'],
[0201.chr('utf-8'), '"\u{81}"'],
[0202.chr('utf-8'), '"\u{82}"'],
[0203.chr('utf-8'), '"\u{83}"'],
[0204.chr('utf-8'), '"\u{84}"'],
[0206.chr('utf-8'), '"\u{86}"'],
[0207.chr('utf-8'), '"\u{87}"'],
[0210.chr('utf-8'), '"\u{88}"'],
[0211.chr('utf-8'), '"\u{89}"'],
[0212.chr('utf-8'), '"\u{8a}"'],
[0213.chr('utf-8'), '"\u{8b}"'],
[0214.chr('utf-8'), '"\u{8c}"'],
[0215.chr('utf-8'), '"\u{8d}"'],
[0216.chr('utf-8'), '"\u{8e}"'],
[0217.chr('utf-8'), '"\u{8f}"'],
[0220.chr('utf-8'), '"\u{90}"'],
[0221.chr('utf-8'), '"\u{91}"'],
[0222.chr('utf-8'), '"\u{92}"'],
[0223.chr('utf-8'), '"\u{93}"'],
[0224.chr('utf-8'), '"\u{94}"'],
[0225.chr('utf-8'), '"\u{95}"'],
[0226.chr('utf-8'), '"\u{96}"'],
[0227.chr('utf-8'), '"\u{97}"'],
[0230.chr('utf-8'), '"\u{98}"'],
[0231.chr('utf-8'), '"\u{99}"'],
[0232.chr('utf-8'), '"\u{9a}"'],
[0233.chr('utf-8'), '"\u{9b}"'],
[0234.chr('utf-8'), '"\u{9c}"'],
[0235.chr('utf-8'), '"\u{9d}"'],
[0236.chr('utf-8'), '"\u{9e}"'],
[0237.chr('utf-8'), '"\u{9f}"'],
].should be_computed_by(:dump)
ruby_version_is ''...'2.4' do
it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do
[ [0200.chr('utf-8'), '"\u{80}"'],
[0201.chr('utf-8'), '"\u{81}"'],
[0202.chr('utf-8'), '"\u{82}"'],
[0203.chr('utf-8'), '"\u{83}"'],
[0204.chr('utf-8'), '"\u{84}"'],
[0206.chr('utf-8'), '"\u{86}"'],
[0207.chr('utf-8'), '"\u{87}"'],
[0210.chr('utf-8'), '"\u{88}"'],
[0211.chr('utf-8'), '"\u{89}"'],
[0212.chr('utf-8'), '"\u{8a}"'],
[0213.chr('utf-8'), '"\u{8b}"'],
[0214.chr('utf-8'), '"\u{8c}"'],
[0215.chr('utf-8'), '"\u{8d}"'],
[0216.chr('utf-8'), '"\u{8e}"'],
[0217.chr('utf-8'), '"\u{8f}"'],
[0220.chr('utf-8'), '"\u{90}"'],
[0221.chr('utf-8'), '"\u{91}"'],
[0222.chr('utf-8'), '"\u{92}"'],
[0223.chr('utf-8'), '"\u{93}"'],
[0224.chr('utf-8'), '"\u{94}"'],
[0225.chr('utf-8'), '"\u{95}"'],
[0226.chr('utf-8'), '"\u{96}"'],
[0227.chr('utf-8'), '"\u{97}"'],
[0230.chr('utf-8'), '"\u{98}"'],
[0231.chr('utf-8'), '"\u{99}"'],
[0232.chr('utf-8'), '"\u{9a}"'],
[0233.chr('utf-8'), '"\u{9b}"'],
[0234.chr('utf-8'), '"\u{9c}"'],
[0235.chr('utf-8'), '"\u{9d}"'],
[0236.chr('utf-8'), '"\u{9e}"'],
[0237.chr('utf-8'), '"\u{9f}"'],
].should be_computed_by(:dump)
end
end

ruby_version_is '2.4' do
it "returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits" do
[ [0200.chr('utf-8'), '"\u0080"'],
[0201.chr('utf-8'), '"\u0081"'],
[0202.chr('utf-8'), '"\u0082"'],
[0203.chr('utf-8'), '"\u0083"'],
[0204.chr('utf-8'), '"\u0084"'],
[0206.chr('utf-8'), '"\u0086"'],
[0207.chr('utf-8'), '"\u0087"'],
[0210.chr('utf-8'), '"\u0088"'],
[0211.chr('utf-8'), '"\u0089"'],
[0212.chr('utf-8'), '"\u008A"'],
[0213.chr('utf-8'), '"\u008B"'],
[0214.chr('utf-8'), '"\u008C"'],
[0215.chr('utf-8'), '"\u008D"'],
[0216.chr('utf-8'), '"\u008E"'],
[0217.chr('utf-8'), '"\u008F"'],
[0220.chr('utf-8'), '"\u0090"'],
[0221.chr('utf-8'), '"\u0091"'],
[0222.chr('utf-8'), '"\u0092"'],
[0223.chr('utf-8'), '"\u0093"'],
[0224.chr('utf-8'), '"\u0094"'],
[0225.chr('utf-8'), '"\u0095"'],
[0226.chr('utf-8'), '"\u0096"'],
[0227.chr('utf-8'), '"\u0097"'],
[0230.chr('utf-8'), '"\u0098"'],
[0231.chr('utf-8'), '"\u0099"'],
[0232.chr('utf-8'), '"\u009A"'],
[0233.chr('utf-8'), '"\u009B"'],
[0234.chr('utf-8'), '"\u009C"'],
[0235.chr('utf-8'), '"\u009D"'],
[0236.chr('utf-8'), '"\u009E"'],
[0237.chr('utf-8'), '"\u009F"'],
].should be_computed_by(:dump)
end
end

it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do
8 changes: 8 additions & 0 deletions spec/ruby/core/thread/name_spec.rb
Original file line number Diff line number Diff line change
@@ -44,5 +44,13 @@
@thread.name = nil
@thread.name.should == nil
end

it "calls #to_str to convert name to String" do
name = mock("Thread#name")
name.should_receive(:to_str).and_return("a thread name")

@thread.name = name
@thread.name.should == "a thread name"
end
end
end
31 changes: 31 additions & 0 deletions spec/ruby/library/etc/struct_group_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'

describe "Struct::Group" do
platform_is_not :windows do
before :all do
@g = Etc.getgrgid(`id -g`.strip.to_i)
end

it "returns group name" do
@g.name.should == `id -gn`.strip
end

it "returns group password" do
@g.passwd.is_a?(String).should == true
end

it "returns group id" do
@g.gid.should == `id -g`.strip.to_i
end

it "returns an array of users belonging to the group" do
@g.mem.is_a?(Array).should == true
end

it "can be compared to another object" do
(@g == nil).should == false
(@g == Object.new).should == false
end
end
end
43 changes: 43 additions & 0 deletions spec/ruby/library/etc/struct_passwd_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'etc'

describe "Struct::Passwd" do
platform_is_not :windows do
before :all do
@pw = Etc.getpwuid(`id -u`.strip.to_i)
end

it "returns user name" do
@pw.name.should == `id -un`.strip
end

it "returns user password" do
@pw.passwd.is_a?(String).should == true
end

it "returns user id" do
@pw.uid.should == `id -u`.strip.to_i
end

it "returns user group id" do
@pw.gid.should == `id -g`.strip.to_i
end

it "returns user personal information (gecos field)" do
@pw.gecos.is_a?(String).should == true
end

it "returns user home directory" do
@pw.dir.is_a?(String).should == true
end

it "returns user shell" do
@pw.shell.is_a?(String).should == true
end

it "can be compared to another object" do
(@pw == nil).should == false
(@pw == Object.new).should == false
end
end
end
32 changes: 32 additions & 0 deletions spec/ruby/library/find/find_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/common', __FILE__)
require 'find'

describe "Find.find" do
it "needs to be reviewed for spec completeness"

before :all do
FindDirSpecs.create_mock_dirs
end

after :all do
FindDirSpecs.delete_mock_dirs
end

describe "when called without a block" do
it "returns an Enumerator" do
Find.find(FindDirSpecs.mock_dir).should be_an_instance_of(enumerator_class)
Find.find(FindDirSpecs.mock_dir).to_a.sort.should == FindDirSpecs.expected_paths
end
end

it "should recursively yield every file in the directory" do
a = []

Find.find(FindDirSpecs.mock_dir) do |file|
a << file
end

a.sort.should == FindDirSpecs.expected_paths
end
end
174 changes: 174 additions & 0 deletions spec/ruby/library/find/fixtures/common.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
module FindDirSpecs
def self.mock_dir(dirs = ['find_specs_mock'])
@mock_dir ||= tmp("")
File.join @mock_dir, dirs
end

# The names of the fixture directories and files used by
# various Find specs.
def self.mock_dir_files
unless @mock_dir_files
@mock_dir_files = %w[
.dotfile
.dotsubdir/.dotfile
.dotsubdir/nondotfile

deeply/.dotfile
deeply/nested/.dotfile.ext
deeply/nested/directory/structure/.ext
deeply/nested/directory/structure/bar
deeply/nested/directory/structure/baz
deeply/nested/directory/structure/file_one
deeply/nested/directory/structure/file_one.ext
deeply/nested/directory/structure/foo
deeply/nondotfile

file_one.ext
file_two.ext

dir_filename_ordering
dir/filename_ordering

nondotfile

subdir_one/.dotfile
subdir_one/nondotfile
subdir_two/nondotfile
subdir_two/nondotfile.ext

brace/a
brace/a.js
brace/a.erb
brace/a.js.rjs
brace/a.html.erb

special/+

special/^
special/$

special/(
special/)
special/[
special/]
special/{
special/}

special/test{1}/file[1]
]

platform_is_not :windows do
@mock_dir_files += %w[
special/*
special/?

special/|
]
end
end

@mock_dir_files
end

def self.create_mock_dirs
umask = File.umask 0
mock_dir_files.each do |name|
file = File.join mock_dir, name
mkdir_p File.dirname(file)
touch file
end
File.umask umask
end

def self.delete_mock_dirs
rm_r mock_dir
end

def self.expected_paths
unless @expected_paths
@expected_paths = %w[
.dotfile

.dotsubdir
.dotsubdir/.dotfile
.dotsubdir/nondotfile

deeply
deeply/.dotfile

deeply/nested
deeply/nested/.dotfile.ext

deeply/nested/directory

deeply/nested/directory/structure
deeply/nested/directory/structure/.ext
deeply/nested/directory/structure/bar
deeply/nested/directory/structure/baz
deeply/nested/directory/structure/file_one
deeply/nested/directory/structure/file_one.ext
deeply/nested/directory/structure/foo
deeply/nondotfile

file_one.ext
file_two.ext

dir_filename_ordering

dir
dir/filename_ordering

nondotfile

subdir_one
subdir_one/.dotfile
subdir_one/nondotfile

subdir_two
subdir_two/nondotfile
subdir_two/nondotfile.ext

brace
brace/a
brace/a.js
brace/a.erb
brace/a.js.rjs
brace/a.html.erb

special
special/+

special/^
special/$

special/(
special/)
special/[
special/]
special/{
special/}

special/test{1}
special/test{1}/file[1]
]

platform_is_not :windows do
@expected_paths += %w[
special/*
special/?

special/|
]
end

@expected_paths.map! do |file|
File.join(mock_dir, file)
end

@expected_paths << mock_dir
@expected_paths.sort!
end

@expected_paths
end
end
12 changes: 12 additions & 0 deletions spec/ruby/library/find/prune_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'find'

describe "Find.prune" do
it "should throw :prune" do
msg = catch(:prune) do
Find.prune
end

msg.should == nil
end
end
14 changes: 14 additions & 0 deletions spec/ruby/library/matrix/vector/cross_product_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'matrix'

describe "Vector#cross_product" do
it "returns the cross product of a vector" do
Vector[1, 2, 3].cross_product(Vector[0, -4, 5]).should == Vector[22, -5, -4]
end

it "raises an error unless both vectors have dimension 3" do
lambda {
Vector[1, 2, 3].cross_product(Vector[0, -4])
}.should raise_error(Vector::ErrDimensionMismatch)
end
end
10 changes: 10 additions & 0 deletions spec/ruby/library/pathname/realdirpath_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'

describe "Pathname#realdirpath" do

it "returns a Pathname" do
Pathname.pwd.realdirpath.should be_an_instance_of(Pathname)
end

end
10 changes: 10 additions & 0 deletions spec/ruby/library/pathname/realpath_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'pathname'

describe "Pathname#realpath" do

it "returns a Pathname" do
Pathname.pwd.realpath.should be_an_instance_of(Pathname)
end

end
38 changes: 38 additions & 0 deletions spec/ruby/library/socket/addrinfo/afamily_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#afamily" do
describe "for an ipv4 socket" do

before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns Socket::AF_INET" do
@addrinfo.afamily.should == Socket::AF_INET
end

end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns Socket::AF_INET6" do
@addrinfo.afamily.should == Socket::AF_INET6
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns Socket::AF_UNIX" do
@addrinfo.afamily.should == Socket::AF_UNIX
end
end
end
end
29 changes: 29 additions & 0 deletions spec/ruby/library/socket/addrinfo/bind_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
require 'socket'

describe "Addrinfo#bind" do

before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", SocketSpecs.port)
end

after :each do
@socket.close unless @socket.closed?
end

it "returns a bound socket when no block is given" do
@socket = @addrinfo.bind
@socket.should be_kind_of(Socket)
@socket.closed?.should be_false
end

it "yields the socket if a block is given" do
@addrinfo.bind do |sock|
@socket = sock
sock.should be_kind_of(Socket)
end
@socket.closed?.should be_true
end

end
16 changes: 16 additions & 0 deletions spec/ruby/library/socket/addrinfo/canonname_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
require 'socket'

describe "Addrinfo#canonname" do

before :each do
@addrinfos = Addrinfo.getaddrinfo("localhost", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME)
end

it "returns the canonical name for a host" do
canonname = @addrinfos.map { |a| a.canonname }.find { |name| name and name.include?("localhost") }
canonname.should include("localhost")
end

end
253 changes: 253 additions & 0 deletions spec/ruby/library/socket/addrinfo/initialize_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#initialize" do

describe "with a sockaddr string" do

describe "without a family" do
before :each do
@addrinfo = Addrinfo.new(Socket.sockaddr_in("smtp", "2001:DB8::1"))
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "2001:db8::1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 25
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_UNSPEC
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET6
end

it "returns the 0 socket type" do
@addrinfo.socktype.should == 0
end

it "returns the 0 protocol" do
@addrinfo.protocol.should == 0
end
end

describe "with a family given" do
before :each do
@addrinfo = Addrinfo.new(Socket.sockaddr_in("smtp", "2001:DB8::1"), Socket::PF_INET6)
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "2001:db8::1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 25
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET6
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET6
end

it "returns the 0 socket type" do
@addrinfo.socktype.should == 0
end

it "returns the 0 protocol" do
@addrinfo.protocol.should == 0
end
end

describe "with a family and socket type" do
before :each do
@addrinfo = Addrinfo.new(Socket.sockaddr_in("smtp", "2001:DB8::1"), Socket::PF_INET6, Socket::SOCK_STREAM)
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "2001:db8::1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 25
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET6
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET6
end

it "returns the 0 socket type" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end

it "returns the 0 protocol" do
@addrinfo.protocol.should == 0
end
end

describe "with a family, socket type and protocol" do
before :each do
@addrinfo = Addrinfo.new(Socket.sockaddr_in("smtp", "2001:DB8::1"), Socket::PF_INET6, Socket::SOCK_STREAM, Socket::IPPROTO_TCP)
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "2001:db8::1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 25
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET6
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET6
end

it "returns the specified socket type" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end

it "returns the specified protocol" do
@addrinfo.protocol.should == Socket::IPPROTO_TCP
end
end

end

describe "with a sockaddr array" do

describe "without a family" do
before :each do
@addrinfo = Addrinfo.new(["AF_INET", 46102, "localhost", "127.0.0.1"])
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "127.0.0.1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 46102
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET
end

it "returns the 0 socket type" do
@addrinfo.socktype.should == 0
end

it "returns the 0 protocol" do
@addrinfo.protocol.should == 0
end
end

describe "with a family given" do
before :each do
@addrinfo = Addrinfo.new(["AF_INET", 46102, "localhost", "127.0.0.1"], Socket::PF_INET)
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "127.0.0.1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 46102
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET
end

it "returns the 0 socket type" do
@addrinfo.socktype.should == 0
end

it "returns the 0 protocol" do
@addrinfo.protocol.should == 0
end
end

describe "with a family and socket type" do
before :each do
@addrinfo = Addrinfo.new(["AF_INET", 46102, "localhost", "127.0.0.1"], Socket::PF_INET, Socket::SOCK_STREAM)
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "127.0.0.1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 46102
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET
end

it "returns the 0 socket type" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end

it "returns the 0 protocol" do
@addrinfo.protocol.should == 0
end
end

describe "with a family, socket type and protocol" do
before :each do
@addrinfo = Addrinfo.new(["AF_INET", 46102, "localhost", "127.0.0.1"], Socket::PF_INET, Socket::SOCK_STREAM, Socket::IPPROTO_TCP)
end

it "stores the ip address from the sockaddr" do
@addrinfo.ip_address.should == "127.0.0.1"
end

it "stores the port number from the sockaddr" do
@addrinfo.ip_port.should == 46102
end

it "returns the Socket::UNSPEC pfamily" do
@addrinfo.pfamily.should == Socket::PF_INET
end

it "returns the INET6 afamily" do
@addrinfo.afamily.should == Socket::AF_INET
end

it "returns the 0 socket type" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end

it "returns the specified protocol" do
@addrinfo.protocol.should == Socket::IPPROTO_TCP
end
end
end

end
36 changes: 36 additions & 0 deletions spec/ruby/library/socket/addrinfo/ip_address_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ip_address" do
describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns the ip address" do
@addrinfo.ip_address.should == "127.0.0.1"
end
end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns the ip address" do
@addrinfo.ip_address.should == "::1"
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "raises an exception" do
lambda { @addrinfo.ip_address }.should raise_error(SocketError)
end
end
end
end
36 changes: 36 additions & 0 deletions spec/ruby/library/socket/addrinfo/ip_port_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ip_port" do
describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns the port" do
@addrinfo.ip_port.should == 80
end
end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns the port" do
@addrinfo.ip_port.should == 80
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "raises an exception" do
lambda { @addrinfo.ip_port }.should raise_error(SocketError)
end
end
end
end
36 changes: 36 additions & 0 deletions spec/ruby/library/socket/addrinfo/ip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ip?" do
describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns true" do
@addrinfo.ip?.should be_true
end
end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns true" do
@addrinfo.ip?.should be_true
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns Socket::AF_INET6" do
@addrinfo.ip?.should be_false
end
end
end
end
36 changes: 36 additions & 0 deletions spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ip_unpack" do
describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns the ip address and port pair" do
@addrinfo.ip_unpack.should == ["127.0.0.1", 80]
end
end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns the ip address and port pair" do
@addrinfo.ip_unpack.should == ["::1", 80]
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "raises an exception" do
lambda { @addrinfo.ip_unpack }.should raise_error(SocketError)
end
end
end
end
46 changes: 46 additions & 0 deletions spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ipv4_loopback?" do
describe "for an ipv4 socket" do
before :each do
@loopback = Addrinfo.tcp("127.0.0.1", 80)
@other = Addrinfo.tcp("0.0.0.0", 80)
end

it "returns true for the loopback address" do
@loopback.ipv4_loopback?.should be_true
end

it "returns false for another address" do
@other.ipv4_loopback?.should be_false
end
end

describe "for an ipv6 socket" do
before :each do
@loopback = Addrinfo.tcp("::1", 80)
@other = Addrinfo.tcp("::", 80)
end

it "returns false for the loopback address" do
@loopback.ipv4_loopback?.should be_false
end

it "returns false for another address" do
@other.ipv4_loopback?.should be_false
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns false" do
@addrinfo.ipv4_loopback?.should be_false
end
end
end
end
46 changes: 46 additions & 0 deletions spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ipv4_multicast?" do
describe "for an ipv4 socket" do
before :each do
@multicast = Addrinfo.tcp("224.0.0.1", 80)
@other = Addrinfo.tcp("0.0.0.0", 80)
end

it "returns true for the loopback address" do
@multicast.ipv4_multicast?.should be_true
end

it "returns false for another address" do
@other.ipv4_multicast?.should be_false
end
end

describe "for an ipv6 socket" do
before :each do
@multicast = Addrinfo.tcp("ff02::1", 80)
@other = Addrinfo.tcp("::", 80)
end

it "returns false for the loopback address" do
@multicast.ipv4_multicast?.should be_false
end

it "returns false for another address" do
@other.ipv4_multicast?.should be_false
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns false" do
@addrinfo.ipv4_multicast?.should be_false
end
end
end
end
41 changes: 41 additions & 0 deletions spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ipv4_private?" do
describe "for an ipv4 socket" do
before :each do
@private = Addrinfo.tcp("10.0.0.1", 80)
@other = Addrinfo.tcp("0.0.0.0", 80)
end

it "returns true for a private address" do
@private.ipv4_private?.should be_true
end

it "returns false for a public address" do
@other.ipv4_private?.should be_false
end
end

describe "for an ipv6 socket" do
before :each do
@other = Addrinfo.tcp("::", 80)
end

it "returns false" do
@other.ipv4_private?.should be_false
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns false" do
@addrinfo.ipv4_private?.should be_false
end
end
end
end
36 changes: 36 additions & 0 deletions spec/ruby/library/socket/addrinfo/ipv4_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ipv4?" do
describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("10.0.0.1", 80)
end

it "returns true" do
@addrinfo.ipv4?.should be_true
end
end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns false" do
@addrinfo.ipv4?.should be_false
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns false" do
@addrinfo.ipv4?.should be_false
end
end
end
end
46 changes: 46 additions & 0 deletions spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ipv6_loopback?" do
describe "for an ipv4 socket" do
before :each do
@loopback = Addrinfo.tcp("127.0.0.1", 80)
@other = Addrinfo.tcp("0.0.0.0", 80)
end

it "returns true for the loopback address" do
@loopback.ipv6_loopback?.should be_false
end

it "returns false for another address" do
@other.ipv6_loopback?.should be_false
end
end

describe "for an ipv6 socket" do
before :each do
@loopback = Addrinfo.tcp("::1", 80)
@other = Addrinfo.tcp("::", 80)
end

it "returns false for the loopback address" do
@loopback.ipv6_loopback?.should be_true
end

it "returns false for another address" do
@other.ipv6_loopback?.should be_false
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns false" do
@addrinfo.ipv6_loopback?.should be_false
end
end
end
end
46 changes: 46 additions & 0 deletions spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ipv6_multicast?" do
describe "for an ipv4 socket" do
before :each do
@multicast = Addrinfo.tcp("224.0.0.1", 80)
@other = Addrinfo.tcp("0.0.0.0", 80)
end

it "returns true for the loopback address" do
@multicast.ipv6_multicast?.should be_false
end

it "returns false for another address" do
@other.ipv6_multicast?.should be_false
end
end

describe "for an ipv6 socket" do
before :each do
@multicast = Addrinfo.tcp("ff02::1", 80)
@other = Addrinfo.tcp("::", 80)
end

it "returns false for the loopback address" do
@multicast.ipv6_multicast?.should be_true
end

it "returns false for another address" do
@other.ipv6_multicast?.should be_false
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns false" do
@addrinfo.ipv6_multicast?.should be_false
end
end
end
end
36 changes: 36 additions & 0 deletions spec/ruby/library/socket/addrinfo/ipv6_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#ipv6?" do
describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("10.0.0.1", 80)
end

it "returns true" do
@addrinfo.ipv6?.should be_false
end
end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns false" do
@addrinfo.ipv6?.should be_true
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns false" do
@addrinfo.ipv6?.should be_false
end
end
end
end
38 changes: 38 additions & 0 deletions spec/ruby/library/socket/addrinfo/pfamily_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#pfamily" do
describe "for an ipv4 socket" do

before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns Socket::PF_INET" do
@addrinfo.pfamily.should == Socket::PF_INET
end

end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns Socket::PF_INET6" do
@addrinfo.pfamily.should == Socket::PF_INET6
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns Socket::PF_UNIX" do
@addrinfo.pfamily.should == Socket::PF_UNIX
end
end
end
end
38 changes: 38 additions & 0 deletions spec/ruby/library/socket/addrinfo/protocol_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#protocol" do
describe "for an ipv4 socket" do

before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns Socket::IPPROTO_TCP" do
@addrinfo.protocol.should == Socket::IPPROTO_TCP
end

end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns Socket::IPPROTO_TCP" do
@addrinfo.protocol.should == Socket::IPPROTO_TCP
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns 0" do
@addrinfo.protocol.should == 0
end
end
end
end
35 changes: 35 additions & 0 deletions spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
describe :socket_addrinfo_to_sockaddr, :shared => true do

describe "for an ipv4 socket" do
before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns a sockaddr packed structure" do
@addrinfo.send(@method).should be_kind_of(String)
end
end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns a sockaddr packed structure" do
@addrinfo.send(@method).should be_kind_of(String)
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns a sockaddr packed structure" do
@addrinfo.send(@method).should be_kind_of(String)
end
end
end

end
38 changes: 38 additions & 0 deletions spec/ruby/library/socket/addrinfo/socktype_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#socktype" do
describe "for an ipv4 socket" do

before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns Socket::SOCK_STREAM" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end

end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns Socket::SOCK_STREAM" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns Socket::SOCK_STREAM" do
@addrinfo.socktype.should == Socket::SOCK_STREAM
end
end
end
end
20 changes: 20 additions & 0 deletions spec/ruby/library/socket/addrinfo/tcp_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo.tcp" do

before :each do
@addrinfo = Addrinfo.tcp("localhost", "smtp")
end

it "creates a addrinfo for a tcp socket" do
["::1", "127.0.0.1"].should include(@addrinfo.ip_address)
[Socket::PF_INET, Socket::PF_INET6].should include(@addrinfo.pfamily)
@addrinfo.ip_port.should == 25
@addrinfo.socktype.should == Socket::SOCK_STREAM
platform_is_not :solaris do
@addrinfo.protocol.should == Socket::IPPROTO_TCP
end
end

end
7 changes: 7 additions & 0 deletions spec/ruby/library/socket/addrinfo/to_s_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../shared/to_sockaddr', __FILE__)
require 'socket'

describe "Addrinfo#to_s" do
it_behaves_like(:socket_addrinfo_to_sockaddr, :to_s)
end
7 changes: 7 additions & 0 deletions spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../shared/to_sockaddr', __FILE__)
require 'socket'

describe "Addrinfo#to_sockaddr" do
it_behaves_like(:socket_addrinfo_to_sockaddr, :to_sockaddr)
end
20 changes: 20 additions & 0 deletions spec/ruby/library/socket/addrinfo/udp_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo.udp" do

before :each do
@addrinfo = Addrinfo.udp("localhost", "daytime")
end

it "creates a addrinfo for a tcp socket" do
["::1", "127.0.0.1"].should include(@addrinfo.ip_address)
[Socket::PF_INET, Socket::PF_INET6].should include(@addrinfo.pfamily)
@addrinfo.ip_port.should == 13
@addrinfo.socktype.should == Socket::SOCK_DGRAM
platform_is_not :solaris do
@addrinfo.protocol.should == Socket::IPPROTO_UDP
end
end

end
38 changes: 38 additions & 0 deletions spec/ruby/library/socket/addrinfo/unix_path_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo#unix_path" do
describe "for an ipv4 socket" do

before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "raises an exception" do
lambda { @addrinfo.unix_path }.should raise_error(SocketError)
end

end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "raises an exception" do
lambda { @addrinfo.unix_path }.should raise_error(SocketError)
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns the socket path" do
@addrinfo.unix_path.should == "/tmp/sock"
end
end
end
end
54 changes: 54 additions & 0 deletions spec/ruby/library/socket/addrinfo/unix_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require 'socket'

describe "Addrinfo.unix" do

platform_is_not :windows do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "creates a addrinfo for a unix socket" do
@addrinfo.pfamily.should == Socket::PF_UNIX
@addrinfo.socktype.should == Socket::SOCK_STREAM
@addrinfo.protocol.should == 0
@addrinfo.unix_path.should == "/tmp/sock"
end
end
end

describe "Addrinfo#unix?" do
describe "for an ipv4 socket" do

before :each do
@addrinfo = Addrinfo.tcp("127.0.0.1", 80)
end

it "returns false" do
@addrinfo.unix?.should be_false
end

end

describe "for an ipv6 socket" do
before :each do
@addrinfo = Addrinfo.tcp("::1", 80)
end

it "returns false" do
@addrinfo.unix?.should be_false
end
end

platform_is_not :windows do
describe "for a unix socket" do
before :each do
@addrinfo = Addrinfo.unix("/tmp/sock")
end

it "returns true" do
@addrinfo.unix?.should be_true
end
end
end
end
4 changes: 0 additions & 4 deletions spec/ruby/library/socket/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -60,10 +60,6 @@ def self.socket_path

# TCPServer echo server accepting one connection
class SpecTCPServer
def self.start(host=nil, port=nil, logger=nil)
new(host, port, logger).start
end

attr_accessor :hostname, :port, :logger

def initialize(host=nil, port=nil, logger=nil)
25 changes: 25 additions & 0 deletions spec/ruby/library/socket/option/bool_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

describe "Socket::Option.bool" do
it "creates a new Socket::Option" do
so = Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true)
so.should be_an_instance_of(Socket::Option)
so.family.should == Socket::AF_INET
so.level.should == Socket::SOL_SOCKET
so.optname.should == Socket::SO_KEEPALIVE
so.data.should == [1].pack('i')
end
end

describe "Socket::Option#bool" do
it "returns boolean value" do
Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true).bool.should == true
Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false).bool.should == false
end

it "raises TypeError if option has not good size" do
so = Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*'))
lambda { so.bool }.should raise_error(TypeError)
end
end
20 changes: 20 additions & 0 deletions spec/ruby/library/socket/option/inspect_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

require 'socket'

describe 'Socket::Option#inspect' do
it 'correctly returns SO_LINGER value' do
value = Socket::Option.linger(nil, 0).inspect
value.should == '#<Socket::Option: UNSPEC SOCKET LINGER off 0sec>'

value = Socket::Option.linger(false, 30).inspect
value.should == '#<Socket::Option: UNSPEC SOCKET LINGER off 30sec>'

value = Socket::Option.linger(true, 0).inspect
value.should == '#<Socket::Option: UNSPEC SOCKET LINGER on 0sec>'

value = Socket::Option.linger(true, 30).inspect
value.should == '#<Socket::Option: UNSPEC SOCKET LINGER on 30sec>'
end
end
28 changes: 28 additions & 0 deletions spec/ruby/library/socket/option/int_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

describe "Socket::Option.int" do
it "creates a new Socket::Option" do
so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 5)
so.should be_an_instance_of(Socket::Option)
so.family.should == Socket::Constants::AF_INET
so.level.should == Socket::Constants::SOL_SOCKET
so.optname.should == Socket::Constants::SO_KEEPALIVE
so.data.should == [5].pack('i')
end
end

describe "Socket::Option#int" do
it "returns int value" do
so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 17)
so.int.should == 17

so = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 32765)
so.int.should == 32765
end

it "raises TypeError if option has not good size" do
so = Socket::Option.new(:UNSPEC, :SOCKET, :SO_LINGER, [0, 0].pack('i*'))
lambda { so.int }.should raise_error(TypeError)
end
end
55 changes: 55 additions & 0 deletions spec/ruby/library/socket/option/linger_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

describe "Socket::Option.linger" do
it "creates a new Socket::Option for SO_LINGER" do
so = Socket::Option.linger(1, 10)
so.should be_an_instance_of(Socket::Option)
so.family.should == Socket::Constants::AF_UNSPEC
so.level.should == Socket::Constants::SOL_SOCKET
so.optname.should == Socket::Constants::SO_LINGER
so.data.should == [1, 10].pack('i*')
end

it "accepts boolean as onoff argument" do
so = Socket::Option.linger(false, 0)
so.data.should == [0, 0].pack('i*')

so = Socket::Option.linger(true, 1)
so.data.should == [1, 1].pack('i*')
end
end

describe "Socket::Option#linger" do
it "returns linger option" do
so = Socket::Option.linger(0, 5)
ary = so.linger
ary[0].should be_false
ary[1].should == 5

so = Socket::Option.linger(false, 4)
ary = so.linger
ary[0].should be_false
ary[1].should == 4

so = Socket::Option.linger(1, 10)
ary = so.linger
ary[0].should be_true
ary[1].should == 10

so = Socket::Option.linger(true, 9)
ary = so.linger
ary[0].should be_true
ary[1].should == 9
end

it "raises TypeError if not a SO_LINGER" do
so = Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :KEEPALIVE, 1)
lambda { so.linger }.should raise_error(TypeError)
end

it "raises TypeError if option has not good size" do
so = Socket::Option.int(:AF_UNSPEC, :SOL_SOCKET, :LINGER, 1)
lambda { so.linger }.should raise_error(TypeError)
end
end
35 changes: 35 additions & 0 deletions spec/ruby/library/socket/option/new_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

describe "Socket::Option.new" do
it "should accept integers" do
so = Socket::Option.new(Socket::AF_INET, Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, [0].pack('i'))
so.family.should == Socket::AF_INET
so.level.should == Socket::SOL_SOCKET
so.optname.should == Socket::SO_KEEPALIVE
end

it "should accept symbols" do
so = Socket::Option.new(:AF_INET, :SOL_SOCKET, :SO_KEEPALIVE, [0].pack('i'))
so.family.should == Socket::AF_INET
so.level.should == Socket::SOL_SOCKET
so.optname.should == Socket::SO_KEEPALIVE

so = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [0].pack('i'))
so.family.should == Socket::AF_INET
so.level.should == Socket::SOL_SOCKET
so.optname.should == Socket::SO_KEEPALIVE
end

it "should raise error on unknown family" do
lambda { Socket::Option.new(:INET4, :SOCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
end

it "should raise error on unknown level" do
lambda { Socket::Option.new(:INET, :ROCKET, :KEEPALIVE, [0].pack('i')) }.should raise_error(SocketError)
end

it "should raise error on unknown option name" do
lambda { Socket::Option.new(:INET, :SOCKET, :ALIVE, [0].pack('i')) }.should raise_error(SocketError)
end
end
6 changes: 6 additions & 0 deletions spec/ruby/library/socket/socket/connect_nonblock_spec.rb
Original file line number Diff line number Diff line change
@@ -57,5 +57,11 @@
@socket.connect_nonblock(@addr)
end.should raise_error(IO::WaitWritable)
end

ruby_version_is "2.3" do
it "returns :wait_writable in exceptionless mode when the connect would block" do
@socket.connect_nonblock(@addr, exception: false).should == :wait_writable
end
end
end
end
19 changes: 15 additions & 4 deletions spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb
Original file line number Diff line number Diff line change
@@ -20,11 +20,10 @@
sleep 0.1
s = @server.accept_nonblock

# commenting while we get some input on the current JRuby situation
# port, address = Socket.unpack_sockaddr_in(s.getsockname)
port, address = Socket.unpack_sockaddr_in(s.getsockname)

# port.should == SocketSpecs.port
# address.should == "127.0.0.1"
port.should == SocketSpecs.port
address.should == "127.0.0.1"
s.should be_kind_of(TCPSocket)

c.close
@@ -35,4 +34,16 @@
@server.close
lambda { @server.accept }.should raise_error(IOError)
end

describe 'without a connected client' do
it 'raises error' do
lambda { @server.accept_nonblock }.should raise_error(IO::WaitReadable)
end

ruby_version_is '2.3' do
it 'returns :wait_readable in exceptionless mode' do
@server.accept_nonblock(exception: false).should == :wait_readable
end
end
end
end
16 changes: 16 additions & 0 deletions spec/ruby/library/socket/tcpserver/listen_spec.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

require 'socket'

describe 'TCPServer#listen' do
before :each do
@server = TCPServer.new(SocketSpecs.hostname, SocketSpecs.port)
end

after :each do
@server.close unless @server.closed?
end

it 'returns 0' do
@server.listen(10).should == 0
end
end
29 changes: 29 additions & 0 deletions spec/ruby/library/socket/tcpserver/sysaccept_spec.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

require 'socket'

describe "TCPServer#sysaccept" do
before :each do
@server = TCPServer.new(SocketSpecs.hostname, SocketSpecs.port)
end

after :each do
@server.close unless @server.closed?
end

it 'blocks if no connections' do
lambda { @server.sysaccept }.should block_caller
end

it 'returns file descriptor of an accepted connection' do
begin
sock = TCPSocket.new(SocketSpecs.hostname, SocketSpecs.port)

fd = @server.sysaccept

fd.should be_an_instance_of(Fixnum)
ensure
sock.close if sock && !sock.closed?
IO.for_fd(fd).close if fd
end
end
end
48 changes: 48 additions & 0 deletions spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require File.expand_path('../../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

describe "TCPSocket#setsockopt" do
before :each do
@server = SocketSpecs::SpecTCPServer.new
@hostname = @server.hostname
end

before :each do
@sock = TCPSocket.new @hostname, SocketSpecs.port
end

after :each do
@sock.close unless @sock.closed?
@server.shutdown
end

describe "using constants" do
it "sets the TCP nodelay to 1" do
@sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1).should == 0
end
end

describe "using symbols" do
it "sets the TCP nodelay to 1" do
@sock.setsockopt(:IPPROTO_TCP, :TCP_NODELAY, 1).should == 0
end

context "without prefix" do
it "sets the TCP nodelay to 1" do
@sock.setsockopt(:TCP, :NODELAY, 1).should == 0
end
end
end

describe "using strings" do
it "sets the TCP nodelay to 1" do
@sock.setsockopt('IPPROTO_TCP', 'TCP_NODELAY', 1).should == 0
end

context "without prefix" do
it "sets the TCP nodelay to 1" do
@sock.setsockopt('TCP', 'NODELAY', 1).should == 0
end
end
end
end
46 changes: 46 additions & 0 deletions spec/ruby/library/stringio/getch_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../../../spec_helper', __FILE__)
require 'stringio'
require File.expand_path('../shared/getc', __FILE__)

# This method is added by io/console on require.
describe "StringIO#getch" do
require 'io/console'

it_behaves_like :stringio_getc, :getch

it "returns the charactor at the current position" do
io = StringIO.new("example")

io.send(@method).should == ?e
io.send(@method).should == ?x
io.send(@method).should == ?a
end

with_feature :encoding do
it "increments #pos by the byte size of the character in multibyte strings" do
io = StringIO.new("föóbar")

io.send(@method); io.pos.should == 1 # "f" has byte size 1
io.send(@method); io.pos.should == 3 # "ö" has byte size 2
io.send(@method); io.pos.should == 5 # "ó" has byte size 2
io.send(@method); io.pos.should == 6 # "b" has byte size 1
end
end

it "returns nil at the end of the string" do
# empty string case
io = StringIO.new("")
io.send(@method).should == nil
io.send(@method).should == nil

# non-empty string case
io = StringIO.new("a")
io.send(@method) # skip one
io.send(@method).should == nil
end

describe "StringIO#getch when self is not readable" do
it_behaves_like :stringio_getc_not_readable, :getch
end
end
20 changes: 20 additions & 0 deletions spec/ruby/library/stringio/read_nonblock_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require File.expand_path('../../../spec_helper', __FILE__)
require "stringio"
require File.expand_path('../shared/read', __FILE__)
require File.expand_path('../shared/sysread', __FILE__)

describe "StringIO#read_nonblock when passed length, buffer" do
it_behaves_like :stringio_read, :read_nonblock
end

describe "StringIO#read_nonblock when passed length" do
it_behaves_like :stringio_read_length, :read_nonblock
end

describe "StringIO#read_nonblock when passed nil" do
it_behaves_like :stringio_read_nil, :read_nonblock
end

describe "StringIO#read_nonblock when passed length" do
it_behaves_like :stringio_sysread_length, :read_nonblock
end
15 changes: 15 additions & 0 deletions spec/ruby/library/stringio/shared/sysread.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe :stringio_sysread_length, :shared => true do
before :each do
@io = StringIO.new("example")
end

it "returns an empty String when passed 0 and no data remains" do
@io.send(@method, 8).should == "example"
@io.send(@method, 0).should == ""
end

it "raises an EOFError when passed length > 0 and no data remains" do
@io.read.should == "example"
lambda { @io.sysread(1) }.should raise_error(EOFError)
end
end
19 changes: 19 additions & 0 deletions spec/ruby/library/stringio/write_nonblock_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/write', __FILE__)

describe "StringIO#write_nonblock when passed [Object]" do
it_behaves_like :stringio_write, :write_nonblock
end

describe "StringIO#write_nonblock when passed [String]" do
it_behaves_like :stringio_write_string, :write_nonblock
end

describe "StringIO#write_nonblock when self is not writable" do
it_behaves_like :stringio_write_not_writable, :write_nonblock
end

describe "StringIO#write_nonblock when in append mode" do
it_behaves_like :stringio_write_append, :write_nonblock
end
42 changes: 42 additions & 0 deletions spec/ruby/library/time/to_date_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

require File.expand_path('../../../spec_helper', __FILE__)
require 'time'

describe "Time#to_date" do
it "yields accurate julian date for ambiguous pre-Gregorian reform value" do
Time.utc(1582, 10, 4).to_date.jd.should == Date::ITALY - 11 # 2299150j
end

it "yields accurate julian date for Julian-Gregorian gap value" do
Time.utc(1582, 10, 14).to_date.jd.should == Date::ITALY - 1 # 2299160j
end

it "yields accurate julian date for post-Gregorian reform value" do
Time.utc(1582, 10, 15).to_date.jd.should == Date::ITALY # 2299161j
end

it "yields same julian day regardless of UTC time value" do
Time.utc(1582, 10, 15, 00, 00, 00).to_date.jd.should == Date::ITALY
Time.utc(1582, 10, 15, 23, 59, 59).to_date.jd.should == Date::ITALY
end

it "yields same julian day regardless of local time or zone" do

with_timezone("Pacific/Pago_Pago", -11) do
Time.local(1582, 10, 15, 00, 00, 00).to_date.jd.should == Date::ITALY
Time.local(1582, 10, 15, 23, 59, 59).to_date.jd.should == Date::ITALY
end

with_timezone("Asia/Kamchatka", +12) do
Time.local(1582, 10, 15, 00, 00, 00).to_date.jd.should == Date::ITALY
Time.local(1582, 10, 15, 23, 59, 59).to_date.jd.should == Date::ITALY
end

end

it "yields date with default Calendar reform day" do
Time.utc(1582, 10, 4).to_date.start.should == Date::ITALY
Time.utc(1582, 10, 14).to_date.start.should == Date::ITALY
Time.utc(1582, 10, 15).to_date.start.should == Date::ITALY
end
end
8 changes: 8 additions & 0 deletions spec/ruby/library/timeout/error_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'timeout'

describe "Timeout::Error" do
it "is a subclass of RuntimeError" do
RuntimeError.should be_ancestor_of(Timeout::Error)
end
end
1 change: 1 addition & 0 deletions spec/truffle/tags/core/kernel/public_send_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fails:Kernel#public_send has an arity of -1
fails:Kernel#public_send raises a NoMethodError if the method is protected
fails:Kernel#public_send raises a NoMethodError if the named method is an alias of a protected method
fails:Kernel#public_send called from own public method raises a NoMethodError if the method is protected
1 change: 1 addition & 0 deletions spec/truffle/tags/core/numeric/step_tags.txt
Original file line number Diff line number Diff line change
@@ -8,3 +8,4 @@ fails:Numeric#step with mixed arguments doesn't raise an error when step is 0.0
fails:Numeric#step with mixed arguments should loop over self when step is 0 or 0.0
fails:Numeric#step with mixed arguments when no block is given returned Enumerator size should return infinity_value when step is 0
fails:Numeric#step with mixed arguments when no block is given returned Enumerator size should return infinity_value when step is 0.0
fails:Numeric#step with keyword arguments when no block is given returned Enumerator size should return infinity_value when the limit is Float::INFINITY
1 change: 1 addition & 0 deletions spec/truffle/tags/core/thread/name_tags.txt
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ fails:Thread#name returns the thread name
fails:Thread#name= can be set to a String
fails:Thread#name= raises an ArgumentError if the name includes a null byte
fails:Thread#name= can be reset to nil
fails:Thread#name= calls #to_str to convert name to String
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/afamily_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#afamily for an ipv4 socket returns Socket::AF_INET
fails:Addrinfo#afamily for an ipv6 socket returns Socket::AF_INET6
fails:Addrinfo#afamily for a unix socket returns Socket::AF_UNIX
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/bind_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Addrinfo#bind returns a bound socket when no block is given
fails:Addrinfo#bind yields the socket if a block is given
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Addrinfo#canonname returns the canonical name for a host
48 changes: 48 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/initialize_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
fails:Addrinfo#initialize with a sockaddr string without a family stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr string without a family stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr string without a family returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr string without a family returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr string without a family returns the 0 socket type
fails:Addrinfo#initialize with a sockaddr string without a family returns the 0 protocol
fails:Addrinfo#initialize with a sockaddr string with a family given stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr string with a family given stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr string with a family given returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr string with a family given returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr string with a family given returns the 0 socket type
fails:Addrinfo#initialize with a sockaddr string with a family given returns the 0 protocol
fails:Addrinfo#initialize with a sockaddr string with a family and socket type stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr string with a family and socket type stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr string with a family and socket type returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr string with a family and socket type returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr string with a family and socket type returns the 0 socket type
fails:Addrinfo#initialize with a sockaddr string with a family and socket type returns the 0 protocol
fails:Addrinfo#initialize with a sockaddr string with a family, socket type and protocol stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr string with a family, socket type and protocol stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr string with a family, socket type and protocol returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr string with a family, socket type and protocol returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr string with a family, socket type and protocol returns the specified socket type
fails:Addrinfo#initialize with a sockaddr string with a family, socket type and protocol returns the specified protocol
fails:Addrinfo#initialize with a sockaddr array without a family stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr array without a family stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr array without a family returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr array without a family returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr array without a family returns the 0 socket type
fails:Addrinfo#initialize with a sockaddr array without a family returns the 0 protocol
fails:Addrinfo#initialize with a sockaddr array with a family given stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr array with a family given stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr array with a family given returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr array with a family given returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr array with a family given returns the 0 socket type
fails:Addrinfo#initialize with a sockaddr array with a family given returns the 0 protocol
fails:Addrinfo#initialize with a sockaddr array with a family and socket type stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr array with a family and socket type stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr array with a family and socket type returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr array with a family and socket type returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr array with a family and socket type returns the 0 socket type
fails:Addrinfo#initialize with a sockaddr array with a family and socket type returns the 0 protocol
fails:Addrinfo#initialize with a sockaddr array with a family, socket type and protocol stores the ip address from the sockaddr
fails:Addrinfo#initialize with a sockaddr array with a family, socket type and protocol stores the port number from the sockaddr
fails:Addrinfo#initialize with a sockaddr array with a family, socket type and protocol returns the Socket::UNSPEC pfamily
fails:Addrinfo#initialize with a sockaddr array with a family, socket type and protocol returns the INET6 afamily
fails:Addrinfo#initialize with a sockaddr array with a family, socket type and protocol returns the 0 socket type
fails:Addrinfo#initialize with a sockaddr array with a family, socket type and protocol returns the specified protocol
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/ip_address_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#ip_address for an ipv4 socket returns the ip address
fails:Addrinfo#ip_address for an ipv6 socket returns the ip address
fails:Addrinfo#ip_address for a unix socket raises an exception
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/ip_port_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#ip_port for an ipv4 socket returns the port
fails:Addrinfo#ip_port for an ipv6 socket returns the port
fails:Addrinfo#ip_port for a unix socket raises an exception
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/ip_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#ip? for an ipv4 socket returns true
fails:Addrinfo#ip? for an ipv6 socket returns true
fails:Addrinfo#ip? for a unix socket returns Socket::AF_INET6
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/ip_unpack_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#ip_unpack for an ipv4 socket returns the ip address and port pair
fails:Addrinfo#ip_unpack for an ipv6 socket returns the ip address and port pair
fails:Addrinfo#ip_unpack for a unix socket raises an exception
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fails:Addrinfo#ipv4_loopback? for an ipv4 socket returns true for the loopback address
fails:Addrinfo#ipv4_loopback? for an ipv4 socket returns false for another address
fails:Addrinfo#ipv4_loopback? for an ipv6 socket returns false for the loopback address
fails:Addrinfo#ipv4_loopback? for an ipv6 socket returns false for another address
fails:Addrinfo#ipv4_loopback? for a unix socket returns false
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fails:Addrinfo#ipv4_multicast? for an ipv4 socket returns true for the loopback address
fails:Addrinfo#ipv4_multicast? for an ipv4 socket returns false for another address
fails:Addrinfo#ipv4_multicast? for an ipv6 socket returns false for the loopback address
fails:Addrinfo#ipv4_multicast? for an ipv6 socket returns false for another address
fails:Addrinfo#ipv4_multicast? for a unix socket returns false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fails:Addrinfo#ipv4_private? for an ipv4 socket returns true for a private address
fails:Addrinfo#ipv4_private? for an ipv4 socket returns false for a public address
fails:Addrinfo#ipv4_private? for an ipv6 socket returns false
fails:Addrinfo#ipv4_private? for a unix socket returns false
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/ipv4_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#ipv4? for an ipv4 socket returns true
fails:Addrinfo#ipv4? for an ipv6 socket returns false
fails:Addrinfo#ipv4? for a unix socket returns false
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fails:Addrinfo#ipv6_loopback? for an ipv4 socket returns true for the loopback address
fails:Addrinfo#ipv6_loopback? for an ipv4 socket returns false for another address
fails:Addrinfo#ipv6_loopback? for an ipv6 socket returns false for the loopback address
fails:Addrinfo#ipv6_loopback? for an ipv6 socket returns false for another address
fails:Addrinfo#ipv6_loopback? for a unix socket returns false
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fails:Addrinfo#ipv6_multicast? for an ipv4 socket returns true for the loopback address
fails:Addrinfo#ipv6_multicast? for an ipv4 socket returns false for another address
fails:Addrinfo#ipv6_multicast? for an ipv6 socket returns false for the loopback address
fails:Addrinfo#ipv6_multicast? for an ipv6 socket returns false for another address
fails:Addrinfo#ipv6_multicast? for a unix socket returns false
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/ipv6_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#ipv6? for an ipv4 socket returns true
fails:Addrinfo#ipv6? for an ipv6 socket returns false
fails:Addrinfo#ipv6? for a unix socket returns false
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/pfamily_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#pfamily for an ipv4 socket returns Socket::PF_INET
fails:Addrinfo#pfamily for an ipv6 socket returns Socket::PF_INET6
fails:Addrinfo#pfamily for a unix socket returns Socket::PF_UNIX
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/protocol_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#protocol for an ipv4 socket returns Socket::IPPROTO_TCP
fails:Addrinfo#protocol for an ipv6 socket returns Socket::IPPROTO_TCP
fails:Addrinfo#protocol for a unix socket returns 0
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/socktype_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#socktype for an ipv4 socket returns Socket::SOCK_STREAM
fails:Addrinfo#socktype for an ipv6 socket returns Socket::SOCK_STREAM
fails:Addrinfo#socktype for a unix socket returns Socket::SOCK_STREAM
1 change: 1 addition & 0 deletions spec/truffle/tags/library/socket/addrinfo/tcp_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Addrinfo.tcp creates a addrinfo for a tcp socket
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/to_s_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#to_s for an ipv4 socket returns a sockaddr packed structure
fails:Addrinfo#to_s for an ipv6 socket returns a sockaddr packed structure
fails:Addrinfo#to_s for a unix socket returns a sockaddr packed structure
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#to_sockaddr for an ipv4 socket returns a sockaddr packed structure
fails:Addrinfo#to_sockaddr for an ipv6 socket returns a sockaddr packed structure
fails:Addrinfo#to_sockaddr for a unix socket returns a sockaddr packed structure
1 change: 1 addition & 0 deletions spec/truffle/tags/library/socket/addrinfo/udp_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Addrinfo.udp creates a addrinfo for a tcp socket
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/unix_path_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Addrinfo#unix_path for an ipv4 socket raises an exception
fails:Addrinfo#unix_path for an ipv6 socket raises an exception
fails:Addrinfo#unix_path for a unix socket returns the socket path
4 changes: 4 additions & 0 deletions spec/truffle/tags/library/socket/addrinfo/unix_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fails:Addrinfo.unix creates a addrinfo for a unix socket
fails:Addrinfo#unix? for an ipv4 socket returns false
fails:Addrinfo#unix? for an ipv6 socket returns false
fails:Addrinfo#unix? for a unix socket returns true
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/socket/option/bool_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Socket::Option#bool returns boolean value
fails:Socket::Option#bool raises TypeError if option has not good size
1 change: 1 addition & 0 deletions spec/truffle/tags/library/socket/option/inspect_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Socket::Option#inspect correctly returns SO_LINGER value
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/socket/option/int_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Socket::Option#int returns int value
fails:Socket::Option#int raises TypeError if option has not good size
3 changes: 3 additions & 0 deletions spec/truffle/tags/library/socket/option/linger_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Socket::Option.linger creates a new Socket::Option for SO_LINGER
fails:Socket::Option.linger accepts boolean as onoff argument
fails:Socket::Option#linger returns linger option
1 change: 1 addition & 0 deletions spec/truffle/tags/library/socket/option/new_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Socket::Option.new should raise error on unknown level
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fails:Socket#connect_nonblock connects the socket to the remote side
fails:Socket#connect_nonblock raises Errno::EINPROGRESS when the connect would block
fails:Socket#connect_nonblock raises Errno::EINPROGRESS with IO::WaitWritable mixed in when the connect would block
fails:Socket#connect_nonblock returns :wait_writable in exceptionless mode when the connect would block
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
fails:Socket::TCPServer.accept_nonblock accepts non blocking connections
fails:Socket::TCPServer.accept_nonblock raises an IOError if the socket is closed
fails:Socket::TCPServer.accept_nonblock without a connected client raises error
fails:Socket::TCPServer.accept_nonblock without a connected client returns :wait_readable in exceptionless mode
2 changes: 2 additions & 0 deletions spec/truffle/tags/library/socket/tcpserver/sysaccept_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:TCPServer#sysaccept blocks if no connections
fails:TCPServer#sysaccept returns file descriptor of an accepted connection
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fails:TCPSocket#setsockopt using constants sets the TCP nodelay to 1
fails:TCPSocket#setsockopt using symbols sets the TCP nodelay to 1
fails:TCPSocket#setsockopt using symbols without prefix sets the TCP nodelay to 1
fails:TCPSocket#setsockopt using strings sets the TCP nodelay to 1
fails:TCPSocket#setsockopt using strings without prefix sets the TCP nodelay to 1
7 changes: 7 additions & 0 deletions spec/truffle/tags/library/stringio/getch_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fails:StringIO#getch increases self's position by one
fails:StringIO#getch returns nil when called at the end of self
fails:StringIO#getch does not increase self's position when called at the end of file
fails:StringIO#getch returns the charactor at the current position
fails:StringIO#getch increments #pos by the byte size of the character in multibyte strings
fails:StringIO#getch returns nil at the end of the string
fails:StringIO#getch StringIO#getch when self is not readable raises an IOError
1 change: 1 addition & 0 deletions spec/truffle/tags/library/stringio/sysread_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:StringIO#sysread when passed nil returns an empty String if at EOF

0 comments on commit 1b5a1c9

Please sign in to comment.