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

Commits on Mar 1, 2016

  1. Squashed 'spec/ruby/' changes from d9a07bf..8d632d3

    8d632d3 Fix a typo in Enumerable#grep specs
    eb9a915 Clean up the entire spec temp dir when finished with mock dirs.
    6793fc5 Add specs for constants with op assigns (2.0+ feature)
    2428acb Duplicate grep_v block specs for grep.
    f8fe203 Fix calls to close_read mistakenly copied as close_write.
    6c483a1 Remove trailing spaces
    aafde9a Setting umask seems unneeded for Dir specs
    75c3c99 Fix indent and verify better the behavior of Dir.chdir without arguments
    cafd965 Use full names in singleton_method_* fixtures to avoid confusion
    793b0f5 Improve specs of Module#method_added and BasicObject#singleton_method_added
    8c780f2 Fix namespace of BasicObject fixtures
    19b3530 Unshare BasicObject#singleton_method_{added,removed,undefined}
    7ec6446 Use ScratchPad instead of a global variable in Module#method_added spec
    55bbe8d Merge pull request #199 from wied03/master
    103e25a Test more block scenarios with super
    2e3116d Remove unnecessary version guards
    8d4cadb Prefer duplication to conditional code in specs
    bb36c64 Merge pull request #197 from nobu/Numeric#step-error
    33b90eb Numeric#step now raises TypeError
    5940ab5 Fix lower version
    dfb4e4b Merge pull request #196 from nobu/Numeric#step-error
    bad02c6 Numeric#step will not raise ArgumentError
    c559cd1 Fix location of version guard in Marshal#load
    dc20179 Merge pull request #193 from unak/patch-1
    51da767 Merge pull request #195 from iliabylich/reset-dollar-comma-gvar-back-to-nil
    ef2bd56 Reset $, global variable back to nil to prevent IO.print from breaking.
    44c6e32 taints float is 2.2 spec.
    73e1e0b Specify Array#dig with non-numeric index
    af15432 Merge pull request #191 from ruby/vais/masgn-const
    86e0894 Wrap specs for multiple assignment to constants in a VariableSpecs module
    fc1fee4 Add an example describing the behavior succinctly and a possible implementation for Fixnum#[]
    e7b8c65 Merge pull request #192 from mame/fixnum-aref-negative
    2900958 Merge pull request #190 from nobu/Symbol#match-fix
    7604cbc check if the result is a MatchData
    03f6140 Add some specs for `Fixnum#[]` when self is negative
    4f8ca98 Add specs for multiple assignment to constants
    51d46b1 New examples of Symbol#match since 2.4
    7c797ee Merge pull request #189 from nobu/Symbol#match-fix
    e450f73 Symbol#match will change at 2.4
    e5db1f0 Merge pull request #187 from alex88/patch-1
    0a9725a Add tests for Time.at with BigDecimal input
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 8d632d36026879e617eae21ba913873e72a70dda
    eregon committed Mar 1, 2016
    Copy the full SHA
    af839a0 View commit details
  2. Copy the full SHA
    d64a2da View commit details
Showing with 328 additions and 188 deletions.
  1. +9 −1 spec/ruby/core/array/dig_spec.rb
  2. +4 −4 spec/ruby/{fixtures/kernel → core/basicobject/fixtures}/singleton_method.rb
  3. +82 −2 spec/ruby/core/basicobject/singleton_method_added_spec.rb
  4. +15 −2 spec/ruby/core/basicobject/singleton_method_removed_spec.rb
  5. +16 −2 spec/ruby/core/basicobject/singleton_method_undefined_spec.rb
  6. +7 −5 spec/ruby/core/dir/chdir_spec.rb
  7. +0 −2 spec/ruby/core/dir/fixtures/common.rb
  8. +1 −1 spec/ruby/core/enumerable/grep_spec.rb
  9. +18 −0 spec/ruby/core/fixnum/element_reference_spec.rb
  10. +6 −6 spec/ruby/core/marshal/shared/load.rb
  11. +1 −1 spec/ruby/core/module/ancestors_spec.rb
  12. +1 −1 spec/ruby/core/module/fixtures/classes.rb
  13. +1 −1 spec/ruby/core/module/instance_methods_spec.rb
  14. +29 −17 spec/ruby/core/module/method_added_spec.rb
  15. +3 −3 spec/ruby/core/module/remove_method_spec.rb
  16. +2 −2 spec/ruby/core/module/to_s_spec.rb
  17. +3 −3 spec/ruby/core/module/undef_method_spec.rb
  18. +16 −5 spec/ruby/core/numeric/step_spec.rb
  19. +4 −8 spec/ruby/core/string/inspect_spec.rb
  20. +2 −2 spec/ruby/core/struct/initialize_spec.rb
  21. +23 −2 spec/ruby/core/symbol/match_spec.rb
  22. +7 −0 spec/ruby/core/time/at_spec.rb
  23. +2 −2 spec/ruby/language/alias_spec.rb
  24. +14 −14 spec/ruby/language/def_spec.rb
  25. +18 −0 spec/ruby/language/fixtures/super.rb
  26. +4 −0 spec/ruby/language/predefined_spec.rb
  27. +8 −0 spec/ruby/language/super_spec.rb
  28. +3 −3 spec/ruby/language/undef_spec.rb
  29. +29 −0 spec/ruby/language/variables_spec.rb
  30. +0 −60 spec/ruby/shared/kernel/singleton_method_added.rb
  31. +0 −20 spec/ruby/shared/kernel/singleton_method_removed.rb
  32. +0 −19 spec/ruby/shared/kernel/singleton_method_undefined.rb
10 changes: 9 additions & 1 deletion spec/ruby/core/array/dig_spec.rb
Original file line number Diff line number Diff line change
@@ -15,8 +15,16 @@
a.dig(0, -1, 0).should == 2
end

it "raises a TypeError for a non-numeric index" do
lambda {
['a'].dig(:first)
}.should raise_error(TypeError)
end

it "raises without any args" do
lambda { [10].dig() }.should raise_error(ArgumentError)
lambda {
[10].dig()
}.should raise_error(ArgumentError)
end

it "calls #dig on the result of #at with the remaining arguments" do
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module KernelSpecs
module BasicObjectSpecs
class SingletonMethod
def self.singleton_method_added name
ScratchPad.record [:method_added, name]
ScratchPad.record [:singleton_method_added, name]
end

def self.singleton_method_removed name
ScratchPad.record [:method_removed, name]
ScratchPad.record [:singleton_method_removed, name]
end

def self.singleton_method_undefined name
ScratchPad.record [:method_undefined, name]
ScratchPad.record [:singleton_method_undefined, name]
end

def self.singleton_method_to_alias
84 changes: 82 additions & 2 deletions spec/ruby/core/basicobject/singleton_method_added_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,86 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../../shared/kernel/singleton_method_added', __FILE__)
require File.expand_path('../fixtures/singleton_method', __FILE__)

describe "BasicObject#singleton_method_added" do
it_behaves_like(:singleton_method_added, :singleton_method_added, BasicObject)
before :each do
ScratchPad.clear
end

it "is a private method" do
BasicObject.should have_private_instance_method(:singleton_method_added)
end

it "is called when a singleton method is defined on an object" do
obj = BasicObject.new

def obj.singleton_method_added(name)
ScratchPad.record [:singleton_method_added, name]
end

def obj.new_singleton_method
end

ScratchPad.recorded.should == [:singleton_method_added, :new_singleton_method]
end

it "is not called for instance methods" do
ScratchPad.record []

Module.new do
def self.singleton_method_added(name)
ScratchPad << name
end

def new_instance_method
end
end

ScratchPad.recorded.should_not include(:new_instance_method)
end

it "is called when a singleton method is defined on a module" do
class BasicObjectSpecs::SingletonMethod
def self.new_method_on_self
end
end
ScratchPad.recorded.should == [:singleton_method_added, :new_method_on_self]
end

it "is called when a method is defined in the singleton class" do
class BasicObjectSpecs::SingletonMethod
class << self
def new_method_on_singleton
end
end
end
ScratchPad.recorded.should == [:singleton_method_added, :new_method_on_singleton]
end

it "is called when a method is defined with alias_method in the singleton class" do
class BasicObjectSpecs::SingletonMethod
class << self
alias_method :new_method_on_singleton_with_alias_method, :singleton_method_to_alias
end
end
ScratchPad.recorded.should == [:singleton_method_added, :new_method_on_singleton_with_alias_method]
end

it "is called when a method is defined with syntax alias in the singleton class" do
class BasicObjectSpecs::SingletonMethod
class << self
alias new_method_on_singleton_with_syntax_alias singleton_method_to_alias
end
end
ScratchPad.recorded.should == [:singleton_method_added, :new_method_on_singleton_with_syntax_alias]
end

it "is called when define_method is used in the singleton class" do
class BasicObjectSpecs::SingletonMethod
class << self
define_method :new_method_with_define_method do
end
end
end
ScratchPad.recorded.should == [:singleton_method_added, :new_method_with_define_method]
end
end
17 changes: 15 additions & 2 deletions spec/ruby/core/basicobject/singleton_method_removed_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../../shared/kernel/singleton_method_removed', __FILE__)
require File.expand_path('../fixtures/singleton_method', __FILE__)

describe "BasicObject#singleton_method_removed" do
it_behaves_like(:singleton_method_removed, :singleton_method_removed, BasicObject)
before :each do
ScratchPad.clear
end

it "is a private method" do
BasicObject.should have_private_instance_method(:singleton_method_removed)
end

it "is called when a method is removed on self" do
class << BasicObjectSpecs::SingletonMethod
remove_method :singleton_method_to_remove
end
ScratchPad.recorded.should == [:singleton_method_removed, :singleton_method_to_remove]
end
end
18 changes: 16 additions & 2 deletions spec/ruby/core/basicobject/singleton_method_undefined_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
require File.expand_path('../../../shared/kernel/singleton_method_undefined', __FILE__)
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/singleton_method', __FILE__)

describe "BasicObject#singleton_method_undefined" do
it_behaves_like(:singleton_method_undefined, :singleton_method_undefined, BasicObject)
before :each do
ScratchPad.clear
end

it "is a private method" do
BasicObject.should have_private_instance_method(:singleton_method_undefined)
end

it "is called when a method is removed on self" do
class << BasicObjectSpecs::SingletonMethod
undef_method :singleton_method_to_undefine
end
ScratchPad.recorded.should == [:singleton_method_undefined, :singleton_method_to_undefine]
end
end
12 changes: 7 additions & 5 deletions spec/ruby/core/dir/chdir_spec.rb
Original file line number Diff line number Diff line change
@@ -20,11 +20,12 @@

it "defaults to $HOME with no arguments" do
if ENV['HOME']
Dir.chdir(ENV['HOME'])
home = Dir.pwd
Dir.chdir
current_dir = Dir.pwd

Dir.chdir
Dir.pwd.should == home
Dir.chdir(ENV['HOME'])
home = Dir.pwd
current_dir.should == home
end
end

@@ -75,7 +76,8 @@ def to_str; DirSpecs.mock_dir; end
Dir.chdir { current_dir = Dir.pwd }

Dir.chdir(ENV['HOME'])
current_dir.should == Dir.pwd
home = Dir.pwd
current_dir.should == home
end

it "changes to the specified directory for the duration of the block" do
2 changes: 0 additions & 2 deletions spec/ruby/core/dir/fixtures/common.rb
Original file line number Diff line number Diff line change
@@ -102,13 +102,11 @@ def self.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
2 changes: 1 addition & 1 deletion spec/ruby/core/enumerable/grep_spec.rb
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ def (@odd_matcher = BasicObject.new).===(obj)
end

it "raises an ArgumentError when not given a pattern" do
-> { @numerous.grep_v { |e| e } }.should raise_error(ArgumentError)
-> { @numerous.grep { |e| e } }.should raise_error(ArgumentError)
end
end
end
18 changes: 18 additions & 0 deletions spec/ruby/core/fixnum/element_reference_spec.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
require File.expand_path('../../../spec_helper', __FILE__)

describe "Fixnum#[]" do
it "behaves like (n >> b) & 1" do
0b101[1].should == 0
0b101[2].should == 1
end

it "returns 1 if the nth bit is set" do
15[1].should == 1
end

it "returns 1 if the nth bit is set (in two's-complement representation)" do
(-1)[1].should == 1
end

it "returns 0 if the nth bit is not set" do
8[2].should == 0
end

it "returns 0 if the nth bit is not set (in two's-complement representation)" do
(-2)[0].should == 0
end

it "returns 0 if the nth bit is greater than the most significant bit" do
2[3].should == 0
end

it "returns 1 if self is negative and the nth bit is greater than the most significant bit" do
(-1)[3].should == 1
end

it "returns 0 when passed a negative argument" do
3[-1].should == 0
(-1)[-1].should == 0
end

it "calls #to_int to convert the argument to an Integer and returns 1 if the nth bit is set" do
12 changes: 6 additions & 6 deletions spec/ruby/core/marshal/shared/load.rb
Original file line number Diff line number Diff line change
@@ -221,13 +221,13 @@
y.tainted?.should be_true
y.first.tainted?.should be_false
end
end

it "does not taint Floats" do
x = [1.2]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
y.first.tainted?.should be_false
it "does not taint Floats" do
x = [1.2]
y = Marshal.send(@method, Marshal.dump(x).taint)
y.tainted?.should be_true
y.first.tainted?.should be_false
end
end
end

2 changes: 1 addition & 1 deletion spec/ruby/core/module/ancestors_spec.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
[ModuleSpecs::Parent, Object, Kernel, BasicObject]
ModuleSpecs.without_test_modules(ModuleSpecs::Child.ancestors).should ==
[ModuleSpecs::Child, ModuleSpecs::Super, ModuleSpecs::Basic, ModuleSpecs::Parent, Object, Kernel, BasicObject]
end
end

it "returns only modules and classes" do
class << ModuleSpecs::Child; self; end.ancestors.should include(ModuleSpecs::Internal, Class, Module, Object, Kernel)
2 changes: 1 addition & 1 deletion spec/ruby/core/module/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ def self.without_test_modules(modules)
ignore = %w[MSpecRSpecAdapter PP::ObjectMixin ModuleSpecs::IncludedInObject MainSpecs::Module ConstantSpecs::ModuleA]
modules.reject { |k| ignore.include?(k.name) }
end

CONST = :plain_constant

module PrivConstModule
2 changes: 1 addition & 1 deletion spec/ruby/core/module/instance_methods_spec.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
methods = ModuleSpecs::Parent.instance_methods(false)
methods.should_not include(:undefed_method)
end

it "only includes module methods on an included module" do
methods = ModuleSpecs::Basic.instance_methods(false)
methods.should include(:public_module)
46 changes: 29 additions & 17 deletions spec/ruby/core/module/method_added_spec.rb
Original file line number Diff line number Diff line change
@@ -12,26 +12,38 @@
end
end

it "is called when a new method is defined in self" do
begin
$methods_added = []

m = Module.new do
def self.method_added(name)
$methods_added << name
end

def test() end
def test2() end
def test() end
alias_method :aliased_test, :test
alias aliased_test2 test
it "is called when a new instance method is defined in self" do
ScratchPad.record []

Module.new do
def self.method_added(name)
ScratchPad << name
end

$methods_added.should == [:test, :test2, :test, :aliased_test, :aliased_test2]
ensure
$methods_added = nil
def test() end
def test2() end
def test() end
alias_method :aliased_test, :test
alias aliased_test2 test
end

ScratchPad.recorded.should == [:test, :test2, :test, :aliased_test, :aliased_test2]
end

it "is not called when a singleton method is added" do
# obj.singleton_method_added is called instead
ScratchPad.record []

klass = Class.new
def klass.method_added(name)
ScratchPad << name
end

obj = klass.new
def obj.new_singleton_method
end

ScratchPad.recorded.should == []
end

it "is not called when a method is undefined in self" do
6 changes: 3 additions & 3 deletions spec/ruby/core/module/remove_method_spec.rb
Original file line number Diff line number Diff line change
@@ -25,11 +25,11 @@ def method_to_remove; 1; end
class Second < First
def method_to_remove; 2; end
end

class Multiple
def method_to_remove_1; 1; end
def method_to_remove_2; 2; end

remove_method :method_to_remove_1, :method_to_remove_2
end
end
@@ -53,7 +53,7 @@ def method_to_remove_2; 2; end
x.respond_to?(:method_to_remove).should == true
x.method_to_remove.should == 1
end

it "removes multiple methods with 1 call" do
x = ModuleSpecs::Multiple.new
x.respond_to?(:method_to_remove_1).should == false
Loading