Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions jruby/lib/io/console/backend/stty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,23 @@ def oflush

def ioflush
end

module PlatformStty # :nodoc:
def tty?(*modes)
modes.each do |mode|
case mode
when nil
when :any
when Symbol
raise ArgumentError, "unknown tty type: #{mode.inspect}"
else
raise TypeError, "wrong argument type #{mode.class} (expected Symbol)"
end
end
super()
end
end
private_constant :PlatformStty

prepend PlatformStty
end
6 changes: 2 additions & 4 deletions test/io/console/test_io_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ def test_bad_keyword
TTY_MODE_STTY = IO.private_method_defined?(:_io_console_stty)

def test_stty_mode_arguments
omit "stty backend only" unless TTY_MODE_STTY

mode = IO::Console::Mode.new(
"saved\n",
"echo icanon isig opost; min = 1; time = 0;",
)
mode.raw!(min: 2, time: 0.3)

assert_equal(["saved", "raw", "min", "2", "time", "3"], mode.arguments)
end
end if TTY_MODE_STTY

def test_tty?
pend "not supported" unless TTY_ENHANCED
Expand Down Expand Up @@ -346,7 +344,7 @@ def test_stty_redirect_stdout
end
assert_not_empty(mode)
end
end if IO.private_method_defined?(:_io_console_stty)
end if TTY_MODE_STTY

def test_tty_on_pty
pend "not supported" unless TTY_ENHANCED
Expand Down
Loading