mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/io-console] Ignore chomp! result and return the modified string
https://github.com/ruby/io-console/commit/09e5ccc729
This commit is contained in:
parent
06454a9457
commit
ead8d89bd7
2 changed files with 10 additions and 1 deletions
|
@ -1562,7 +1562,7 @@ static VALUE
|
||||||
str_chomp(VALUE str)
|
str_chomp(VALUE str)
|
||||||
{
|
{
|
||||||
if (!NIL_P(str)) {
|
if (!NIL_P(str)) {
|
||||||
str = rb_funcallv(str, rb_intern("chomp!"), 0, 0);
|
rb_funcallv(str, rb_intern("chomp!"), 0, 0);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,15 @@ defined?(PTY) and defined?(IO.console) and TestIO_Console.class_eval do
|
||||||
assert_equal("\r\n", r.gets)
|
assert_equal("\r\n", r.gets)
|
||||||
assert_equal("\"asdf\"", r.gets.chomp)
|
assert_equal("\"asdf\"", r.gets.chomp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
run_pty("p IO.console.getpass('> ')") do |r, w|
|
||||||
|
assert_equal("> ", r.readpartial(10))
|
||||||
|
sleep 0.1
|
||||||
|
w.print "asdf\C-D\C-D"
|
||||||
|
sleep 0.1
|
||||||
|
assert_equal("\r\n", r.gets)
|
||||||
|
assert_equal("\"asdf\"", r.gets.chomp)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_iflush
|
def test_iflush
|
||||||
|
|
Loading…
Add table
Reference in a new issue