From 2f8e5c80e65a14b3a9298b6cae7ee7fc53890540 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Wed, 5 Apr 2023 22:40:34 +0100 Subject: [ruby/irb] Drop Ruby 2.6 support (https://github.com/ruby/irb/pull/555) * Remove all Ruby 2.6 support * Drop Ruby 2.6 specific testing conditions * Only run Ruby 2.7+ on CI * Bump Ruby requirement to 2.7+ https://github.com/ruby/irb/commit/3f714b616c --- test/irb/test_cmd.rb | 3 --- test/irb/test_color.rb | 45 +++++++----------------------------------- test/irb/test_color_printer.rb | 7 ------- test/irb/test_context.rb | 1 - test/irb/test_ruby_lex.rb | 15 -------------- 5 files changed, 7 insertions(+), 64 deletions(-) (limited to 'test/irb') diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index ef864fb5c9..66328b89b1 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -855,9 +855,6 @@ module TestIRB end def test_edit_with_constant - # const_source_location is supported after Ruby 2.7 - omit if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') - out, err = execute_lines( "edit IRB::Irb" ) diff --git a/test/irb/test_color.rb b/test/irb/test_color.rb index fbcb283a6d..652396c89e 100644 --- a/test/irb/test_color.rb +++ b/test/irb/test_color.rb @@ -109,14 +109,11 @@ module TestIRB "< "#{RED}<= Gem::Version.new('2.7.0') - tests.merge!({ - "4.5.6" => "#{MAGENTA}#{BOLD}4.5#{CLEAR}#{RED}#{REVERSE}.6#{CLEAR}", - "\e[0m\n" => "#{RED}#{REVERSE}^[#{CLEAR}[#{BLUE}#{BOLD}0#{CLEAR}#{RED}#{REVERSE}m#{CLEAR}\n", - "< "#{RED}< "#{MAGENTA}#{BOLD}4.5#{CLEAR}#{RED}#{REVERSE}.6#{CLEAR}", + "\e[0m\n" => "#{RED}#{REVERSE}^[#{CLEAR}[#{BLUE}#{BOLD}0#{CLEAR}#{RED}#{REVERSE}m#{CLEAR}\n", + "< "#{RED}<= Gem::Version.new('3.0.0') @@ -136,18 +133,9 @@ module TestIRB }) end else - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - tests.merge!({ - "[1]]]\u0013" => "[#{BLUE}#{BOLD}1#{CLEAR}]#{RED}#{REVERSE}]#{CLEAR}]^S", - "def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}true#{CLEAR}) end", - }) - else - tests.merge!({ - "[1]]]\u0013" => "[#{BLUE}#{BOLD}1#{CLEAR}]]]^S", - "def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{CYAN}#{BOLD}true#{CLEAR}) end", - }) - end tests.merge!({ + "[1]]]\u0013" => "[#{BLUE}#{BOLD}1#{CLEAR}]#{RED}#{REVERSE}]#{CLEAR}]^S", + "def req(true) end" => "#{GREEN}def#{CLEAR} #{BLUE}#{BOLD}req#{CLEAR}(#{RED}#{REVERSE}true#{CLEAR}) end", "nil = 1" => "#{CYAN}#{BOLD}nil#{CLEAR} = #{BLUE}#{BOLD}1#{CLEAR}", "alias $x $1" => "#{GREEN}alias#{CLEAR} #{GREEN}#{BOLD}$x#{CLEAR} $1", "class bad; end" => "#{GREEN}class#{CLEAR} bad; #{GREEN}end#{CLEAR}", @@ -184,10 +172,6 @@ module TestIRB end def test_colorize_code_complete_true - unless complete_option_supported? - pend '`complete: true` is the same as `complete: false` in Ruby 2.6-' - end - # `complete: true` behaviors. Warn end-of-file. { "'foo' + 'bar" => "#{RED}#{BOLD}'#{CLEAR}#{RED}foo#{CLEAR}#{RED}#{BOLD}'#{CLEAR} + #{RED}#{BOLD}'#{CLEAR}#{RED}#{REVERSE}bar#{CLEAR}", @@ -216,16 +200,6 @@ module TestIRB assert_equal_with_term(code, code, complete: false, colorable: false) assert_equal_with_term(result, code, complete: false, tty: false, colorable: true) - - unless complete_option_supported? - assert_equal_with_term(result, code, complete: true) - - assert_equal_with_term(code, code, complete: true, tty: false) - - assert_equal_with_term(code, code, complete: true, colorable: false) - - assert_equal_with_term(result, code, complete: true, tty: false, colorable: true) - end end end @@ -251,11 +225,6 @@ module TestIRB private - # `complete: true` is the same as `complete: false` in Ruby 2.6- - def complete_option_supported? - Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - end - def with_term(tty: true) stdout = $stdout io = StringIO.new diff --git a/test/irb/test_color_printer.rb b/test/irb/test_color_printer.rb index 41a7345bd3..a717940d81 100644 --- a/test/irb/test_color_printer.rb +++ b/test/irb/test_color_printer.rb @@ -38,9 +38,6 @@ module TestIRB IRBTestColorPrinter = Struct.new(:a) def test_color_printer - unless ripper_lexer_scan_supported? - pend 'Ripper::Lexer#scan is supported in Ruby 2.7+' - end { 1 => "#{BLUE}#{BOLD}1#{CLEAR}\n", "a\nb" => %[#{RED}#{BOLD}"#{CLEAR}#{RED}a\\nb#{CLEAR}#{RED}#{BOLD}"#{CLEAR}\n], @@ -55,10 +52,6 @@ module TestIRB private - def ripper_lexer_scan_supported? - Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0') - end - def with_term stdout = $stdout io = StringIO.new diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb index 783b19b970..c4ca56aba6 100644 --- a/test/irb/test_context.rb +++ b/test/irb/test_context.rb @@ -185,7 +185,6 @@ module TestIRB end def test_object_inspection_prints_useful_info_when_kernel_inspect_also_errored - omit if RUBY_VERSION < '2.7' verbose, $VERBOSE = $VERBOSE, nil main = Object.new main.singleton_class.module_eval <<~RUBY diff --git a/test/irb/test_ruby_lex.rb b/test/irb/test_ruby_lex.rb index d9b1418cbe..1657d0fc6d 100644 --- a/test/irb/test_ruby_lex.rb +++ b/test/irb/test_ruby_lex.rb @@ -613,9 +613,6 @@ module TestIRB end def test_broken_heredoc - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') - pend 'This test needs Ripper::Lexer#scan to take broken tokens' - end input_with_correct_indents = [ Row.new(%q(def foo), nil, 2, 1), Row.new(%q( <<~Q), 2, 2, 1), @@ -721,10 +718,6 @@ module TestIRB end def test_broken_percent_literal - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') - pend 'This test needs Ripper::Lexer#scan to take broken tokens' - end - tokens = RubyLex.ripper_lex_without_warning('%wwww') pos_to_index = {} tokens.each_with_index { |t, i| @@ -734,10 +727,6 @@ module TestIRB end def test_broken_percent_literal_in_method - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') - pend 'This test needs Ripper::Lexer#scan to take broken tokens' - end - tokens = RubyLex.ripper_lex_without_warning(<<~EOC.chomp) def foo %wwww @@ -751,10 +740,6 @@ module TestIRB end def test_unterminated_code - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.7.0') - pend 'This test needs Ripper::Lexer#scan to take broken tokens' - end - ['do', '<