[ruby/io-console] Avoid the influence of special variable $/

https://github.com/ruby/io-console/commit/5f71354332
This commit is contained in:
Nobuyoshi Nakada 2023-08-18 12:19:25 +09:00 committed by git
parent cff8058701
commit 818ba30ee9
2 changed files with 10 additions and 1 deletions

View File

@ -1564,7 +1564,7 @@ static VALUE
str_chomp(VALUE str)
{
if (!NIL_P(str)) {
rb_funcallv(str, id_chomp_bang, 0, 0);
rb_funcallv(str, id_chomp_bang, 1, &rb_default_rs);
}
return str;
}

View File

@ -258,6 +258,15 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
assert_equal("\r\n", r.gets)
assert_equal("\"asdf\"", r.gets.chomp)
end
run_pty("$VERBOSE, $/ = nil, '.'; p IO.console.getpass('> ')") do |r, w|
assert_equal("> ", r.readpartial(10))
sleep 0.1
w.print "asdf\n"
sleep 0.1
assert_equal("\r\n", r.gets)
assert_equal("\"asdf\"", r.gets.chomp)
end
end
def test_iflush