Skip to content

Commit 9072885

Browse files
committed
split ractor-safe test for ruby 3/4 APIs
1 parent 97bfb2a commit 9072885

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

test/xxhash_test.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@
33

44
describe XXhash do
55
it 'is marked as ractor-safe' do
6-
skip("Ractorrs are not supported in this version of ruby(#{RUBY_VERSION})") unless defined?(Ractor)
6+
skip("Ractors are not supported in this version of ruby(#{RUBY_VERSION})") unless defined?(Ractor)
77

8-
ractor = Ractor.new do
9-
Ractor.yield XXhash.xxh32(Ractor.receive)
10-
end
8+
if defined?(Ractor::Port)
9+
ractor = Ractor.new do
10+
msg, reply_port = Ractor.receive
11+
reply_port << XXhash.xxh32(msg)
12+
end
13+
14+
reply = Ractor::Port.new
15+
ractor << ["test", reply]
1116

12-
ractor.send('test')
13-
assert_equal ractor.take, XXhash.xxh32('test')
17+
assert_equal reply.receive, XXhash.xxh32("test")
18+
else
19+
ractor = Ractor.new do
20+
Ractor.yield XXhash.xxh32(Ractor.receive)
21+
end
22+
23+
ractor.send('test')
24+
assert_equal ractor.take, XXhash.xxh32('test')
25+
end
1426
end
1527

1628
it 'returns 32-bit hash' do

0 commit comments

Comments
 (0)