From 1dcc0348541370c15f7173dd17234e17968e1731 Mon Sep 17 00:00:00 2001 From: Petr Chalupa Date: Wed, 21 Feb 2018 16:47:15 +0100 Subject: [PATCH] Fix to_s methods --- lib/concurrent/atomic/atomic_boolean.rb | 2 +- lib/concurrent/atomic/atomic_fixnum.rb | 2 +- lib/concurrent/atomic/atomic_reference.rb | 2 +- lib/concurrent/edge/cancellation.rb | 4 ++-- lib/concurrent/edge/lock_free_stack.rb | 2 +- lib/concurrent/edge/promises.rb | 4 ++-- lib/concurrent/edge/throttle.rb | 2 +- spec/concurrent/edge/promises_spec.rb | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/concurrent/atomic/atomic_boolean.rb b/lib/concurrent/atomic/atomic_boolean.rb index fc7697671..6d9b344c1 100644 --- a/lib/concurrent/atomic/atomic_boolean.rb +++ b/lib/concurrent/atomic/atomic_boolean.rb @@ -114,7 +114,7 @@ module Concurrent class AtomicBoolean < AtomicBooleanImplementation # @return [String] Short string representation. def to_s - format '<#%s:0x%x value:%s>', self.class, object_id << 1, value + format '%s value:%s>', super[0..-2], value end alias_method :inspect, :to_s diff --git a/lib/concurrent/atomic/atomic_fixnum.rb b/lib/concurrent/atomic/atomic_fixnum.rb index ddadf18dd..d1e4b0080 100644 --- a/lib/concurrent/atomic/atomic_fixnum.rb +++ b/lib/concurrent/atomic/atomic_fixnum.rb @@ -131,7 +131,7 @@ module Concurrent class AtomicFixnum < AtomicFixnumImplementation # @return [String] Short string representation. def to_s - format '<#%s:0x%x value:%s>', self.class, object_id << 1, value + format '%s value:%s>', super[0..-2], value end alias_method :inspect, :to_s diff --git a/lib/concurrent/atomic/atomic_reference.rb b/lib/concurrent/atomic/atomic_reference.rb index 12a91c01a..3b57e8572 100644 --- a/lib/concurrent/atomic/atomic_reference.rb +++ b/lib/concurrent/atomic/atomic_reference.rb @@ -44,7 +44,7 @@ class Concurrent::AtomicReference < Concurrent::MutexAtomicReference class Concurrent::AtomicReference # @return [String] Short string representation. def to_s - format '<#%s:0x%x value:%s>', self.class, object_id << 1, get + format '%s value:%s>', super[0..-2], get end alias_method :inspect, :to_s diff --git a/lib/concurrent/edge/cancellation.rb b/lib/concurrent/edge/cancellation.rb index 09e99a9a0..8c56b90a2 100644 --- a/lib/concurrent/edge/cancellation.rb +++ b/lib/concurrent/edge/cancellation.rb @@ -54,7 +54,7 @@ def canceled? # Short string representation. # @return [String] def to_s - format '<#%s:0x%x canceled:%s>', self.class, object_id << 1, canceled? + format '%s canceled:%s>', super[0..-2], canceled? end alias_method :inspect, :to_s @@ -120,7 +120,7 @@ def join(*tokens, &block) # Short string representation. # @return [String] def to_s - format '<#%s:0x%x canceled:%s>', self.class, object_id << 1, canceled? + format '%s canceled:%s>', super[0..-2], canceled? end alias_method :inspect, :to_s diff --git a/lib/concurrent/edge/lock_free_stack.rb b/lib/concurrent/edge/lock_free_stack.rb index 37ff8a8b4..8e07d987d 100644 --- a/lib/concurrent/edge/lock_free_stack.rb +++ b/lib/concurrent/edge/lock_free_stack.rb @@ -118,7 +118,7 @@ def clear_each(&block) # @return [String] Short string representation. def to_s - format '<#%s:0x%x %s>', self.class, object_id << 1, to_a.to_s + format '%s %s>', super[0..-2], to_a.to_s end alias_method :inspect, :to_s diff --git a/lib/concurrent/edge/promises.rb b/lib/concurrent/edge/promises.rb index a5643237d..bf3f73ca7 100644 --- a/lib/concurrent/edge/promises.rb +++ b/lib/concurrent/edge/promises.rb @@ -626,7 +626,7 @@ def chain_on(executor, *args, &task) # @return [String] Short string representation. def to_s - format '<#%s:0x%x %s>', self.class, object_id << 1, state + format '%s %s>', super[0..-2], state end alias_method :inspect, :to_s @@ -2067,7 +2067,7 @@ def pop_for_select(probe = Concurrent::Promises.resolvable_future) # @return [String] Short string representation. def to_s - format '<#%s:0x%x size:%s>', self.class, object_id << 1, @Size + format '%s size:%s>', super[0..-2], @Size end alias_method :inspect, :to_s diff --git a/lib/concurrent/edge/throttle.rb b/lib/concurrent/edge/throttle.rb index 9b58b4aa5..8ba489a97 100644 --- a/lib/concurrent/edge/throttle.rb +++ b/lib/concurrent/edge/throttle.rb @@ -117,7 +117,7 @@ def throttled_block(&block) # @return [String] Short string representation. def to_s - format '<#%s:0x%x limit:%s can_run:%d>', self.class, object_id << 1, @Limit, can_run + format '%s limit:%s can_run:%d>', super[0..-2], @Limit, can_run end alias_method :inspect, :to_s diff --git a/spec/concurrent/edge/promises_spec.rb b/spec/concurrent/edge/promises_spec.rb index 1f3e81411..e575dfb59 100644 --- a/spec/concurrent/edge/promises_spec.rb +++ b/spec/concurrent/edge/promises_spec.rb @@ -383,9 +383,9 @@ def behaves_as_delay(delay, value) four = three.delay.then(&:succ) # meaningful to_s and inspect defined for Future and Promise - expect(head.to_s).to match(/<#Concurrent::Promises::Future:0x[\da-f]+ pending>/) + expect(head.to_s).to match(/#/) expect(head.inspect).to( - match(/<#Concurrent::Promises::Future:0x[\da-f]+ pending>/)) + match(/#/)) # evaluates only up to three, four is left unevaluated expect(three.value!).to eq 3