aboutsummaryrefslogtreecommitdiffstats
path: root/spec/rubyspec/core
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/core')
-rw-r--r--spec/rubyspec/core/kernel/exit_spec.rb2
-rw-r--r--spec/rubyspec/core/module/prepend_spec.rb16
-rw-r--r--spec/rubyspec/core/random/default_spec.rb7
-rw-r--r--spec/rubyspec/core/rational/to_r_spec.rb10
-rw-r--r--spec/rubyspec/core/struct/inspect_spec.rb9
-rw-r--r--spec/rubyspec/core/thread/status_spec.rb16
-rw-r--r--spec/rubyspec/core/thread/terminate_spec.rb4
-rw-r--r--spec/rubyspec/core/time/shared/time_params.rb5
8 files changed, 58 insertions, 11 deletions
diff --git a/spec/rubyspec/core/kernel/exit_spec.rb b/spec/rubyspec/core/kernel/exit_spec.rb
index 5e175d5036..61a6670cfd 100644
--- a/spec/rubyspec/core/kernel/exit_spec.rb
+++ b/spec/rubyspec/core/kernel/exit_spec.rb
@@ -15,7 +15,7 @@ describe "Kernel#exit!" do
Kernel.should have_private_instance_method(:exit!)
end
- it_behaves_like :process_exit!, :exit!, KernelSpecs::Method.new
+ it_behaves_like :process_exit!, :exit!, "self"
end
describe "Kernel.exit" do
diff --git a/spec/rubyspec/core/module/prepend_spec.rb b/spec/rubyspec/core/module/prepend_spec.rb
index 7d162bd5c5..c0cce616a2 100644
--- a/spec/rubyspec/core/module/prepend_spec.rb
+++ b/spec/rubyspec/core/module/prepend_spec.rb
@@ -342,4 +342,20 @@ describe "Module#prepend" do
child_class.new.foo(ary)
ary.should == [3, 2, 1]
end
+
+ describe "called on a module" do
+ describe "included into a class"
+ it "does not obscure the module's methods from reflective access" do
+ mod = Module.new do
+ def foo; end
+ end
+ cls = Class.new do
+ include mod
+ end
+ pre = Module.new
+ mod.prepend pre
+
+ cls.instance_methods.should include(:foo)
+ end
+ end
end
diff --git a/spec/rubyspec/core/random/default_spec.rb b/spec/rubyspec/core/random/default_spec.rb
new file mode 100644
index 0000000000..51a76c01ce
--- /dev/null
+++ b/spec/rubyspec/core/random/default_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+
+describe "Random::DEFAULT" do
+ it "returns a Random instance" do
+ Random::DEFAULT.should be_an_instance_of(Random)
+ end
+end
diff --git a/spec/rubyspec/core/rational/to_r_spec.rb b/spec/rubyspec/core/rational/to_r_spec.rb
index 22c8b4532c..6e44cf1b23 100644
--- a/spec/rubyspec/core/rational/to_r_spec.rb
+++ b/spec/rubyspec/core/rational/to_r_spec.rb
@@ -7,4 +7,14 @@ describe "Rational#to_r" do
obj = BasicObject.new
lambda { Rational(obj) }.should raise_error(TypeError)
end
+
+ it "works when a BasicObject has to_r" do
+ obj = BasicObject.new; def obj.to_r; 1 / 2.to_r end
+ Rational(obj).should == Rational('1/2')
+ end
+
+ it "fails when a BasicObject's to_r does not return a Rational" do
+ obj = BasicObject.new; def obj.to_r; 1 end
+ lambda { Rational(obj) }.should raise_error(TypeError)
+ end
end
diff --git a/spec/rubyspec/core/struct/inspect_spec.rb b/spec/rubyspec/core/struct/inspect_spec.rb
index a85466e1a2..94fb71a5f1 100644
--- a/spec/rubyspec/core/struct/inspect_spec.rb
+++ b/spec/rubyspec/core/struct/inspect_spec.rb
@@ -6,12 +6,9 @@ describe "Struct#inspect" do
it "returns a string representation of some kind" do
car = StructClasses::Car.new('Ford', 'Ranger')
car.inspect.should == '#<struct StructClasses::Car make="Ford", model="Ranger", year=nil>'
- # ujihisa reported in http://rubyspec.org/issues/show/130 that the
- # following example failed under mspec. Prefixing 'Whiskey' with a double
- # colon causes it to work. Given that this is an mspec bug, as opposed to
- # a problem with a spec, I've used the workaround below.
- ::Whiskey = Struct.new(:name, :ounces)
- ::Whiskey.new('Jack', 100).inspect.should == '#<struct Whiskey name="Jack", ounces=100>'
+
+ Whiskey = Struct.new(:name, :ounces)
+ Whiskey.new('Jack', 100).inspect.should == '#<struct Whiskey name="Jack", ounces=100>'
end
it_behaves_like(:struct_inspect, :inspect)
diff --git a/spec/rubyspec/core/thread/status_spec.rb b/spec/rubyspec/core/thread/status_spec.rb
index 3fbc4f888a..6cfdf0be40 100644
--- a/spec/rubyspec/core/thread/status_spec.rb
+++ b/spec/rubyspec/core/thread/status_spec.rb
@@ -41,4 +41,20 @@ describe "Thread#status" do
it "reports aborting on a killed thread after sleep" do
ThreadSpecs.status_of_dying_thread_after_sleep.status.should == 'aborting'
end
+
+ it "reports aborting on an externally killed thread that sleeps" do
+ q = Queue.new
+ t = Thread.new do
+ begin
+ q.push nil
+ sleep
+ ensure
+ q.push Thread.current.status
+ end
+ end
+ q.pop
+ t.kill
+ t.join
+ q.pop.should == 'aborting'
+ end
end
diff --git a/spec/rubyspec/core/thread/terminate_spec.rb b/spec/rubyspec/core/thread/terminate_spec.rb
index 9ac4a5b6f8..bb89d87762 100644
--- a/spec/rubyspec/core/thread/terminate_spec.rb
+++ b/spec/rubyspec/core/thread/terminate_spec.rb
@@ -5,7 +5,3 @@ require File.expand_path('../shared/exit', __FILE__)
describe "Thread#terminate" do
it_behaves_like :thread_exit, :terminate
end
-
-describe "Thread#terminate!" do
- it "needs to be reviewed for spec completeness"
-end
diff --git a/spec/rubyspec/core/time/shared/time_params.rb b/spec/rubyspec/core/time/shared/time_params.rb
index b60699dfb3..87b52d9f8d 100644
--- a/spec/rubyspec/core/time/shared/time_params.rb
+++ b/spec/rubyspec/core/time/shared/time_params.rb
@@ -24,6 +24,11 @@ describe :time_params, shared: true do
Time.send(@method, 2000, 2, 3, 4, 5, 0)
end
+ it "accepts a too big day of the month by going to the next month" do
+ Time.send(@method, 1999, 2, 31).should ==
+ Time.send(@method, 1999, 3, 3)
+ end
+
it "raises a TypeError if the year is nil" do
lambda { Time.send(@method, nil) }.should raise_error(TypeError)
end