Skip to content

Commit 1877ae5

Browse files
authored
Merge pull request #2181 from ruby/ruby-3_4
Prepare for ruby 3.4.0
2 parents d05c32d + 5a5cf79 commit 1877ae5

File tree

17 files changed

+137
-211
lines changed

17 files changed

+137
-211
lines changed

.github/workflows/ruby.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
ruby: ['3.1', '3.2', '3.3', head]
16+
ruby: ['3.1', '3.2', '3.3', '3.4.0-rc1', head]
1717
rubyopt: [""]
1818
job:
1919
- test
2020
include:
2121
- ruby: head
2222
job: stdlib_test rubocop
23-
- ruby: "3.3"
23+
- ruby: "3.4.0-rc1"
2424
job: stdlib_test
25-
- ruby: "3.3"
25+
- ruby: "3.4.0-rc1"
2626
job: test
2727
rubyopt: "--enable-frozen-string-literal"
28-
- ruby: "3.3"
28+
- ruby: "3.4.0-rc1"
2929
job: stdlib_test
3030
rubyopt: "--enable-frozen-string-literal"
31-
- ruby: "3.3"
31+
- ruby: "3.4.0-rc1"
3232
job: lexer templates compile confirm_lexer confirm_templates
33-
- ruby: "3.3"
33+
- ruby: "3.4.0-rc1"
3434
job: rubocop validate test_doc build test_generate_stdlib raap
35-
- ruby: "3.3"
35+
- ruby: "3.4.0-rc1"
3636
job: typecheck_test
3737
env:
3838
RANDOMIZE_STDLIB_TEST_ORDER: "true"

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gem "test-unit"
1010
gem "rspec"
1111
gem "rubocop"
1212
gem "rubocop-rubycw"
13-
gem "rubocop-on-rbs" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1')
13+
gem "rubocop-on-rbs"
1414
gem "json"
1515
gem "json-schema"
1616
gem "goodcheck"

bin/test_runner.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
require "set"
66

77
IS_LATEST_RUBY = Gem::Version.new(RUBY_VERSION).yield_self do |ruby_version|
8-
Gem::Version.new('3.3.0') <= ruby_version && ruby_version < Gem::Version.new('3.4.0')
8+
Gem::Version.new('3.4.0') <= ruby_version && ruby_version < Gem::Version.new('3.5.0')
99
end
1010

1111
unless IS_LATEST_RUBY
1212
unless ENV["CI"]
13-
STDERR.puts "⚠️⚠️⚠️⚠️ stdlib test assumes Ruby 3.3 but RUBY_VERSION==#{RUBY_VERSION} ⚠️⚠️⚠️⚠️"
13+
STDERR.puts "⚠️⚠️⚠️⚠️ stdlib test assumes Ruby 3.4 but RUBY_VERSION==#{RUBY_VERSION} ⚠️⚠️⚠️⚠️"
1414
end
1515
end
1616

lib/rbs/prototype/runtime.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,6 @@ def type_params(mod)
649649
end
650650

651651
def block_from_ast_of(method)
652-
return nil if RUBY_VERSION < '3.1'
653-
654652
begin
655653
ast = RubyVM::AbstractSyntaxTree.of(method)
656654
rescue ArgumentError

test/rbs/rb_prototype_test.rb

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -846,14 +846,8 @@ def test_duplicate_methods
846846

847847
rb = <<-'EOR'
848848
class C
849-
if RUBY_VERSION >= '2.7'
850-
def foo(x, y, z)
851-
do_something_27
852-
end
853-
else
854-
def foo(x, y, z)
855-
do_something
856-
end
849+
def foo(x, y, z)
850+
do_something_27
857851
end
858852
end
859853
EOR
@@ -1086,21 +1080,19 @@ def foo: (*untyped, **untyped) ?{ (?) -> untyped } -> nil
10861080
end
10871081
end
10881082

1089-
if RUBY_VERSION >= '3'
1090-
def test_endless_method_definition
1091-
parser = RB.new
1092-
rb = <<~'RUBY'
1083+
def test_endless_method_definition
1084+
parser = RB.new
1085+
rb = <<~'RUBY'
10931086
module M
10941087
def foo = 42
10951088
end
1096-
RUBY
1097-
parser.parse(rb)
1089+
RUBY
1090+
parser.parse(rb)
10981091

1099-
assert_write parser.decls, <<~RBS
1092+
assert_write parser.decls, <<~RBS
11001093
module M
11011094
def foo: () -> 42
11021095
end
1103-
RBS
1104-
end
1096+
RBS
11051097
end
11061098
end

test/rbs/runtime_prototype_test.rb

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -241,33 +241,6 @@ def test_decls_for_anonymous_class_or_module
241241
end
242242
end
243243

244-
if RUBY_VERSION >= '2.7' && RUBY_VERSION <= '3.0'
245-
class TestForArgumentForwarding
246-
eval <<~RUBY
247-
def foo(...)
248-
end
249-
RUBY
250-
end
251-
252-
def test_argument_forwarding
253-
SignatureManager.new do |manager|
254-
manager.build do |env|
255-
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::TestForArgumentForwarding"], env: env, merge: true)
256-
257-
assert_write p.decls, <<-EOF
258-
module RBS
259-
class RuntimePrototypeTest < ::Test::Unit::TestCase
260-
class TestForArgumentForwarding
261-
def foo: (*untyped) { (*untyped) -> untyped } -> untyped
262-
end
263-
end
264-
end
265-
EOF
266-
end
267-
end
268-
end
269-
end
270-
271244
module TestForOverrideModuleName
272245
module M
273246
def self.name() 'FakeNameM' end
@@ -389,35 +362,35 @@ def initialize: () -> void
389362
end
390363
end
391364

392-
if RUBY_VERSION >= '3.1' && RUBY_VERSION <= "3.3"
393-
class TestForYield
394-
def m1() yield end
395-
def m2() yield 42 end
396-
def m3() yield 42; yield 42, 43 end
397-
eval 'def m4() yield end'
398-
end
365+
class TestForYield
366+
def m1() yield end
367+
def m2() yield 42 end
368+
def m3() yield 42; yield 42, 43 end
369+
eval 'def m4() yield end'
370+
end
399371

400-
def test_for_yield
401-
SignatureManager.new do |manager|
402-
manager.build do |env|
403-
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::TestForYield"], env: env, merge: true)
372+
def test_for_yield
373+
omit "Ruby 3.4 uses Prism and needs migration" if RUBY_VERSION >= "3.4"
374+
375+
SignatureManager.new do |manager|
376+
manager.build do |env|
377+
p = Runtime.new(patterns: ["RBS::RuntimePrototypeTest::TestForYield"], env: env, merge: true)
404378

405-
assert_write p.decls, <<~RBS
406-
module RBS
407-
class RuntimePrototypeTest < ::Test::Unit::TestCase
408-
class TestForYield
409-
def m1: () { () -> untyped } -> untyped
379+
assert_write p.decls, <<~RBS
380+
module RBS
381+
class RuntimePrototypeTest < ::Test::Unit::TestCase
382+
class TestForYield
383+
def m1: () { () -> untyped } -> untyped
410384
411-
def m2: () { (untyped) -> untyped } -> untyped
385+
def m2: () { (untyped) -> untyped } -> untyped
412386
413-
def m3: () { (untyped, untyped) -> untyped } -> untyped
387+
def m3: () { (untyped, untyped) -> untyped } -> untyped
414388
415-
def m4: () -> untyped
416-
end
389+
def m4: () -> untyped
417390
end
418391
end
419-
RBS
420-
end
392+
end
393+
RBS
421394
end
422395
end
423396
end

test/rbs/test/hook_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
require "rbs/test"
44
require "logger"
55

6-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
7-
86
class RBS::Test::HookTest < Test::Unit::TestCase
97
class Example
108
def hello(x, y)

test/rbs/test/type_check_test.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
require "rbs/test"
44
require "logger"
55

6-
return unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
7-
86
RSPEC_MOCK = -> { double('foo') }
97

108
class RBS::Test::TypeCheckTest < Test::Unit::TestCase

test/stdlib/IO_test.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -422,24 +422,22 @@ class IOWaitTest < Test::Unit::TestCase
422422
testing "::IO"
423423

424424
def test_readyp
425-
if_ruby31 do
426-
# This method returns true|false in Ruby 2.7, nil|IO in 3.0, and true|false in 3.1.
425+
# This method returns true|false in Ruby 2.7, nil|IO in 3.0, and true|false in 3.1.
427426

428-
IO.pipe.tap do |r, w|
429-
assert_send_type(
430-
"() -> untyped",
431-
r, :ready?
432-
)
433-
end
427+
IO.pipe.tap do |r, w|
428+
assert_send_type(
429+
"() -> untyped",
430+
r, :ready?
431+
)
432+
end
434433

435-
IO.pipe.tap do |r, w|
436-
w.write("hello")
434+
IO.pipe.tap do |r, w|
435+
w.write("hello")
437436

438-
assert_send_type(
439-
"() -> untyped",
440-
r, :ready?
441-
)
442-
end
437+
assert_send_type(
438+
"() -> untyped",
439+
r, :ready?
440+
)
443441
end
444442
end
445443

@@ -491,7 +489,7 @@ def test_nread
491489
end
492490

493491
def test_wait
494-
if_ruby "3.0.0"..."3.2.0" do
492+
if_ruby "3.0.0"..."3.2.0", skip: false do
495493
IO.pipe.tap do |r, w|
496494
w.write("hello")
497495

0 commit comments

Comments
 (0)