Skip to content

Commit

Permalink
Showing 84 changed files with 451 additions and 1,288 deletions.
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
12 changes: 12 additions & 0 deletions spec/ruby/core/kernel/clone_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/dup_clone', __FILE__)

describe "Kernel#clone" do
it_behaves_like :kernel_dup_clone, :clone

before :each do
ScratchPad.clear
@obj = KernelSpecs::Duplicate.new 1, :a
@@ -13,6 +16,15 @@
ScratchPad.recorded.should == clone.object_id
end

it "copies frozen state from the original" do
o2 = @obj.clone
@obj.freeze
o3 = @obj.clone

o2.frozen?.should == false
o3.frozen?.should == true
end

it "copies instance variables" do
clone = @obj.clone
clone.one.should == 1
10 changes: 10 additions & 0 deletions spec/ruby/core/kernel/dup_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)
require File.expand_path('../shared/dup_clone', __FILE__)

describe "Kernel#dup" do
it_behaves_like :kernel_dup_clone, :dup

before :each do
ScratchPad.clear
@obj = KernelSpecs::Duplicate.new 1, :a
@@ -13,6 +16,13 @@
ScratchPad.recorded.should == dup.object_id
end

it "does not copy frozen state from the original" do
@obj.freeze
dup = @obj.dup

dup.frozen?.should == false
end

it "copies instance variables" do
dup = @obj.dup
dup.one.should == 1
53 changes: 21 additions & 32 deletions spec/ruby/core/kernel/fixtures/classes.rb
Original file line number Diff line number Diff line change
@@ -59,6 +59,27 @@ def self.encoded_chomp(file)
ruby_exe "puts", :args => "| #{RUBY_EXE} -n #{file}"
end

# kind_of?, is_a?, instance_of?
module SomeOtherModule; end
module AncestorModule; end
module MyModule; end
module MyExtensionModule; end

class AncestorClass < String
include AncestorModule
end

class InstanceClass < AncestorClass
include MyModule
end

class KindaClass < AncestorClass
include MyModule
def initialize
self.extend MyExtensionModule
end
end

class Method
public :abort, :exec, :exit, :exit!, :fork, :system
public :spawn if respond_to?(:spawn, true)
@@ -246,38 +267,6 @@ class << self
end
end

class IVars
def initialize
@secret = 99
end
end

module InstEvalCVar
instance_eval { @@count = 2 }
end

module InstEval
def self.included(base)
base.instance_eval { @@count = 2 }
end
end

class IncludesInstEval
include InstEval
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

class EvalTest
def self.eval_yield_with_binding
eval("yield", binding)
141 changes: 0 additions & 141 deletions spec/ruby/core/kernel/instance_eval_spec.rb

This file was deleted.

39 changes: 37 additions & 2 deletions spec/ruby/core/kernel/instance_of_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "Kernel#instance_of?" do
it "needs to be reviewed for spec completeness"
describe Kernel, "#instance_of?" do
before(:each) do
@o = KernelSpecs::InstanceClass.new
end

it "returns true if given class is object's class" do
@o.instance_of?(KernelSpecs::InstanceClass).should == true
[].instance_of?(Array).should == true
''.instance_of?(String).should == true
end

it "returns false if given class is object's ancestor class" do
@o.instance_of?(KernelSpecs::AncestorClass).should == false
end

it "returns false if given class is not object's class nor object's ancestor class" do
@o.instance_of?(Array).should == false
end

it "returns false if given a Module that is included in object's class" do
@o.instance_of?(KernelSpecs::MyModule).should == false
end

it "returns false if given a Module that is included one of object's ancestors only" do
@o.instance_of?(KernelSpecs::AncestorModule).should == false
end

it "returns false if given a Module that is not included in object's class" do
@o.instance_of?(KernelSpecs::SomeOtherModule).should == false
end

it "raises a TypeError if given an object that is not a Class nor a Module" do
lambda { @o.instance_of?(Object.new) }.should raise_error(TypeError)
lambda { @o.instance_of?('KernelSpecs::InstanceClass') }.should raise_error(TypeError)
lambda { @o.instance_of?(1) }.should raise_error(TypeError)
end
end
3 changes: 2 additions & 1 deletion spec/ruby/core/kernel/is_a_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/kind_of', __FILE__)

describe "Kernel#is_a?" do
it "needs to be reviewed for spec completeness"
it_behaves_like(:kernel_kind_of , :is_a?)
end
3 changes: 2 additions & 1 deletion spec/ruby/core/kernel/kind_of_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../shared/kind_of', __FILE__)

describe "Kernel#kind_of?" do
it "needs to be reviewed for spec completeness"
it_behaves_like(:kernel_kind_of , :kind_of?)
end
12 changes: 10 additions & 2 deletions spec/ruby/core/kernel/match_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "Kernel#=~" do
it "needs to be reviewed for spec completeness"
it "returns nil matching any object" do
o = Object.new

(o =~ /Object/).should be_nil
(o =~ 'Object').should be_nil
(o =~ Object).should be_nil
(o =~ Object.new).should be_nil
(o =~ nil).should be_nil
(o =~ true).should be_nil
end
end
6 changes: 6 additions & 0 deletions spec/ruby/core/kernel/object_id_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../../shared/kernel/object_id', __FILE__)

describe "Kernel#object_id" do
it_behaves_like :object_id, :object_id, Object
end
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ def initialize_copy(original)
private :initialize_copy
end

describe :object_dup_clone, :shared => true do
describe :kernel_dup_clone, :shared => true do
it "returns a new object duplicated from the original" do
o = ObjectSpecDup.new
o2 = ObjectSpecDup.new
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
module ObjectSpecs
module SomeOtherModule; end
module AncestorModule; end
module MyModule; end
module MyExtensionModule; end
require File.expand_path('../../fixtures/classes', __FILE__)

class AncestorClass < String
include AncestorModule
end

class KindaClass < AncestorClass
include MyModule
def initialize
self.extend MyExtensionModule
end
end
end

describe :object_kind_of, :shared => true do
describe :kernel_kind_of, :shared => true do
before(:each) do
@o = ObjectSpecs::KindaClass.new
@o = KernelSpecs::KindaClass.new
end

it "returns true if given class is the object's class" do
@o.send(@method, ObjectSpecs::KindaClass).should == true
@o.send(@method, KernelSpecs::KindaClass).should == true
end

it "returns true if given class is an ancestor of the object's class" do
@o.send(@method, ObjectSpecs::AncestorClass).should == true
@o.send(@method, KernelSpecs::AncestorClass).should == true
@o.send(@method, String).should == true
@o.send(@method, Object).should == true
end
@@ -36,19 +20,19 @@ def initialize
end

it "returns true if given a Module that is included in object's class" do
@o.send(@method, ObjectSpecs::MyModule).should == true
@o.send(@method, KernelSpecs::MyModule).should == true
end

it "returns true if given a Module that is included one of object's ancestors only" do
@o.send(@method, ObjectSpecs::AncestorModule).should == true
@o.send(@method, KernelSpecs::AncestorModule).should == true
end

it "returns true if given a Module that object has been extended with" do
@o.send(@method, ObjectSpecs::MyExtensionModule).should == true
@o.send(@method, KernelSpecs::MyExtensionModule).should == true
end

it "returns false if given a Module not included in object's class nor ancestors" do
@o.send(@method, ObjectSpecs::SomeOtherModule).should == false
@o.send(@method, KernelSpecs::SomeOtherModule).should == false
end

it "raises a TypeError if given an object that is not a Class nor a Module" do
5 changes: 5 additions & 0 deletions spec/ruby/core/method/to_proc_spec.rb
Original file line number Diff line number Diff line change
@@ -13,6 +13,11 @@
@meth.to_proc.kind_of?(Proc).should == true
end

it "returns a Proc which does not depends on the value of self" do
3.instance_exec(4, &5.method(:+)).should == 9
end


it "returns a Proc object with the correct arity" do
# This may seem redundant but this bug has cropped up in jruby, mri and yarv.
# http://jira.codehaus.org/browse/JRUBY-124
1 change: 1 addition & 0 deletions spec/ruby/core/module/ancestors_spec.rb
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@

describe "Module#ancestors" do
it "returns a list of modules included in self (including self)" do
BasicObject.ancestors.should == [BasicObject]
ModuleSpecs.ancestors.should include(ModuleSpecs)
ModuleSpecs::Basic.ancestors.should include(ModuleSpecs::Basic)
ModuleSpecs::Super.ancestors.should include(ModuleSpecs::Super, ModuleSpecs::Basic)
17 changes: 0 additions & 17 deletions spec/ruby/core/object/clone_spec.rb

This file was deleted.

14 changes: 0 additions & 14 deletions spec/ruby/core/object/dup_spec.rb

This file was deleted.

17 changes: 0 additions & 17 deletions spec/ruby/core/object/fixtures/classes.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/ruby/core/object/initialize_spec.rb

This file was deleted.

97 changes: 0 additions & 97 deletions spec/ruby/core/object/instance_exec_spec.rb

This file was deleted.

53 changes: 0 additions & 53 deletions spec/ruby/core/object/instance_of_spec.rb

This file was deleted.

6 changes: 0 additions & 6 deletions spec/ruby/core/object/is_a_spec.rb

This file was deleted.

6 changes: 0 additions & 6 deletions spec/ruby/core/object/kind_of_spec.rb

This file was deleted.

14 changes: 0 additions & 14 deletions spec/ruby/core/object/match_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/ruby/core/object/metaclass_spec.rb

This file was deleted.

13 changes: 0 additions & 13 deletions spec/ruby/core/object/new_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/ruby/core/object/object_id_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/ruby/core/time/getlocal_spec.rb
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
t = Time.new(2005, 2, 27, 22, 50, 0, -3600)
t.utc_offset.should == -3600

with_timezone("US/Eastern") do
with_timezone("America/New_York") do
t.getlocal.utc_offset.should == -18000
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/time/localtime_spec.rb
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@
t = Time.new(2005, 2, 27, 22, 50, 0, -3600)
t.utc_offset.should == -3600

with_timezone("US/Eastern") do
with_timezone("America/New_York") do
t.localtime
end

4 changes: 2 additions & 2 deletions spec/ruby/core/time/shared/local.rb
Original file line number Diff line number Diff line change
@@ -23,14 +23,14 @@
end

it "creates the correct time just before dst change" do
with_timezone("US/Eastern") do
with_timezone("America/New_York") do
time = Time.send(@method, 0, 30, 1, 30, 10, 2005, 0, 0, true, ENV['TZ'])
time.utc_offset.should == -4 * 3600
end
end

it "creates the correct time just after dst change" do
with_timezone("US/Eastern") do
with_timezone("America/New_York") do
time = Time.send(@method, 0, 30, 1, 30, 10, 2005, 0, 0, false, ENV['TZ'])
time.utc_offset.should == -5 * 3600
end
8 changes: 4 additions & 4 deletions spec/ruby/core/time/zone_spec.rb
Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@
it "returns the correct timezone for a local time" do
t = Time.new(2005, 2, 27, 22, 50, 0, -3600)

with_timezone("US/Eastern") do
with_timezone("America/New_York") do
t.getlocal.zone.should == "EST"
end
end

it "returns nil when getting the local time with a fixed offset" do
t = Time.new(2005, 2, 27, 22, 50, 0, -3600)

with_timezone("US/Eastern") do
with_timezone("America/New_York") do
t.getlocal("+05:00").zone.should be_nil
end
end
@@ -42,7 +42,7 @@
it "returns the string with the default internal encoding" do
t = Time.new(2005, 2, 27, 22, 50, 0, -3600)

with_timezone("US/Eastern") do
with_timezone("America/New_York") do
t.getlocal.zone.encoding.should == Encoding::UTF_8
end
end
@@ -53,7 +53,7 @@
it "returns an ASCII string" do
t = Time.new(2005, 2, 27, 22, 50, 0, -3600)

with_timezone("US/Eastern") do
with_timezone("America/New_York") do
t.getlocal.zone.encoding.should == Encoding::US_ASCII
end
end
41 changes: 4 additions & 37 deletions spec/ruby/default.mspec
Original file line number Diff line number Diff line change
@@ -5,54 +5,21 @@ class MSpecScript
set :language, [ 'language' ]

# Core library specs
set :core, [
'core',
]
set :core, [ 'core' ]

# Standard library specs
set :library, [
'library',

# obsolete libraries
'^library/cgi-lib',
'^library/date2',
'^library/enumerator',
'^library/eregex',
'^library/finalize',
'^library/ftools',
'^library/generator',
'^library/getopts',
'^library/importenv',
'^library/jcode',
'^library/mailread',
'^library/parsearg',
'^library/parsedate',
'^library/ping',
'^library/readbytes',
'^library/rubyunit',
'^library/runit',
'^library/soap',
'^library/wsdl',
'^library/xsd',
'^library/Win32API',

'^library/test/unit/collector',
'^library/test/unit/ui',
'^library/test/unit/util',

'^library/dl', # reimplemented and API changed
]
set :library, [ 'library' ]

# An ordered list of the directories containing specs to run
set :files, get(:language) + get(:core) + get(:library)

# This set of files is run by mspec ci
set :ci_files, get(:files)

# Optional library specs
# Optional specs
set :capi, 'optional/capi'

# A list of _all_ optional library specs
# A list of _all_ optional specs
set :optional, [get(:capi)]

# The default implementation to run the specs.
2 changes: 1 addition & 1 deletion spec/ruby/language/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -366,7 +366,7 @@ module ConstantSpecs
ConstantSpecs::CS_SINGLETON1.foo.should == 1
end

ruby_bug "#10943", "2.3" do
ruby_version_is "2.3" do
it "uses its own namespace for each object" do
a = ConstantSpecs::CS_SINGLETON2[0].foo
b = ConstantSpecs::CS_SINGLETON2[1].foo
7 changes: 0 additions & 7 deletions spec/ruby/library/enumerator/each_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/ruby/library/enumerator/each_with_index_spec.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/ruby/library/enumerator/enum_cons_spec.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/ruby/library/enumerator/enum_for_spec.rb

This file was deleted.

16 changes: 0 additions & 16 deletions spec/ruby/library/enumerator/enum_slice_spec.rb

This file was deleted.

16 changes: 0 additions & 16 deletions spec/ruby/library/enumerator/enum_with_index_spec.rb

This file was deleted.

14 changes: 0 additions & 14 deletions spec/ruby/library/enumerator/new_spec.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/ruby/library/enumerator/next_spec.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/ruby/library/enumerator/rewind_spec.rb

This file was deleted.

10 changes: 0 additions & 10 deletions spec/ruby/library/enumerator/to_enum_spec.rb

This file was deleted.

9 changes: 0 additions & 9 deletions spec/ruby/library/enumerator/with_index_spec.rb

This file was deleted.

20 changes: 0 additions & 20 deletions spec/ruby/library/ftools/catname_spec.rb

This file was deleted.

30 changes: 0 additions & 30 deletions spec/ruby/library/ftools/chmod_spec.rb

This file was deleted.

31 changes: 0 additions & 31 deletions spec/ruby/library/ftools/compare_spec.rb

This file was deleted.

35 changes: 0 additions & 35 deletions spec/ruby/library/ftools/copy_spec.rb

This file was deleted.

26 changes: 0 additions & 26 deletions spec/ruby/library/ftools/install_spec.rb

This file was deleted.

25 changes: 0 additions & 25 deletions spec/ruby/library/ftools/makedirs_spec.rb

This file was deleted.

34 changes: 0 additions & 34 deletions spec/ruby/library/ftools/move_spec.rb

This file was deleted.

27 changes: 0 additions & 27 deletions spec/ruby/library/ftools/safe_unlink_spec.rb

This file was deleted.

35 changes: 0 additions & 35 deletions spec/ruby/library/ftools/syscopy_spec.rb

This file was deleted.

33 changes: 0 additions & 33 deletions spec/ruby/library/generator/each_spec.rb

This file was deleted.

21 changes: 0 additions & 21 deletions spec/ruby/library/generator/fixtures/common.rb

This file was deleted.

26 changes: 0 additions & 26 deletions spec/ruby/library/generator/new_spec.rb

This file was deleted.

79 changes: 0 additions & 79 deletions spec/ruby/library/generator/next_spec.rb

This file was deleted.

34 changes: 0 additions & 34 deletions spec/ruby/library/generator/rewind_spec.rb

This file was deleted.

107 changes: 0 additions & 107 deletions spec/ruby/library/parsedate/parsedate_spec.rb

This file was deleted.

29 changes: 0 additions & 29 deletions spec/ruby/library/ping/pingecho_spec.rb

This file was deleted.

10 changes: 6 additions & 4 deletions spec/ruby/optional/capi/numeric_spec.rb
Original file line number Diff line number Diff line change
@@ -164,10 +164,12 @@
@s.rb_int2num(5).should == 5
end

# INT2NUM used to use `long` prior to MRI 1.9. With 1.9 it has been changed
# to use `int` instead.
it "converts 0xFFFFFFFF to -1" do
@s.rb_int2num(0xFFFFFFFF).should == -1
platform_is_not :wordsize => 32 do
# INT2NUM used to use `long` prior to MRI 1.9. With 1.9 it has been changed
# to use `int` instead.
it "converts 0xFFFFFFFF to -1" do
@s.rb_int2num(0xFFFFFFFF).should == -1
end
end
end

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# These examples hold for both BasicObject#__id__ and Object#object_id.
describe :basic_object_id, :shared => true do
# These examples hold for both BasicObject#__id__ and Kernel#object_id.
describe :object_id, :shared => true do
it "returns an integer" do
o1 = @object.new
o1.__send__(@method).should be_kind_of(Integer)
@@ -15,10 +15,7 @@
o2 = @object.new
o1.__send__(@method).should_not == o2.__send__(@method)
end
end

# These examples hold for Object#object_id, or for specific subclasses.
describe :object_id, :shared => true do
it "returns the same value for two Fixnums with the same value" do
o1 = 1
o2 = 1
2 changes: 1 addition & 1 deletion spec/ruby/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
end

dir = "../fixtures/code"
CODE_LOADING_DIR = defined?(:require_relative) ?
CODE_LOADING_DIR = defined?(require_relative) ?
File.realpath(dir, __FILE__) :
File.expand_path(dir, __FILE__)

1 change: 1 addition & 0 deletions spec/truffle/tags/core/basicobject/__id__tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:BasicObject#__id__ returns a different value for two Float literals
1 change: 1 addition & 0 deletions spec/truffle/tags/core/basicobject/instance_eval_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:BasicObject#instance_eval gets constants in the receiver if a string given
2 changes: 2 additions & 0 deletions spec/truffle/tags/core/basicobject/instance_exec_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:BasicObject#instance_exec raises a TypeError when defining methods on an immediate
fails:BasicObject#instance_exec raises a TypeError when defining methods on numerics
3 changes: 3 additions & 0 deletions spec/truffle/tags/core/kernel/instance_of_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Kernel#instance_of? returns false if given a Module that is included in object's class
fails:Kernel#instance_of? returns false if given a Module that is included one of object's ancestors only
fails:Kernel#instance_of? returns false if given a Module that is not included in object's class
1 change: 1 addition & 0 deletions spec/truffle/tags/core/kernel/object_id_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Kernel#object_id returns a different value for two Float literals
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/object/instance_exec_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/object/instance_of_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/object/object_id_tags.txt

This file was deleted.

7 changes: 0 additions & 7 deletions spec/truffle/tags/core/random/rand_tags.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
fails:Random.rand returns a Float if no max argument is passed
fails:Random.rand returns a Float >= 0 if no max argument is passed
fails:Random.rand returns a Float < 1 if no max argument is passed
fails:Random.rand returns the same sequence for a given seed if no max argument is passed
fails:Random.rand returns an Integer if an Integer argument is passed
fails:Random.rand returns an Integer >= 0 if an Integer argument is passed
fails:Random.rand returns an Integer < the max argument if an Integer argument is passed
fails:Random.rand returns the same sequence for a given seed if an Integer argument is passed
fails:Random.rand coerces arguments to Integers with #to_int
fails:Random#rand with Fixnum eventually returns all possible values
fails:Random#rand with Bignum typically returns a Bignum
fails:Random#rand with Bignum returns the same sequence for a given seed
Original file line number Diff line number Diff line change
@@ -17,13 +17,14 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.source.SourceSection;

import com.oracle.truffle.api.utilities.ConditionProfile;

import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyCallNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.cast.BooleanCastNodeFactory;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.nodes.methods.UnsupportedOperationBehavior;
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.ObjectIDOperations;
import org.jruby.truffle.runtime.RubyContext;
@@ -191,7 +192,7 @@ public RubyNilClass initialize() {

}

@CoreMethod(names = "instance_eval", needsBlock = true, optional = 1)
@CoreMethod(names = "instance_eval", needsBlock = true, optional = 1, unsupportedOperationBehavior = UnsupportedOperationBehavior.ARGUMENT_ERROR)
public abstract static class InstanceEvalNode extends CoreMethodNode {

@Child private YieldDispatchHeadNode yield;
@@ -217,16 +218,14 @@ public Object instanceEval(VirtualFrame frame, Object receiver, RubyString strin
public Object instanceEval(VirtualFrame frame, Object receiver, UndefinedPlaceholder string, RubyProc block) {
notDesignedForCompilation();

return yield.dispatchWithModifiedSelf(frame, block, receiver);
return yield.dispatchWithModifiedSelf(frame, block, receiver, receiver);
}

}

@CoreMethod(names = "instance_exec", needsBlock = true, argumentsAsArray = true)
public abstract static class InstanceExecNode extends YieldingCoreMethodNode {

private final ConditionProfile rubyMethodProfile = ConditionProfile.createBinaryProfile();

public InstanceExecNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -239,10 +238,6 @@ public InstanceExecNode(InstanceExecNode prev) {
public Object instanceExec(VirtualFrame frame, Object receiver, Object[] arguments, RubyProc block) {
notDesignedForCompilation();

if (rubyMethodProfile.profile(block.getSelfCapturedInScope() instanceof RubyMethod)) {
return yield(frame, block, arguments);
}

return yieldWithModifiedSelf(frame, block, receiver, arguments);
}

Original file line number Diff line number Diff line change
@@ -20,6 +20,8 @@

import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.objects.SingletonClassNode;
import org.jruby.truffle.nodes.objects.SingletonClassNodeFactory;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.TruffleFatalException;
@@ -32,11 +34,13 @@ public class AddMethodNode extends RubyNode {

@Child private RubyNode receiver;
@Child private MethodDefinitionNode methodNode;
@Child private SingletonClassNode singletonClassNode;

public AddMethodNode(RubyContext context, SourceSection section, RubyNode receiver, MethodDefinitionNode method) {
super(context, section);
this.receiver = receiver;
this.methodNode = method;
singletonClassNode = SingletonClassNodeFactory.create(context, section, null);
}

@Override
@@ -52,7 +56,7 @@ public RubySymbol execute(VirtualFrame frame) {
if (receiverObject instanceof RubyModule) {
module = (RubyModule) receiverObject;
} else {
module = ((RubyBasicObject) receiverObject).getSingletonClass(this);
module = singletonClassNode.executeSingletonClass(frame, receiverObject);
}

final Visibility visibility = getVisibility(frame, methodObject.getName());
3 changes: 2 additions & 1 deletion truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -145,8 +145,9 @@ def _offset_to_milliseconds
class Method

def to_proc
meth = self
proc { |*args|
self.call(*args)
meth.call(*args)
}
end

0 comments on commit 334ef87

Please sign in to comment.