1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Test Thread#to_s when used from to_s_spec.rb

This commit is contained in:
Nobuyoshi Nakada 2019-12-11 16:41:37 +09:00
parent d2d42081ce
commit 3098798044
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 12 additions and 11 deletions

View file

@ -7,11 +7,12 @@ module ThreadSpecs
end
class Status
attr_reader :thread, :inspect, :status
attr_reader :thread, :inspect, :status, :to_s
def initialize(thread)
@thread = thread
@alive = thread.alive?
@inspect = thread.inspect
@to_s = thread.to_s
@status = thread.status
@stop = thread.stop?
end

View file

@ -12,42 +12,42 @@ describe :thread_to_s, shared: true do
end
it "can check it's own status" do
ThreadSpecs.status_of_current_thread.inspect.should include('run')
ThreadSpecs.status_of_current_thread.send(@method).should include('run')
end
it "describes a running thread" do
ThreadSpecs.status_of_running_thread.inspect.should include('run')
ThreadSpecs.status_of_running_thread.send(@method).should include('run')
end
it "describes a sleeping thread" do
ThreadSpecs.status_of_sleeping_thread.inspect.should include('sleep')
ThreadSpecs.status_of_sleeping_thread.send(@method).should include('sleep')
end
it "describes a blocked thread" do
ThreadSpecs.status_of_blocked_thread.inspect.should include('sleep')
ThreadSpecs.status_of_blocked_thread.send(@method).should include('sleep')
end
it "describes a completed thread" do
ThreadSpecs.status_of_completed_thread.inspect.should include('dead')
ThreadSpecs.status_of_completed_thread.send(@method).should include('dead')
end
it "describes a killed thread" do
ThreadSpecs.status_of_killed_thread.inspect.should include('dead')
ThreadSpecs.status_of_killed_thread.send(@method).should include('dead')
end
it "describes a thread with an uncaught exception" do
ThreadSpecs.status_of_thread_with_uncaught_exception.inspect.should include('dead')
ThreadSpecs.status_of_thread_with_uncaught_exception.send(@method).should include('dead')
end
it "describes a dying sleeping thread" do
ThreadSpecs.status_of_dying_sleeping_thread.inspect.should include('sleep')
ThreadSpecs.status_of_dying_sleeping_thread.send(@method).should include('sleep')
end
it "reports aborting on a killed thread" do
ThreadSpecs.status_of_dying_running_thread.inspect.should include('aborting')
ThreadSpecs.status_of_dying_running_thread.send(@method).should include('aborting')
end
it "reports aborting on a killed thread after sleep" do
ThreadSpecs.status_of_dying_thread_after_sleep.inspect.should include('aborting')
ThreadSpecs.status_of_dying_thread_after_sleep.send(@method).should include('aborting')
end
end