Skip to content

Commit da5c4a9

Browse files
authored
Merge pull request #699 from ruby-concurrency/pitr-ch/to_s
Fix to_s methods
2 parents 1fb510b + 1dcc034 commit da5c4a9

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

lib/concurrent/atomic/atomic_boolean.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module Concurrent
114114
class AtomicBoolean < AtomicBooleanImplementation
115115
# @return [String] Short string representation.
116116
def to_s
117-
format '<#%s:0x%x value:%s>', self.class, object_id << 1, value
117+
format '%s value:%s>', super[0..-2], value
118118
end
119119

120120
alias_method :inspect, :to_s

lib/concurrent/atomic/atomic_fixnum.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ module Concurrent
131131
class AtomicFixnum < AtomicFixnumImplementation
132132
# @return [String] Short string representation.
133133
def to_s
134-
format '<#%s:0x%x value:%s>', self.class, object_id << 1, value
134+
format '%s value:%s>', super[0..-2], value
135135
end
136136

137137
alias_method :inspect, :to_s

lib/concurrent/atomic/atomic_reference.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Concurrent::AtomicReference < Concurrent::MutexAtomicReference
4444
class Concurrent::AtomicReference
4545
# @return [String] Short string representation.
4646
def to_s
47-
format '<#%s:0x%x value:%s>', self.class, object_id << 1, get
47+
format '%s value:%s>', super[0..-2], get
4848
end
4949

5050
alias_method :inspect, :to_s

lib/concurrent/edge/cancellation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def canceled?
5454
# Short string representation.
5555
# @return [String]
5656
def to_s
57-
format '<#%s:0x%x canceled:%s>', self.class, object_id << 1, canceled?
57+
format '%s canceled:%s>', super[0..-2], canceled?
5858
end
5959

6060
alias_method :inspect, :to_s
@@ -120,7 +120,7 @@ def join(*tokens, &block)
120120
# Short string representation.
121121
# @return [String]
122122
def to_s
123-
format '<#%s:0x%x canceled:%s>', self.class, object_id << 1, canceled?
123+
format '%s canceled:%s>', super[0..-2], canceled?
124124
end
125125

126126
alias_method :inspect, :to_s

lib/concurrent/edge/lock_free_stack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def clear_each(&block)
118118

119119
# @return [String] Short string representation.
120120
def to_s
121-
format '<#%s:0x%x %s>', self.class, object_id << 1, to_a.to_s
121+
format '%s %s>', super[0..-2], to_a.to_s
122122
end
123123

124124
alias_method :inspect, :to_s

lib/concurrent/edge/promises.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ def chain_on(executor, *args, &task)
626626

627627
# @return [String] Short string representation.
628628
def to_s
629-
format '<#%s:0x%x %s>', self.class, object_id << 1, state
629+
format '%s %s>', super[0..-2], state
630630
end
631631

632632
alias_method :inspect, :to_s
@@ -2067,7 +2067,7 @@ def pop_for_select(probe = Concurrent::Promises.resolvable_future)
20672067

20682068
# @return [String] Short string representation.
20692069
def to_s
2070-
format '<#%s:0x%x size:%s>', self.class, object_id << 1, @Size
2070+
format '%s size:%s>', super[0..-2], @Size
20712071
end
20722072

20732073
alias_method :inspect, :to_s

lib/concurrent/edge/throttle.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def throttled_block(&block)
117117

118118
# @return [String] Short string representation.
119119
def to_s
120-
format '<#%s:0x%x limit:%s can_run:%d>', self.class, object_id << 1, @Limit, can_run
120+
format '%s limit:%s can_run:%d>', super[0..-2], @Limit, can_run
121121
end
122122

123123
alias_method :inspect, :to_s

spec/concurrent/edge/promises_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,9 @@ def behaves_as_delay(delay, value)
383383
four = three.delay.then(&:succ)
384384

385385
# meaningful to_s and inspect defined for Future and Promise
386-
expect(head.to_s).to match(/<#Concurrent::Promises::Future:0x[\da-f]+ pending>/)
386+
expect(head.to_s).to match(/#<Concurrent::Promises::Future:0x[\da-f]+ pending>/)
387387
expect(head.inspect).to(
388-
match(/<#Concurrent::Promises::Future:0x[\da-f]+ pending>/))
388+
match(/#<Concurrent::Promises::Future:0x[\da-f]+ pending>/))
389389

390390
# evaluates only up to three, four is left unevaluated
391391
expect(three.value!).to eq 3

0 commit comments

Comments
 (0)