Skip to content

Commit

Permalink
Fix to_s methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pitr-ch committed Feb 21, 2018
1 parent 3265766 commit 1dcc034
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/concurrent/atomic/atomic_boolean.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/atomic/atomic_fixnum.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/atomic/atomic_reference.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/concurrent/edge/cancellation.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/edge/lock_free_stack.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/concurrent/edge/promises.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/concurrent/edge/throttle.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/concurrent/edge/promises_spec.rb
Expand Up @@ -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(/#<Concurrent::Promises::Future:0x[\da-f]+ pending>/)
expect(head.inspect).to(
match(/<#Concurrent::Promises::Future:0x[\da-f]+ pending>/))
match(/#<Concurrent::Promises::Future:0x[\da-f]+ pending>/))

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

0 comments on commit 1dcc034

Please sign in to comment.