Skip to content

Commit 79a7d46

Browse files
authored
Merge pull request #2725 from ruby/fix-ruby-skip-tests
Fix tests for rbs_skip_tests in ruby repo
2 parents 5d97dd5 + 0738108 commit 79a7d46

File tree

3 files changed

+17
-315
lines changed

3 files changed

+17
-315
lines changed

core/ractor.rbs

Lines changed: 3 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -350,68 +350,6 @@ class Ractor
350350
#
351351
def self.receive: () -> untyped
352352

353-
# <!--
354-
# rdoc-file=ractor.rb
355-
# - Ractor.receive_if {|msg| block } -> msg
356-
# -->
357-
# Receive only a specific message.
358-
#
359-
# Instead of Ractor.receive, Ractor.receive_if can be given a pattern (or any
360-
# filter) in a block and you can choose the messages to accept that are
361-
# available in your ractor's incoming queue.
362-
#
363-
# r = Ractor.new do
364-
# p Ractor.receive_if{|msg| msg.match?(/foo/)} #=> "foo3"
365-
# p Ractor.receive_if{|msg| msg.match?(/bar/)} #=> "bar1"
366-
# p Ractor.receive_if{|msg| msg.match?(/baz/)} #=> "baz2"
367-
# end
368-
# r << "bar1"
369-
# r << "baz2"
370-
# r << "foo3"
371-
# r.take
372-
#
373-
# This will output:
374-
#
375-
# foo3
376-
# bar1
377-
# baz2
378-
#
379-
# If the block returns a truthy value, the message is removed from the incoming
380-
# queue and returned. Otherwise, the message remains in the incoming queue and
381-
# the next messages are checked by the given block.
382-
#
383-
# If there are no messages left in the incoming queue, the method will block
384-
# until new messages arrive.
385-
#
386-
# If the block is escaped by break/return/exception/throw, the message is
387-
# removed from the incoming queue as if a truthy value had been returned.
388-
#
389-
# r = Ractor.new do
390-
# val = Ractor.receive_if{|msg| msg.is_a?(Array)}
391-
# puts "Received successfully: #{val}"
392-
# end
393-
#
394-
# r.send(1)
395-
# r.send('test')
396-
# wait
397-
# puts "2 non-matching sent, nothing received"
398-
# r.send([1, 2, 3])
399-
# wait
400-
#
401-
# Prints:
402-
#
403-
# 2 non-matching sent, nothing received
404-
# Received successfully: [1, 2, 3]
405-
#
406-
# Note that you can not call receive/receive_if in the given block recursively.
407-
# You should not do any tasks in the block other than message filtration.
408-
#
409-
# Ractor.current << true
410-
# Ractor.receive_if{|msg| Ractor.receive}
411-
# #=> `receive': can not call receive/receive_if recursively (Ractor::Error)
412-
#
413-
def self.receive_if: () { (untyped) -> boolish } -> untyped
414-
415353
# <!--
416354
# rdoc-file=ractor.rb
417355
# - recv()
@@ -425,7 +363,7 @@ class Ractor
425363
# -->
426364
# TBD
427365
#
428-
def self.select: (*Ractor ractors, ?move: boolish, ?yield_value: untyped) -> [ Ractor | Symbol, untyped ]
366+
def self.select: (?) -> untyped
429367

430368
# <!--
431369
# rdoc-file=ractor.rb
@@ -459,46 +397,6 @@ class Ractor
459397
#
460398
def self.store_if_absent: [A] (Symbol) { (nil) -> A } -> A
461399

462-
# <!--
463-
# rdoc-file=ractor.rb
464-
# - Ractor.yield(msg, move: false) -> nil
465-
# -->
466-
# Send a message to the current ractor's outgoing port to be accepted by #take.
467-
#
468-
# r = Ractor.new {Ractor.yield 'Hello from ractor'}
469-
# puts r.take
470-
# # Prints: "Hello from ractor"
471-
#
472-
# This method is blocking, and will return only when somebody consumes the sent
473-
# message.
474-
#
475-
# r = Ractor.new do
476-
# Ractor.yield 'Hello from ractor'
477-
# puts "Ractor: after yield"
478-
# end
479-
# wait
480-
# puts "Still not taken"
481-
# puts r.take
482-
#
483-
# This will print:
484-
#
485-
# Still not taken
486-
# Hello from ractor
487-
# Ractor: after yield
488-
#
489-
# If the outgoing port was closed with #close_outgoing, the method will raise:
490-
#
491-
# r = Ractor.new do
492-
# close_outgoing
493-
# Ractor.yield 'Hello from ractor'
494-
# end
495-
# wait
496-
# # `yield': The outgoing-port is already closed (Ractor::ClosedError)
497-
#
498-
# The meaning of the `move` argument is the same as for #send.
499-
#
500-
def self.yield: (untyped obj, ?move: boolish) -> untyped
501-
502400
# <!--
503401
# rdoc-file=ractor.rb
504402
# - <<(...)
@@ -513,6 +411,7 @@ class Ractor
513411
# get a value from ractor-local storage for current Ractor Obsolete and use
514412
# Ractor.[] instead.
515413
#
414+
%a{deprecated: Use Ractor.[] instead}
516415
def []: (interned sym) -> untyped
517416

518417
# <!--
@@ -522,40 +421,9 @@ class Ractor
522421
# set a value in ractor-local storage for current Ractor Obsolete and use
523422
# Ractor.[]= instead.
524423
#
424+
%a{deprecated: Use Ractor.[]= instead}
525425
def []=: [T] (interned sym, T val) -> T
526426

527-
# <!--
528-
# rdoc-file=ractor.rb
529-
# - ractor.close_incoming -> true | false
530-
# -->
531-
# Closes the incoming port and returns whether it was already closed. All
532-
# further attempts to Ractor.receive in the ractor, and #send to the ractor will
533-
# fail with Ractor::ClosedError.
534-
#
535-
# r = Ractor.new {sleep(500)}
536-
# r.close_incoming #=> false
537-
# r.close_incoming #=> true
538-
# r.send('test')
539-
# # Ractor::ClosedError (The incoming-port is already closed)
540-
#
541-
def close_incoming: () -> bool
542-
543-
# <!--
544-
# rdoc-file=ractor.rb
545-
# - ractor.close_outgoing -> true | false
546-
# -->
547-
# Closes the outgoing port and returns whether it was already closed. All
548-
# further attempts to Ractor.yield in the ractor, and #take from the ractor will
549-
# fail with Ractor::ClosedError.
550-
#
551-
# r = Ractor.new {sleep(500)}
552-
# r.close_outgoing #=> false
553-
# r.close_outgoing #=> true
554-
# r.take
555-
# # Ractor::ClosedError (The outgoing-port is already closed)
556-
#
557-
def close_outgoing: () -> bool
558-
559427
# <!--
560428
# rdoc-file=ractor.rb
561429
# - inspect()
@@ -579,73 +447,6 @@ class Ractor
579447
#
580448
def send: (untyped obj, ?move: boolish) -> Ractor
581449

582-
# <!--
583-
# rdoc-file=ractor.rb
584-
# - ractor.take -> msg
585-
# -->
586-
# Get a message from the ractor's outgoing port, which was put there by
587-
# Ractor.yield or at ractor's termination.
588-
#
589-
# r = Ractor.new do
590-
# Ractor.yield 'explicit yield'
591-
# 'last value'
592-
# end
593-
# puts r.take #=> 'explicit yield'
594-
# puts r.take #=> 'last value'
595-
# puts r.take # Ractor::ClosedError (The outgoing-port is already closed)
596-
#
597-
# The fact that the last value is also sent to the outgoing port means that
598-
# `take` can be used as an analog of Thread#join ("just wait until ractor
599-
# finishes"). However, it will raise if somebody has already consumed that
600-
# message.
601-
#
602-
# If the outgoing port was closed with #close_outgoing, the method will raise
603-
# Ractor::ClosedError.
604-
#
605-
# r = Ractor.new do
606-
# sleep(500)
607-
# Ractor.yield 'Hello from ractor'
608-
# end
609-
# r.close_outgoing
610-
# r.take
611-
# # Ractor::ClosedError (The outgoing-port is already closed)
612-
# # The error would be raised immediately, not when ractor will try to receive
613-
#
614-
# If an uncaught exception is raised in the Ractor, it is propagated by take as
615-
# a Ractor::RemoteError.
616-
#
617-
# r = Ractor.new {raise "Something weird happened"}
618-
#
619-
# begin
620-
# r.take
621-
# rescue => e
622-
# p e # => #<Ractor::RemoteError: thrown by remote Ractor.>
623-
# p e.ractor == r # => true
624-
# p e.cause # => #<RuntimeError: Something weird happened>
625-
# end
626-
#
627-
# Ractor::ClosedError is a descendant of StopIteration, so the termination of
628-
# the ractor will break out of any loops that receive this message without
629-
# propagating the error:
630-
#
631-
# r = Ractor.new do
632-
# 3.times {|i| Ractor.yield "message #{i}"}
633-
# "finishing"
634-
# end
635-
#
636-
# loop {puts "Received: " + r.take}
637-
# puts "Continue successfully"
638-
#
639-
# This will print:
640-
#
641-
# Received: message 0
642-
# Received: message 1
643-
# Received: message 2
644-
# Received: finishing
645-
# Continue successfully
646-
#
647-
def take: () -> untyped
648-
649450
# <!--
650451
# rdoc-file=ractor.rb
651452
# - to_s()

test/stdlib/Pathname_test.rb

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ def test_pwd
2727
Pathname, :pwd
2828
end
2929

30-
def test_initialize
31-
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
32-
30+
def test_new
3331
assert_send_type '(String) -> Pathname',
3432
Pathname, :new, 'foo'
3533
assert_send_type '(ToStr) -> Pathname',
36-
Pathname, :new, ToStr.new('foo')
34+
Pathname, :new, ToStr.new('foo').__with_object_methods(:respond_to?)
3735
assert_send_type '(Pathname) -> Pathname',
3836
Pathname, :new, Pathname('foo')
3937
end
@@ -45,25 +43,21 @@ class PathnameInstanceTest < Test::Unit::TestCase
4543
testing '::Pathname'
4644

4745
def test_plus
48-
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
49-
5046
assert_send_type '(Pathname) -> Pathname',
5147
Pathname('foo'), :+, Pathname('bar')
5248
assert_send_type '(String) -> Pathname',
5349
Pathname('foo'), :+, 'bar'
5450
assert_send_type '(ToStr) -> Pathname',
55-
Pathname('foo'), :+, ToStr.new('bar')
51+
Pathname('foo'), :+, ToStr.new('bar').__with_object_methods(:respond_to?)
5652
end
5753

5854
def test_slash
59-
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
60-
6155
assert_send_type '(Pathname) -> Pathname',
6256
Pathname('foo'), :/, Pathname('bar')
6357
assert_send_type '(String) -> Pathname',
6458
Pathname('foo'), :/, 'bar'
6559
assert_send_type '(ToStr) -> Pathname',
66-
Pathname('foo'), :/, ToStr.new('bar')
60+
Pathname('foo'), :/, ToStr.new('bar').__with_object_methods(:respond_to?)
6761
end
6862

6963
def test_spaceship
@@ -386,16 +380,14 @@ def test_inspect
386380
end
387381

388382
def test_join
389-
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
390-
391383
assert_send_type '() -> Pathname',
392384
Pathname('.'), :join
393385
assert_send_type '(String) -> Pathname',
394386
Pathname('.'), :join, 'foo'
395387
assert_send_type '(String, String) -> Pathname',
396388
Pathname('.'), :join, 'foo', 'bar'
397389
assert_send_type '(ToStr) -> Pathname',
398-
Pathname('.'), :join, ToStr.new('foo')
390+
Pathname('.'), :join, ToStr.new('foo').__with_object_methods(:respond_to?)
399391
assert_send_type '(Pathname) -> Pathname',
400392
Pathname('.'), :join, Pathname('foo')
401393
end
@@ -610,15 +602,13 @@ def test_relative?
610602
end
611603

612604
def test_relative_path_from
613-
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
614-
615605
assert_send_type '(Pathname) -> Pathname',
616606
Pathname('.'), :relative_path_from, Pathname('.')
617607
assert_send_type '(String) -> Pathname',
618608
Pathname('.'), :relative_path_from, '.'
619609

620610
assert_send_type '(_ToStr) -> Pathname',
621-
Pathname('.'), :relative_path_from, ToStr.new('.').__with_object_methods(:is_a?)
611+
Pathname('.'), :relative_path_from, ToStr.new('.').__with_object_methods(:is_a?, :respond_to?)
622612
end
623613

624614
def test_rename
@@ -834,14 +824,15 @@ class PathnameKernelTest < Test::Unit::TestCase
834824
testing '::Kernel'
835825

836826
def test_Pathname
837-
omit "Pathname is developing in head" if RUBY_VERSION >= '3.5'
827+
assert_send_type(
828+
"(::String) -> ::Pathname",
829+
self, :Pathname, "Gemfile"
830+
)
838831

839-
with_string("Gemfile") do
840-
assert_send_type(
841-
"(::string) -> ::Pathname",
842-
self, :Pathname, _1
843-
)
844-
end
832+
assert_send_type(
833+
"(::_ToStr) -> ::Pathname",
834+
self, :Pathname, ToStr.new("Gemfile").__with_object_methods(:respond_to?)
835+
)
845836

846837
assert_send_type(
847838
"(::Pathname) -> ::Pathname",

0 commit comments

Comments
 (0)