77end
88
99class TestIO_Console < Test ::Unit ::TestCase
10+ HOST_OS = RbConfig ::CONFIG [ 'host_os' ]
11+ private def host_os? ( os )
12+ HOST_OS =~ os
13+ end
14+
1015 begin
1116 PATHS = $LOADED_FEATURES. grep ( %r"/io/console(?:\. #{ RbConfig ::CONFIG [ 'DLEXT' ] } |\. rb|/\w +\. rb)\z " ) { $`}
1217 rescue Encoding ::CompatibilityError
@@ -26,7 +31,7 @@ class TestIO_Console < Test::Unit::TestCase
2631 # But it does not occur in `make test-all > /dev/null`, so
2732 # there should be an additional factor, I guess.
2833 def set_winsize_setup
29- @old_ttou = trap ( :TTOU , 'IGNORE' ) if RUBY_PLATFORM =~ /freebsd/i
34+ @old_ttou = trap ( :TTOU , 'IGNORE' ) if host_os? ( /freebsd/ )
3035 end
3136
3237 def set_winsize_teardown
@@ -368,10 +373,10 @@ def assert_ctrl(expect, cc, r, w)
368373 w . flush
369374 result = EnvUtil . timeout ( 3 ) { r . gets }
370375 if result
371- case cc
372- when 0 .. 31
376+ case cc . chr
377+ when " \C -A" .. " \C -_"
373378 cc = "^" + ( cc . ord | 0x40 ) . chr
374- when 127
379+ when " \C -?"
375380 cc = "^?"
376381 end
377382 result . sub! ( cc , "" )
@@ -387,7 +392,7 @@ def test_intr
387392 # TestIO_Console#test_intr [/usr/home/chkbuild/chkbuild/tmp/build/20220304T163001Z/ruby/test/io/console/test_io_console.rb:387]:
388393 # <"25"> expected but was
389394 # <"-e:12:in `p': \e[1mexecution expired (\e[1;4mTimeout::Error\e[m\e[1m)\e[m">.
390- omit if /freebsd/ =~ RUBY_PLATFORM
395+ omit if host_os? ( /freebsd/ )
391396
392397 run_pty ( "#{ <<~"begin;" } \n #{ <<~'end;' } " ) do |r , w , _ |
393398 begin;
@@ -413,7 +418,7 @@ def test_intr
413418 if cc = ctrl [ "intr" ]
414419 assert_ctrl ( "#{ cc . ord } " , cc , r , w )
415420 assert_ctrl ( "#{ cc . ord } " , cc , r , w )
416- assert_ctrl ( "Interrupt" , cc , r , w ) unless /linux/ =~ " #{ RUBY_PLATFORM } #{ RbConfig :: CONFIG [ 'host_os' ] } "
421+ assert_ctrl ( "Interrupt" , cc , r , w ) unless host_os? ( /linux/ )
417422 end
418423 if cc = ctrl [ "dsusp" ]
419424 assert_ctrl ( "#{ cc . ord } " , cc , r , w )
0 commit comments