Skip to content

Commit 36f42e8

Browse files
OskarEichlernobu
authored andcommitted
Return nil when JRuby has no console device
1 parent deb5c1f commit 36f42e8

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

‎jruby/lib/io/console/common.rb‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def self.console(sym = nil, *args)
4343
@console = con
4444
end
4545

46+
return nil unless con
4647
return con.send(sym, *args) if sym
4748
return con
4849
end

‎test/io/console/test_io_console.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def run_noctty(src)
720720
end
721721

722722
def test_noctty
723-
assert_equal(["nil"], run_noctty("IO.console"))
723+
assert_equal(["[nil, nil]"], run_noctty("[IO.console, IO.console(:tty?)]"))
724724
if IO.method_defined?(:ttyname)
725725
assert_equal(["nil"], run_noctty("STDIN.ttyname rescue $!"))
726726
end

0 commit comments

Comments
 (0)