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: ba6e48001453
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bd88513c02fc
Choose a head ref
  • 3 commits
  • 56 files changed
  • 1 contributor

Commits on May 29, 2016

  1. Squashed 'spec/ruby/' changes from 5c54bc7..842119c

    842119c Guard spec currently failing on Windows
    aa107f7 Write in text mode to allow newline conversion and read in binary mode
    a7ad8dd Use binary open modes for testing newlines
    5240f19 Simplify language spec to use clearer Proc#call instead of Proc#[]
    0142e23 Specs for Proc#arity. The current specs cover lambdas twice.
    646adc2 Add a spec for zsuper passing splat and keyword arguments together
    7a70098 Spec for not capturing a local variable in place of a block argument.
    3963efc Spec for a block local assigned in a nested scope before initialization.
    a1b181b [Truffle] Implement rb_ary_new_from_args.
    512c59c Add spec to check string constructed from Array#pack has valid encoding.
    98fc8f5 Add multi-byte character specs for String#{gsub,gsub!}.
    342b52b [Truffle] Implement rb_Array().
    6f3d788 [Truffle] rb_ary_store passes.
    56fd602 [Truffle] Implement RARRAY_AREF.
    69068e0 Test RARRAY_LEN even if RARRAY_PTR is not defined.
    0b4fb5f [Truffle] rb_ary_{entry,push,pop}
    525374c [Truffle] rb_ary_new2 is working a well.
    38ccb78 [Truffle] First C-API spec passing!
    7d7c404 Add support for compiling & testing optional C API specs on JRuby+Truffle.
    f128b49 Make sure Object.const_missing is not called for defined?(Undefined::Object)
    2056323 Fix spec to compare hashes properly.
    3904950 Add a spec for hashing a double-nested array with inner zarray.
    f253ed0 Also check content of encoded File.basename result.
    dbb6b46 Test that File.basename preserves the encoding of the original.
    60f3439 Add some specs for puts with newline conversion.
    c551794 Expand specs for visibility under direct and indirect situations.
    0017fcd Wrap extra GNU Readline features in platform guards so it passes on OS X libedit
    f79cdb7 Merge pull request #261 from nobu/master
    8aa3424 protoize CAPI test codes
    bab5937 Specify rb_define_class
    beacfe6 Disable readline specs on Windows for now as the behavior varies significantly
    62ba370 Let's try to enable the readline specs by default again.
    3e46008 Merge pull request #260 from nobu/fix-capi-warnings
    d87060a Remove not portable and unrealistic DATA spec
    1895d1f Merge pull request #259 from odaira/myContribution
    b557adb Fix suggest-attribute=noreturn
    84511ed Add a spec for DATA.rewind
    2cb8dd7 Merge pull request #258 from nobu/refine-setsid
    9a72b57 Check session ID values
    5f98f99 Try to make the rb_big_pack spec more accurate
    494be5b Do not rely on Fixnum class name in Process#setsid spec
    67b01ca Allow Fixnum = Integer for rb_obj_classname
    5be3488 Adapt specs for improvements in Bignum#coerce
    c501ee4 Do not try to call rb_big functions with fixnum-range values.
    369c97e Make sure our assumptions hold about the ensure_bignum helper
    b6abf84 Merge pull request #255 from odaira/myContribution
    d406960 Cannot flock DATA with LOCK_EX on AIX because a file opened as read-only cannot be exclusively locked on AIX
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 842119cca99f84503f574ee4fb42bfb7a8d80f2f
    eregon committed May 29, 2016
    Copy the full SHA
    e608800 View commit details
  2. Copy the full SHA
    0553e72 View commit details
  3. [Truffle] Tags for new specs.

    eregon committed May 29, 2016
    Copy the full SHA
    bd88513 View commit details
Showing with 463 additions and 134 deletions.
  1. +8 −5 spec/ruby/core/bignum/coerce_spec.rb
  2. +10 −8 spec/ruby/core/io/puts_spec.rb
  3. +232 −0 spec/ruby/core/proc/arity_spec.rb
  4. +11 −3 spec/ruby/core/process/setsid_spec.rb
  5. +1 −8 spec/ruby/default.mspec
  6. +18 −0 spec/ruby/language/block_spec.rb
  7. +14 −0 spec/ruby/language/fixtures/super.rb
  8. +2 −17 spec/ruby/language/predefined/data_spec.rb
  9. +5 −0 spec/ruby/language/predefined/fixtures/data5.rb
  10. +0 −3 spec/ruby/language/predefined/fixtures/data_flock.rb
  11. +8 −0 spec/ruby/language/super_spec.rb
  12. +13 −11 spec/ruby/library/readline/basic_quote_characters_spec.rb
  13. +8 −6 spec/ruby/library/readline/emacs_editing_mode_spec.rb
  14. +13 −11 spec/ruby/library/readline/filename_quote_characters_spec.rb
  15. +8 −6 spec/ruby/library/readline/vi_editing_mode_spec.rb
  16. +7 −15 spec/ruby/optional/capi/bignum_spec.rb
  17. +41 −0 spec/ruby/optional/capi/class_spec.rb
  18. +1 −1 spec/ruby/optional/capi/ext/array_spec.c
  19. +1 −1 spec/ruby/optional/capi/ext/bignum_spec.c
  20. +12 −1 spec/ruby/optional/capi/ext/class_spec.c
  21. +1 −1 spec/ruby/optional/capi/ext/complex_spec.c
  22. +1 −1 spec/ruby/optional/capi/ext/constants_spec.c
  23. +1 −1 spec/ruby/optional/capi/ext/data_spec.c
  24. +1 −1 spec/ruby/optional/capi/ext/encoding_spec.c
  25. +1 −1 spec/ruby/optional/capi/ext/enumerator_spec.c
  26. +2 −2 spec/ruby/optional/capi/ext/exception_spec.c
  27. +1 −1 spec/ruby/optional/capi/ext/file_spec.c
  28. +1 −1 spec/ruby/optional/capi/ext/fixnum_spec.c
  29. +1 −1 spec/ruby/optional/capi/ext/float_spec.c
  30. +1 −1 spec/ruby/optional/capi/ext/gc_spec.c
  31. +1 −1 spec/ruby/optional/capi/ext/globals_spec.c
  32. +1 −1 spec/ruby/optional/capi/ext/hash_spec.c
  33. +1 −1 spec/ruby/optional/capi/ext/integer_spec.c
  34. +1 −1 spec/ruby/optional/capi/ext/io_spec.c
  35. +7 −6 spec/ruby/optional/capi/ext/kernel_spec.c
  36. +1 −1 spec/ruby/optional/capi/ext/marshal_spec.c
  37. +1 −1 spec/ruby/optional/capi/ext/module_spec.c
  38. +1 −1 spec/ruby/optional/capi/ext/mutex_spec.c
  39. +1 −1 spec/ruby/optional/capi/ext/numeric_spec.c
  40. +1 −1 spec/ruby/optional/capi/ext/object_spec.c
  41. +1 −1 spec/ruby/optional/capi/ext/proc_spec.c
  42. +1 −1 spec/ruby/optional/capi/ext/range_spec.c
  43. +1 −1 spec/ruby/optional/capi/ext/rational_spec.c
  44. +1 −1 spec/ruby/optional/capi/ext/regexp_spec.c
  45. +1 −0 spec/ruby/optional/capi/ext/rubyspec.h
  46. +1 −1 spec/ruby/optional/capi/ext/string_spec.c
  47. +1 −1 spec/ruby/optional/capi/ext/struct_spec.c
  48. +1 −1 spec/ruby/optional/capi/ext/symbol_spec.c
  49. +1 −1 spec/ruby/optional/capi/ext/thread_spec.c
  50. +1 −1 spec/ruby/optional/capi/ext/time_spec.c
  51. +1 −1 spec/ruby/optional/capi/ext/typed_data_spec.c
  52. +1 −1 spec/ruby/optional/capi/ext/util_spec.c
  53. +1 −1 spec/ruby/optional/capi/object_spec.rb
  54. +8 −0 spec/truffle/tags/core/proc/arity_tags.txt
  55. +1 −0 spec/truffle/tags/language/predefined/data_tags.txt
  56. +1 −0 spec/truffle/tags/language/super_tags.txt
13 changes: 8 additions & 5 deletions spec/ruby/core/bignum/coerce_spec.rb
Original file line number Diff line number Diff line change
@@ -29,16 +29,19 @@
lambda { a.coerce(:test) }.should raise_error(TypeError)
end

not_compliant_on :rubinius do
it "raises a TypeError when passed a Float or String" do
ruby_version_is ""..."2.4" do
it "raises a TypeError when passed a String" do
a = bignum_value

lambda { a.coerce(12.3) }.should raise_error(TypeError)
lambda { a.coerce("123") }.should raise_error(TypeError)
end

it "raises a TypeError when passed a Float" do
a = bignum_value
lambda { a.coerce(12.3) }.should raise_error(TypeError)
end
end

deviates_on :rubinius do
ruby_version_is "2.4" do
it "coerces both values to Floats and returns [other, self] when passed a Float" do
a = bignum_value
a.coerce(1.2).should == [1.2, a.to_f]
18 changes: 10 additions & 8 deletions spec/ruby/core/io/puts_spec.rb
Original file line number Diff line number Diff line change
@@ -119,24 +119,26 @@ def @io.write(str)

with_feature :encoding do
it "writes crlf when IO is opened with newline: :crlf" do
File.open(@name, 'w', newline: :crlf) do |file|
File.open(@name, 'wt', newline: :crlf) do |file|
file.puts
end
File.read(@name).should == "\r\n"
File.binread(@name).should == "\r\n"
end

it "writes cr when IO is opened with newline: :cr" do
File.open(@name, 'w', newline: :cr) do |file|
File.open(@name, 'wt', newline: :cr) do |file|
file.puts
end
File.read(@name).should == "\r"
File.binread(@name).should == "\r"
end

it "writes lf when IO is opened with newline: :lf" do
File.open(@name, 'w', newline: :lf) do |file|
file.puts
platform_is_not :windows do # https://bugs.ruby-lang.org/issues/12436
it "writes lf when IO is opened with newline: :lf" do
File.open(@name, 'wt', newline: :lf) do |file|
file.puts
end
File.binread(@name).should == "\n"
end
File.read(@name).should == "\n"
end
end
end
232 changes: 232 additions & 0 deletions spec/ruby/core/proc/arity_spec.rb
Original file line number Diff line number Diff line change
@@ -423,4 +423,236 @@
end
end
end

context "for instances created with proc { || }" do
context "returns zero" do
evaluate <<-ruby do
@a = proc { }
@b = proc { || }
ruby

@a.arity.should == 0
@b.arity.should == 0
end

evaluate <<-ruby do
@a = proc { |&b| }
ruby

@a.arity.should == 0
end

evaluate <<-ruby do
@a = proc { |a=1| }
@b = proc { |a=1, b=2| }
ruby

@a.arity.should == 0
@b.arity.should == 0
end

evaluate <<-ruby do
@a = proc { |a: 1| }
@b = proc { |a: 1, b: 2| }
ruby

@a.arity.should == 0
@b.arity.should == 0
end

evaluate <<-ruby do
@a = proc { |**k, &l| }
@b = proc { |a: 1, b: 2, **k| }
ruby

@a.arity.should == 0
@b.arity.should == 0
end

evaluate <<-ruby do
@a = proc { |a=1, b: 2| }
@b = proc { |a=1, b: 2| }
ruby

@a.arity.should == 0
@b.arity.should == 0
end
end

context "returns positive values" do
evaluate <<-ruby do
@a = proc { |a| }
@b = proc { |a, b| }
@c = proc { |a, b, c| }
@d = proc { |a, b, c, d| }
ruby

@a.arity.should == 1
@b.arity.should == 2
@c.arity.should == 3
@d.arity.should == 4
end

evaluate <<-ruby do
@a = proc { |a, b=1| }
@b = proc { |a, b, c=1, d=2| }
ruby

@a.arity.should == 1
@b.arity.should == 2
end

evaluate <<-ruby do
@a = lambda { |a:| }
@b = lambda { |a:, b:| }
@c = lambda { |a: 1, b:, c:, d: 2| }
ruby

@a.arity.should == 1
@b.arity.should == 1
@c.arity.should == 1
end

evaluate <<-ruby do
@a = proc { |a, b:| }
@b = proc { |a, b:, &l| }
ruby

@a.arity.should == 2
@b.arity.should == 2
end

evaluate <<-ruby do
@a = proc { |a, b, c:, d: 1| }
@b = proc { |a, b, c:, d: 1, **k, &l| }
ruby

@a.arity.should == 3
@b.arity.should == 3
end

evaluate <<-ruby do
@a = proc { |a, b, c:, d: 1| }
@b = proc { |a, b, c:, d: 1, **k, &l| }
ruby

@a.arity.should == 3
@b.arity.should == 3
end

evaluate <<-ruby do
@a = proc { |(a, (*b, c)), d=1| }
@b = proc { |a, (*b, c), d, (*e), (*), **k| }
ruby

@a.arity.should == 1
@b.arity.should == 5
end
end

context "returns negative values" do
evaluate <<-ruby do
@a = proc { |a=1, *b| }
@b = proc { |a=1, b=2, *c| }
ruby

@a.arity.should == -1
@b.arity.should == -1
end

evaluate <<-ruby do
@a = proc { |*| }
@b = proc { |*a| }
ruby

@a.arity.should == -1
@b.arity.should == -1
end

evaluate <<-ruby do
@a = proc { |a, *| }
@b = proc { |a, *b| }
@c = proc { |a, b, *c| }
@d = proc { |a, b, c, *d| }
ruby

@a.arity.should == -2
@b.arity.should == -2
@c.arity.should == -3
@d.arity.should == -4
end

evaluate <<-ruby do
@a = proc { |*a, b| }
@b = proc { |*a, b, c| }
@c = proc { |*a, b, c, d| }
ruby

@a.arity.should == -2
@b.arity.should == -3
@c.arity.should == -4
end

evaluate <<-ruby do
@a = proc { |a, *b, c| }
@b = proc { |a, b, *c, d, e| }
ruby

@a.arity.should == -3
@b.arity.should == -5
end

evaluate <<-ruby do
@a = proc { |a, b=1, c=2, *d, e, f| }
@b = proc { |a, b, c=1, *d, e, f, g| }
ruby

@a.arity.should == -4
@b.arity.should == -6
end

evaluate <<-ruby do
@a = proc { |*a, b: 1| }
@b = proc { |a=1, *b, c: 2, &l| }
ruby

@a.arity.should == -1
@b.arity.should == -1
end

evaluate <<-ruby do
@a = proc { |*a, **k| }
ruby

@a.arity.should == -1
end

evaluate <<-ruby do
@a = proc { |a=1, *b, c:, d: 2, **k, &l| }
ruby

@a.arity.should == -2
end

evaluate <<-ruby do
@a = proc { |a, (b, c), *, d:, e: 2, **| }
ruby

@a.arity.should == -4
end

evaluate <<-ruby do
@a = proc { |a, b=1, *c, d, e:, f: 2, **k, &l| }
@b = proc { |a, b=1, *c, d:, e:, f: 2, **k, &l| }
@c = proc { |a=0, b=1, *c, d, e:, f: 2, **k, &l| }
@d = proc { |a=0, b=1, *c, d:, e:, f: 2, **k, &l| }
ruby

@a.arity.should == -4
@b.arity.should == -3
@c.arity.should == -3
@d.arity.should == -2
end
end
end
end
14 changes: 11 additions & 3 deletions spec/ruby/core/process/setsid_spec.rb
Original file line number Diff line number Diff line change
@@ -4,23 +4,31 @@
with_feature :fork do
it "establishes this process as a new session and process group leader" do
read, write = IO.pipe
read2, write2 = IO.pipe
pid = Process.fork {
begin
read.close
write2.close
pgid = Process.setsid
write << pgid.class.to_s
write << pgid
write.close
read2.gets
rescue Exception => e
write << e << e.backtrace
end
Process.exit!
}
write.close
klass = read.gets
read2.close
pgid_child = read.gets
read.close
pgid = Process.getsid(pid)
write2.close
Process.wait pid

klass.should == "Fixnum"
pgid_child = Integer(pgid_child)
pgid_child.should == pgid
pgid_child.should_not == Process.getsid
end
end
end
9 changes: 1 addition & 8 deletions spec/ruby/default.mspec
Original file line number Diff line number Diff line change
@@ -48,12 +48,5 @@ class MSpecScript
MSpec.enable_feature :continuation_library
MSpec.enable_feature :fork unless PlatformGuard.windows?
MSpec.enable_feature :encoding

# The Readline specs are not enabled by default because the functionality
# depends heavily on the underlying library, including whether certain
# methods are implemented or not. This makes it extremely difficult to
# make the specs consistently pass. Until a suitable scheme to handle
# all these issues, the specs will not be enabled by default.
#
# MSpec.enable_feature :readline
MSpec.enable_feature :readline unless PlatformGuard.windows?
end
18 changes: 18 additions & 0 deletions spec/ruby/language/block_spec.rb
Original file line number Diff line number Diff line change
@@ -201,6 +201,14 @@ def m(a) yield a end
var.should == 1
end

it "does not capture a local when the block argument has the same name" do
var = 1
proc { |&var|
var.call(2)
}.call { |x| x }.should == 2
var.should == 1
end

describe "taking zero arguments" do
it "does not raise an exception when no values are yielded" do
@y.z { 1 }.should == 1
@@ -721,6 +729,16 @@ def m(a) yield a end
glark.should be_nil
end
end

it "are visible in deeper scopes before initialization" do
[1].each {|;glark|
[1].each {
defined?(glark).should_not be_nil
glark = 1
}
glark.should == 1
}
end
end

describe "Post-args" do
14 changes: 14 additions & 0 deletions spec/ruby/language/fixtures/super.rb
Original file line number Diff line number Diff line change
@@ -529,4 +529,18 @@ def foobar(array)
end
end
end

module SplatAndKeyword
class A
def foo(*args, **options)
[args, options]
end
end

class B < A
def foo(*args, **options)
super
end
end
end
end
Loading