From 655f3d01fe6a0d31aa0bfbc34fc3edb41942eb2a Mon Sep 17 00:00:00 2001 From: Erik Berlin Date: Tue, 20 Oct 2026 10:07:04 -0700 Subject: [PATCH] Keep IO#isatty an alias of IO#tty? on JRuby The C extension defines both tty? and isatty in IO::platform_tty, so they stay the same method once io/console is loaded. The JRuby backends' PlatformTty only defined tty?, so after https://github.com/ruby/io-console/commit/f686b8305 loading io/console left IO#isatty as the original method, which ruby/spec's "IO#isatty is an alias of IO#tty?" checks. --- jruby/lib/io/console/common.rb | 1 + test/io/console/test_io_console.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/jruby/lib/io/console/common.rb b/jruby/lib/io/console/common.rb index efa3015..876e77b 100644 --- a/jruby/lib/io/console/common.rb +++ b/jruby/lib/io/console/common.rb @@ -181,6 +181,7 @@ def tty?(*modes) end super() end + alias isatty tty? end private_constant :PlatformTty end diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 838abb4..b59777c 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -94,6 +94,10 @@ def test_tty? assert_equal(STDIN.tty?, STDIN.tty?(nil)) end + def test_isatty + assert_equal(IO.instance_method(:tty?), IO.instance_method(:isatty)) + end + def test_tty_non_tty File.open(IO::NULL) do |f| assert_not_predicate(f, :tty?)