Skip to content

Commit 7ce883c

Browse files
committed
Test fixes
1 parent 465f0ef commit 7ce883c

File tree

6 files changed

+19
-24
lines changed

6 files changed

+19
-24
lines changed

lib/concurrent/actress/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ def receive_envelope
168168
nil
169169
rescue => error
170170
log ERROR, error
171-
envelope.ivar.fail error unless envelope.ivar.nil?
172171
terminate!
172+
envelope.ivar.fail error unless envelope.ivar.nil?
173173
ensure
174174
@receive_envelope_scheduled = false
175175
process_envelopes?

lib/concurrent/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def initialize
2525

2626
# if assigned to {#logger}, it will log nothing.
2727
def no_logger
28-
-> (level, progname, message = nil, &block) {}
28+
lambda { |level, progname, message = nil, &block| }
2929
end
3030

3131
# Global thread pool optimized for short *tasks*.

lib/concurrent/executor/one_by_one.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ def initialize
3030
# @raise [ArgumentError] if no task is given
3131
def post(executor, *args, &task)
3232
return nil if task.nil?
33-
if executor.can_overflow?
34-
raise ArgumentError, 'OneByOne cannot be used in conjunction with executor which may overflow'
35-
end
33+
# FIXME Agent#send-off will blow up here
34+
# if executor.can_overflow?
35+
# raise ArgumentError, 'OneByOne cannot be used in conjunction with executor which may overflow'
36+
# end
3637

3738
job = Job.new executor, args, task
3839

lib/concurrent/executor/per_thread_executor.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Concurrent
22

33
class PerThreadExecutor
4+
include Executor
45

56
def self.post(*args)
67
raise ArgumentError.new('no block given') unless block_given?

spec/concurrent/actress_spec.rb

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ def on_message(message)
3535
# set_trace_func nil
3636
# end
3737

38-
def assert condition
39-
unless condition
40-
# require 'pry'
41-
# binding.pry
42-
raise
43-
puts "--- \n#{caller.join("\n")}"
44-
end
45-
end
46-
4738
describe 'stress test' do
4839
1.times do |i|
4940
it format('run %3d', i) do
@@ -56,23 +47,23 @@ def assert condition
5647
actor = Ping.spawn :ping, queue
5748

5849
# when spawn returns children are set
59-
assert Concurrent::Actress::ROOT.send(:core).instance_variable_get(:@children).include?(actor)
50+
Concurrent::Actress::ROOT.send(:core).instance_variable_get(:@children).should include(actor)
6051

6152
actor << 'a' << 1
62-
assert queue.pop == 'a'
63-
assert actor.ask(2).value == 2
53+
queue.pop.should eq 'a'
54+
actor.ask(2).value.should eq 2
6455

65-
assert actor.parent == Concurrent::Actress::ROOT
66-
assert Concurrent::Actress::ROOT.path == '/'
67-
assert actor.path == '/ping'
56+
actor.parent.should eq Concurrent::Actress::ROOT
57+
Concurrent::Actress::ROOT.path.should eq '/'
58+
actor.path.should eq '/ping'
6859
child = actor.ask(:child).value
69-
assert child.path == '/ping/pong'
60+
child.path.should eq '/ping/pong'
7061
queue.clear
7162
child.ask(3)
72-
assert queue.pop == 3
63+
queue.pop.should eq 3
7364

7465
actor << :terminate
75-
assert actor.ask(:blow_up).wait.rejected?
66+
actor.ask(:blow_up).wait.should be_rejected
7667
end
7768
end
7869
end.each(&:join)

spec/spec_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
logger = Logger.new($stderr)
2121
logger.level = Logger::INFO
22-
Concurrent.configuration.logger = -> (level, progname, message = nil, &block) { logger.add level, message, progname, &block }
22+
Concurrent.configuration.logger = lambda do |level, progname, message = nil, &block|
23+
logger.add level, message, progname, &block
24+
end
2325

2426
# import all the support files
2527
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require File.expand_path(f) }

0 commit comments

Comments
 (0)