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

Commits on Mar 18, 2015

  1. Squashed 'spec/ruby/' changes from 63695c3..2e07d5c

    2e07d5c Prefer a ruby_version_is guard in this case.
    6ea2a98 Fix wording about optional specs.
    46fb78d Simplify default config file: no more outdated libraries!
    373d2a3 Remove obsolete ping library specs.
    1db87a9 Remove obsolete parsedate library specs.
    6814224 Remove obsolete generator library specs.
    e0ec0c7 Remove obsolete ftools library specs.
    1dfdb35 Remove obsolete enumerator library specs.
    05c8f6d Remove library exclusion of no-longer existing directories.
    fcbe567 Add a few specs for Kernel#class.
    d26ba36 Remove specs in core/basicobject unrelated to BasicObject methods.
    ca9099e Fix location of some specs of BasicObject#instance_eval which were in core/kernel.
    08aef2d Fix location of BasicObject#instance_exec spec which was in core/object.
    347128a Share classes of instance_of? and kind_of?/is_a?.
    6fa6e79 Fix location of Kernel#instance_of? spec which was in core/object.
    b277a38 Fix location of Kernel#=~ spec which was in core/object.
    8e27ac5 No such thing as Object#metaclass.
    de66abd There is no such thing as Object.new, move specs to BasicObject#initialize.
    d6faac8 Fix location of Kernel#object_id spec which was in core/object.
    23489ce Fix location of Kernel#{is_a?,kind_of?} specs which were in core/object.
    1c1fae2 Remove empty spec file.
    8e9144c Fix location of some Kernel#{dup,clone} specs which were in core/object.
    64743bb Fix location of a spec related to Method#to_proc.
    283b8d8 add guard for 64bit dependent specs
    e0f68e1 Use America/New_York instead of US/Eastern
    3a753c5 Fix defined? argument
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 2e07d5c6e1cd97b8d44f93073e02d2a23f5f0ff9
    eregon committed Mar 18, 2015
    Copy the full SHA
    d6c9ba5 View commit details
  2. Copy the full SHA
    cefcede View commit details
Showing with 432 additions and 1,264 deletions.
  1. +2 −2 spec/ruby/core/basicobject/__id__spec.rb
  2. +0 −7 spec/ruby/core/basicobject/ancestors_spec.rb
  3. +0 −7 spec/ruby/core/basicobject/class_spec.rb
  4. +33 −0 spec/ruby/core/basicobject/fixtures/classes.rb
  5. +6 −0 spec/ruby/core/basicobject/initialize_spec.rb
  6. +138 −0 spec/ruby/core/basicobject/instance_eval_spec.rb
  7. +90 −0 spec/ruby/core/basicobject/instance_exec_spec.rb
  8. +0 −10 spec/ruby/core/basicobject/new_spec.rb
  9. +0 −7 spec/ruby/core/basicobject/superclass_spec.rb
  10. +4 −2 spec/ruby/core/integer/round_spec.rb
  11. +21 −1 spec/ruby/core/kernel/class_spec.rb
  12. +12 −0 spec/ruby/core/kernel/clone_spec.rb
  13. +10 −0 spec/ruby/core/kernel/dup_spec.rb
  14. +21 −32 spec/ruby/core/kernel/fixtures/classes.rb
  15. +0 −141 spec/ruby/core/kernel/instance_eval_spec.rb
  16. +37 −2 spec/ruby/core/kernel/instance_of_spec.rb
  17. +2 −1 spec/ruby/core/kernel/is_a_spec.rb
  18. +2 −1 spec/ruby/core/kernel/kind_of_spec.rb
  19. +10 −2 spec/ruby/core/kernel/match_spec.rb
  20. +6 −0 spec/ruby/core/kernel/object_id_spec.rb
  21. +1 −1 spec/ruby/core/{object → kernel}/shared/dup_clone.rb
  22. +9 −25 spec/ruby/core/{object → kernel}/shared/kind_of.rb
  23. +5 −0 spec/ruby/core/method/to_proc_spec.rb
  24. +1 −0 spec/ruby/core/module/ancestors_spec.rb
  25. +0 −17 spec/ruby/core/object/clone_spec.rb
  26. +0 −14 spec/ruby/core/object/dup_spec.rb
  27. +0 −17 spec/ruby/core/object/fixtures/classes.rb
  28. +0 −1 spec/ruby/core/object/initialize_spec.rb
  29. +0 −97 spec/ruby/core/object/instance_exec_spec.rb
  30. +0 −53 spec/ruby/core/object/instance_of_spec.rb
  31. +0 −6 spec/ruby/core/object/is_a_spec.rb
  32. +0 −6 spec/ruby/core/object/kind_of_spec.rb
  33. +0 −14 spec/ruby/core/object/match_spec.rb
  34. +0 −9 spec/ruby/core/object/metaclass_spec.rb
  35. +0 −13 spec/ruby/core/object/new_spec.rb
  36. +0 −7 spec/ruby/core/object/object_id_spec.rb
  37. +1 −1 spec/ruby/core/time/getlocal_spec.rb
  38. +1 −1 spec/ruby/core/time/localtime_spec.rb
  39. +2 −2 spec/ruby/core/time/shared/local.rb
  40. +4 −4 spec/ruby/core/time/zone_spec.rb
  41. +4 −37 spec/ruby/default.mspec
  42. +1 −1 spec/ruby/language/constants_spec.rb
  43. +0 −7 spec/ruby/library/enumerator/each_spec.rb
  44. +0 −9 spec/ruby/library/enumerator/each_with_index_spec.rb
  45. +0 −10 spec/ruby/library/enumerator/enum_cons_spec.rb
  46. +0 −10 spec/ruby/library/enumerator/enum_for_spec.rb
  47. +0 −16 spec/ruby/library/enumerator/enum_slice_spec.rb
  48. +0 −16 spec/ruby/library/enumerator/enum_with_index_spec.rb
  49. +0 −14 spec/ruby/library/enumerator/new_spec.rb
  50. +0 −10 spec/ruby/library/enumerator/next_spec.rb
  51. +0 −10 spec/ruby/library/enumerator/rewind_spec.rb
  52. +0 −10 spec/ruby/library/enumerator/to_enum_spec.rb
  53. +0 −9 spec/ruby/library/enumerator/with_index_spec.rb
  54. +0 −20 spec/ruby/library/ftools/catname_spec.rb
  55. +0 −30 spec/ruby/library/ftools/chmod_spec.rb
  56. +0 −31 spec/ruby/library/ftools/compare_spec.rb
  57. +0 −35 spec/ruby/library/ftools/copy_spec.rb
  58. +0 −26 spec/ruby/library/ftools/install_spec.rb
  59. +0 −25 spec/ruby/library/ftools/makedirs_spec.rb
  60. +0 −34 spec/ruby/library/ftools/move_spec.rb
  61. +0 −27 spec/ruby/library/ftools/safe_unlink_spec.rb
  62. +0 −35 spec/ruby/library/ftools/syscopy_spec.rb
  63. +0 −33 spec/ruby/library/generator/each_spec.rb
  64. +0 −21 spec/ruby/library/generator/fixtures/common.rb
  65. +0 −26 spec/ruby/library/generator/new_spec.rb
  66. +0 −79 spec/ruby/library/generator/next_spec.rb
  67. +0 −34 spec/ruby/library/generator/rewind_spec.rb
  68. +0 −107 spec/ruby/library/parsedate/parsedate_spec.rb
  69. +0 −29 spec/ruby/library/ping/pingecho_spec.rb
  70. +6 −4 spec/ruby/optional/capi/numeric_spec.rb
  71. +2 −5 spec/ruby/shared/{object → kernel}/object_id.rb
  72. +1 −1 spec/ruby/spec_helper.rb
4 changes: 2 additions & 2 deletions spec/ruby/core/basicobject/__id__spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../../shared/object/object_id', __FILE__)
require File.expand_path('../../../shared/kernel/object_id', __FILE__)

describe "BasicObject#__id__" do
it_behaves_like :basic_object_id, :__id__, BasicObject
it_behaves_like :object_id, :__id__, BasicObject
end
7 changes: 0 additions & 7 deletions spec/ruby/core/basicobject/ancestors_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/core/basicobject/class_spec.rb

This file was deleted.

33 changes: 33 additions & 0 deletions spec/ruby/core/basicobject/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module BasicObjectSpecs
class IVars
def initialize
@secret = 99
end
end

module InstExec
def self.included(base)
base.instance_exec { @@count = 2 }
end
end

module InstExecIncluded
include InstExec
end

module InstEvalCVar
instance_eval { @@count = 2 }
end

class InstEvalConst
INST_EVAL_CONST_X = 2
end

module InstEvalOuter
module Inner
obj = InstEvalConst.new
X_BY_STR = obj.instance_eval("INST_EVAL_CONST_X") rescue nil
X_BY_BLOCK = obj.instance_eval { INST_EVAL_CONST_X } rescue nil
end
end
end
6 changes: 6 additions & 0 deletions spec/ruby/core/basicobject/initialize_spec.rb
Original file line number Diff line number Diff line change
@@ -4,4 +4,10 @@
it "is a private instance method" do
BasicObject.should have_private_instance_method(:initialize)
end

it "does not accept arguments" do
lambda {
BasicObject.new("This", "makes it easier", "to call super", "from other constructors")
}.should raise_error(ArgumentError)
end
end
138 changes: 138 additions & 0 deletions spec/ruby/core/basicobject/instance_eval_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "BasicObject#instance_eval" do
before :each do
ScratchPad.clear
end

it "is a public instance method" do
BasicObject.should have_public_instance_method(:instance_eval)
end
@@ -14,4 +19,137 @@
a = BasicObject.new
a.instance_eval('self').equal?(a).should be_true
end

it "expects a block with no arguments" do
lambda { "hola".instance_eval }.should raise_error(ArgumentError)
end

it "takes no arguments with a block" do
lambda { "hola".instance_eval(4, 5) {|a,b| a + b } }.should raise_error(ArgumentError)
end

it "yields the object to the block" do
"hola".instance_eval {|o| ScratchPad.record o }
ScratchPad.recorded.should == "hola"
end

it "returns the result of the block" do
"hola".instance_eval { :result }.should == :result
end

it "only binds the eval to the receiver" do
f = Object.new
f.instance_eval do
def foo
1
end
end
f.foo.should == 1
lambda { Object.new.foo }.should raise_error(NoMethodError)
end

it "preserves self in the original block when passed a block argument" do
prc = proc { self }

old_self = prc.call

new_self = Object.new
new_self.instance_eval(&prc).should == new_self

prc.call.should == old_self
end

# TODO: This should probably be replaced with a "should behave like" that uses
# the many scoping/binding specs from kernel/eval_spec, since most of those
# behaviors are the same for instance_eval. See also module_eval/class_eval.

it "binds self to the receiver" do
s = "hola"
(s == s.instance_eval { self }).should be_true
o = mock('o')
(o == o.instance_eval("self")).should be_true
end

it "executes in the context of the receiver" do
"Ruby-fu".instance_eval { size }.should == 7
"hola".instance_eval("size").should == 4
Object.class_eval { "hola".instance_eval("to_s") }.should == "hola"
Object.class_eval { "Ruby-fu".instance_eval{ to_s } }.should == "Ruby-fu"

end

it "has access to receiver's instance variables" do
BasicObjectSpecs::IVars.new.instance_eval { @secret }.should == 99
BasicObjectSpecs::IVars.new.instance_eval("@secret").should == 99
end

it "treats block-local variables as local to the block" do
prc = instance_eval <<-CODE
proc do |x, prc|
if x
n = 2
else
n = 1
prc.call(true, prc)
n
end
end
CODE

prc.call(false, prc).should == 1
end

# On 1.9 class variables aren't inherited so we have to modify the test
# from 1.8
it "sets class variables in the receiver" do
BasicObjectSpecs::InstEvalCVar.class_variables.should include(:@@count)
BasicObjectSpecs::InstEvalCVar.send(:class_variable_get, :@@count).should == 2
end

it "makes the receiver metaclass the scoped class when used with a string" do
obj = Object.new
klass = obj.instance_eval %{
class B; end
B
}
obj.singleton_class.const_get(:B).should be_an_instance_of(Class)
end

it "gets constants in the receiver if a string given" do
BasicObjectSpecs::InstEvalOuter::Inner::X_BY_STR.should == 2
end

it "doesn't get constants in the receiver if a block given" do
BasicObjectSpecs::InstEvalOuter::Inner::X_BY_BLOCK.should be_nil
end

it "raises a TypeError when defining methods on an immediate" do
lambda do
1.instance_eval { def foo; end }
end.should raise_error(TypeError)
lambda do
:foo.instance_eval { def foo; end }
end.should raise_error(TypeError)
end

quarantine! do # Not clean, leaves cvars lying around to break other specs
it "scopes class var accesses in the caller when called on a Fixnum" do
# Fixnum can take instance vars
Fixnum.class_eval "@@__tmp_instance_eval_spec = 1"
(defined? @@__tmp_instance_eval_spec).should be_nil

@@__tmp_instance_eval_spec = 2
1.instance_eval { @@__tmp_instance_eval_spec }.should == 2
Fixnum.__send__(:remove_class_variable, :@@__tmp_instance_eval_spec)
end
end

it "raises a TypeError when defining methods on numerics" do
lambda do
(1.0).instance_eval { def foo; end }
end.should raise_error(TypeError)
lambda do
(1 << 64).instance_eval { def foo; end }
end.should raise_error(TypeError)
end
end
90 changes: 90 additions & 0 deletions spec/ruby/core/basicobject/instance_exec_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "BasicObject#instance_exec" do
it "is a public instance method" do
@@ -14,4 +15,93 @@
a = BasicObject.new
a.instance_exec(1) { |b| b }.should equal(1)
end

it "raises a LocalJumpError unless given a block" do
lambda { "hola".instance_exec }.should raise_error(LocalJumpError)
end

it "has an arity of -1" do
Object.new.method(:instance_exec).arity.should == -1
end

it "accepts arguments with a block" do
lambda { "hola".instance_exec(4, 5) { |a,b| a + b } }.should_not raise_error
end

it "doesn't pass self to the block as an argument" do
"hola".instance_exec { |o| o }.should be_nil
end

it "passes any arguments to the block" do
Object.new.instance_exec(1,2) {|one, two| one + two}.should == 3
end

it "only binds the exec to the receiver" do
f = Object.new
f.instance_exec do
def foo
1
end
end
f.foo.should == 1
lambda { Object.new.foo }.should raise_error(NoMethodError)
end

# TODO: This should probably be replaced with a "should behave like" that uses
# the many scoping/binding specs from kernel/eval_spec, since most of those
# behaviors are the same for instance_exec. See also module_eval/class_eval.

it "binds self to the receiver" do
s = "hola"
(s == s.instance_exec { self }).should == true
end

it "binds the block's binding self to the receiver" do
s = "hola"
(s == s.instance_exec { eval "self", binding }).should == true
end

it "executes in the context of the receiver" do
"Ruby-fu".instance_exec { size }.should == 7
Object.class_eval { "Ruby-fu".instance_exec{ to_s } }.should == "Ruby-fu"
end

it "has access to receiver's instance variables" do
BasicObjectSpecs::IVars.new.instance_exec { @secret }.should == 99
end

it "sets class variables in the receiver" do
BasicObjectSpecs::InstExec.class_variables.should include(:@@count)
BasicObjectSpecs::InstExec.send(:class_variable_get, :@@count).should == 2
end

it "raises a TypeError when defining methods on an immediate" do
lambda do
1.instance_exec { def foo; end }
end.should raise_error(TypeError)
lambda do
:foo.instance_exec { def foo; end }
end.should raise_error(TypeError)
end

quarantine! do # Not clean, leaves cvars lying around to break other specs
it "scopes class var accesses in the caller when called on a Fixnum" do
# Fixnum can take instance vars
Fixnum.class_eval "@@__tmp_instance_exec_spec = 1"
(defined? @@__tmp_instance_exec_spec).should == nil

@@__tmp_instance_exec_spec = 2
1.instance_exec { @@__tmp_instance_exec_spec }.should == 2
Fixnum.__send__(:remove_class_variable, :@@__tmp_instance_exec_spec)
end
end

it "raises a TypeError when defining methods on numerics" do
lambda do
(1.0).instance_exec { def foo; end }
end.should raise_error(TypeError)
lambda do
(1 << 64).instance_exec { def foo; end }
end.should raise_error(TypeError)
end
end
10 changes: 0 additions & 10 deletions spec/ruby/core/basicobject/new_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/core/basicobject/superclass_spec.rb

This file was deleted.

6 changes: 4 additions & 2 deletions spec/ruby/core/integer/round_spec.rb
Original file line number Diff line number Diff line change
@@ -28,8 +28,10 @@
(-25 * 10**70 + 1).round(-71).should eql(-20 * 10**70)
end

it "raises a RangeError when passed a big negative value" do
lambda { 42.round(fixnum_min()) }.should raise_error(RangeError)
platform_is_not :wordsize => 32 do
it "raises a RangeError when passed a big negative value" do
lambda { 42.round(fixnum_min()) }.should raise_error(RangeError)
end
end

it "raises a RangeError when passed Float::INFINITY" do
22 changes: 21 additions & 1 deletion spec/ruby/core/kernel/class_spec.rb
Original file line number Diff line number Diff line change
@@ -2,5 +2,25 @@
require File.expand_path('../fixtures/classes', __FILE__)

describe "Kernel#class" do
it "needs to be reviewed for spec completeness"
it "returns the class of the object" do
Object.new.class.should equal(Object)

1.class.should equal(Fixnum)
3.14.class.should equal(Float)
:hello.class.should equal(Symbol)
"hello".class.should equal(String)
[1, 2].class.should equal(Array)
{ 1 => 2 }.class.should equal(Hash)
end

it "returns Class for a class" do
BasicObject.class.should equal(Class)
String.class.should equal(Class)
end

it "returns the first non-singleton class" do
a = "hello"
def a.my_singleton_method; end
a.class.should equal(String)
end
end
Loading