Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4ff65a78fa13
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ac21b12f1e96
Choose a head ref
  • 4 commits
  • 60 files changed
  • 1 contributor

Commits on Aug 19, 2016

  1. Squashed 'spec/mspec/' changes from 27b0077..abc90e8

    abc90e8 Improve BlockingMatcher so that it is more efficient
    5c11c04 Added matcher for testing if Procs block a caller
    
    git-subtree-dir: spec/mspec
    git-subtree-split: abc90e837514830a6c72aff5a99a6f3f4fcbb400
    eregon committed Aug 19, 2016
    Copy the full SHA
    cdc6674 View commit details
  2. Copy the full SHA
    c15f049 View commit details
  3. Squashed 'spec/ruby/' changes from 884bfb7..b6baa6d

    b6baa6d Module#define_method accepts attr_accessor methods
    818e0fe Fix sized enumerators of Numeric#step with Infinity
    6488c84 Add a spec for a case then protected method called from public_send in own method
    1be7799 Added Thread#name, #name=.
    cb2cf57 Spec for module_function's singleton method with super.
    e06f420 Clarify $~ spec by using different variables for different cases
    1989a8d Additional Hash#to_proc specs from JRuby's suite.
    ef90111 Add multi-threaded Etc.getgrgid spec.
    7ecbd0b Use a more sensible command line for a RUBYOPT spec
    b09bd70 Ensure to use -e for -e specs
    9b31990 Add spec for creating instances of a cloned Time class
    6dafa0b Add a spec for Hash#to_proc result passed as instance_exec block.
    85ebe53 splatted hashes need to have symbol keys.  Adding spec
    351ddff Port specs from Array#max in Array#min
    630ed7f Import Array#max/min from JRuby+Truffle specs, themselves from Enumerable specs
    bb51c64 Spec out Array#max a tiny bit
    ea4ab25 Add missing fixture
    07c74cb Use a fixture for common code in #spawn specs
    a26029c Fix expectation with the newer output
    a102ba3 Kernel#spawn should not take an Array as it means something quite different
    869dc7c Make sure the path returned by Dir.pwd is absolute/expanded
    641bc01 Use the system ruby when the environment is empty in #spawn
    77132b3 Fail early if the Signalizer thread dies
    0312337 Use /bin/env to print the environment when the passed environment is empty or almost
    6987ef5 Make sure the thread is still alive while waiting for pid in Process#kill
    3c57ec7 Keep at least PATH when unsetting all other environment variables
    4f0609f Use a fixture rather than inline code which needs lots of escape characters
    6cff59a Replace an occurrence of sleep in Signal#trap specs
    94c1ac4 add IO.select spec. zero timeout returns immediately
    8edcc46 Add note in Class#dup spec
    73adaa2 [Truffle] Pass rb_str_new specs.
    62520ae Notify when compilation failed and use system ruby
    340e85c Merge pull request #286 from etehtsea/tcpserver-impr
    903b5e6 Add basic TCPServer#listen spec
    d15c2a2 Improve TCPServer#accept_nonblock specs
    e7676c5 (un)pack sockaddr should land into JRuby-head soon
    f579539 Guard failing expectation on Solaris
    88700b1 Try to allow some names to be nil in Addrinfo#canonname spec
    de38e1b Merge pull request #284 from etehtsea/tcp-server-sysaccept
    ee34678 Add TCPServer#sysaccept spec
    62b7184 Merge pull request #283 from etehtsea/imp-socket-option-spec
    17b6275 Improve Socket::Option specs
    cfc6222 Move inspect spec to other option specs
    0bf9e67 Have a try at fixing Addrinfo.udp spec
    77029fb Merge pull request #281 from etehtsea/add-socket-option-inspect
    0b0c55c Cleanup Addrinfo specs
    c3ee302 Add back socket Addrinfo specs
    564b142 Fix the newly added-back library specs
    f305537 Add library specs lost in the big merge back
    e2d2069 Add Socket::Option#inspect spec
    ebb208a Travis: allow ruby-head to fail since it's outdated
    6a6153d Explicitly do not escape for testing -e
    2704b5e Merge pull request #279 from etehtsea/connect-nonblock-exceptionless
    0f33773 Add spec for exceptionless Socket#connect_nonblock
    4f81c77 Follow CRuby r55728
    
    git-subtree-dir: spec/ruby
    git-subtree-split: b6baa6d10ca41f2322769ec9a6cc97635f9adc59
    eregon committed Aug 19, 2016
    Copy the full SHA
    ef6e62e View commit details
  4. Copy the full SHA
    ac21b12 View commit details
Showing with 2,031 additions and 49 deletions.
  1. +1 −0 spec/mspec/lib/mspec/matchers.rb
  2. +35 −0 spec/mspec/lib/mspec/matchers/block_caller.rb
  3. +13 −0 spec/mspec/spec/matchers/block_caller_spec.rb
  4. +3 −0 spec/ruby/.travis.yml
  5. +34 −0 spec/ruby/core/kernel/public_send_spec.rb
  6. +17 −0 spec/ruby/core/module/define_method_spec.rb
  7. +9 −1 spec/ruby/core/numeric/step_spec.rb
  8. +72 −33 spec/ruby/core/string/dump_spec.rb
  9. +8 −0 spec/ruby/core/thread/name_spec.rb
  10. +14 −7 spec/ruby/language/predefined_spec.rb
  11. +31 −0 spec/ruby/library/etc/struct_group_spec.rb
  12. +43 −0 spec/ruby/library/etc/struct_passwd_spec.rb
  13. +32 −0 spec/ruby/library/find/find_spec.rb
  14. +174 −0 spec/ruby/library/find/fixtures/common.rb
  15. +12 −0 spec/ruby/library/find/prune_spec.rb
  16. +14 −0 spec/ruby/library/matrix/vector/cross_product_spec.rb
  17. +10 −0 spec/ruby/library/pathname/realdirpath_spec.rb
  18. +10 −0 spec/ruby/library/pathname/realpath_spec.rb
  19. +38 −0 spec/ruby/library/socket/addrinfo/afamily_spec.rb
  20. +29 −0 spec/ruby/library/socket/addrinfo/bind_spec.rb
  21. +16 −0 spec/ruby/library/socket/addrinfo/canonname_spec.rb
  22. +253 −0 spec/ruby/library/socket/addrinfo/initialize_spec.rb
  23. +36 −0 spec/ruby/library/socket/addrinfo/ip_address_spec.rb
  24. +36 −0 spec/ruby/library/socket/addrinfo/ip_port_spec.rb
  25. +36 −0 spec/ruby/library/socket/addrinfo/ip_spec.rb
  26. +36 −0 spec/ruby/library/socket/addrinfo/ip_unpack_spec.rb
  27. +46 −0 spec/ruby/library/socket/addrinfo/ipv4_loopback_spec.rb
  28. +46 −0 spec/ruby/library/socket/addrinfo/ipv4_multicast_spec.rb
  29. +41 −0 spec/ruby/library/socket/addrinfo/ipv4_private_spec.rb
  30. +36 −0 spec/ruby/library/socket/addrinfo/ipv4_spec.rb
  31. +46 −0 spec/ruby/library/socket/addrinfo/ipv6_loopback_spec.rb
  32. +46 −0 spec/ruby/library/socket/addrinfo/ipv6_multicast_spec.rb
  33. +36 −0 spec/ruby/library/socket/addrinfo/ipv6_spec.rb
  34. +38 −0 spec/ruby/library/socket/addrinfo/pfamily_spec.rb
  35. +38 −0 spec/ruby/library/socket/addrinfo/protocol_spec.rb
  36. +35 −0 spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb
  37. +38 −0 spec/ruby/library/socket/addrinfo/socktype_spec.rb
  38. +20 −0 spec/ruby/library/socket/addrinfo/tcp_spec.rb
  39. +7 −0 spec/ruby/library/socket/addrinfo/to_s_spec.rb
  40. +7 −0 spec/ruby/library/socket/addrinfo/to_sockaddr_spec.rb
  41. +20 −0 spec/ruby/library/socket/addrinfo/udp_spec.rb
  42. +38 −0 spec/ruby/library/socket/addrinfo/unix_path_spec.rb
  43. +54 −0 spec/ruby/library/socket/addrinfo/unix_spec.rb
  44. +0 −4 spec/ruby/library/socket/fixtures/classes.rb
  45. +25 −0 spec/ruby/library/socket/option/bool_spec.rb
  46. +20 −0 spec/ruby/library/socket/option/inspect_spec.rb
  47. +28 −0 spec/ruby/library/socket/option/int_spec.rb
  48. +55 −0 spec/ruby/library/socket/option/linger_spec.rb
  49. +35 −0 spec/ruby/library/socket/option/new_spec.rb
  50. +6 −0 spec/ruby/library/socket/socket/connect_nonblock_spec.rb
  51. +15 −4 spec/ruby/library/socket/tcpserver/accept_nonblock_spec.rb
  52. +16 −0 spec/ruby/library/socket/tcpserver/listen_spec.rb
  53. +29 −0 spec/ruby/library/socket/tcpserver/sysaccept_spec.rb
  54. +48 −0 spec/ruby/library/socket/tcpsocket/setsockopt_spec.rb
  55. +46 −0 spec/ruby/library/stringio/getch_spec.rb
  56. +20 −0 spec/ruby/library/stringio/read_nonblock_spec.rb
  57. +15 −0 spec/ruby/library/stringio/shared/sysread.rb
  58. +19 −0 spec/ruby/library/stringio/write_nonblock_spec.rb
  59. +42 −0 spec/ruby/library/time/to_date_spec.rb
  60. +8 −0 spec/ruby/library/timeout/error_spec.rb
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
21 changes: 14 additions & 7 deletions spec/ruby/language/predefined_spec.rb
Original file line number Diff line number Diff line change
@@ -64,19 +64,26 @@
def obj.foo; yield; end
def obj.foo2(&proc); proc.call; end

match = /foo/.match "foo"
match2 = nil
match3 = nil
match4 = nil

obj.foo { match = /bar/.match("bar") }
match1 = /foo/.match "foo"

$~.should == match
obj.foo { match2 = /bar/.match("bar") }

eval 'match = /baz/.match("baz")'
match2.should_not == nil
$~.should == match2

$~.should == match
eval 'match3 = /baz/.match("baz")'

obj.foo2 { match = /qux/.match("qux") }
match3.should_not == nil
$~.should == match3

$~.should == match
obj.foo2 { match4 = /qux/.match("qux") }

match4.should_not == nil
$~.should == match4
end

it "raises an error if assigned an object not nil or instanceof MatchData" do
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
Loading