refine tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1c3e07f0d6
commit
d24d2d3ca4
@ -16,7 +16,27 @@ class TestIO_Console < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_echo
|
||||||
|
PTY.open {|m, s|
|
||||||
|
assert(s.echo?)
|
||||||
|
m.print "a"
|
||||||
|
assert_equal("a", m.readpartial(10))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def test_noecho
|
def test_noecho
|
||||||
|
PTY.open {|m, s|
|
||||||
|
s.noecho {
|
||||||
|
assert(!s.echo?)
|
||||||
|
m.print "a"
|
||||||
|
sleep 0.1
|
||||||
|
}
|
||||||
|
m.print "b"
|
||||||
|
assert_equal("b", m.readpartial(10))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_noecho2
|
||||||
PTY.open {|m, s|
|
PTY.open {|m, s|
|
||||||
assert(s.echo?)
|
assert(s.echo?)
|
||||||
m.print "a\n"
|
m.print "a\n"
|
||||||
@ -43,6 +63,18 @@ class TestIO_Console < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_setecho
|
def test_setecho
|
||||||
|
PTY.open {|m, s|
|
||||||
|
assert(s.echo?)
|
||||||
|
s.echo = false
|
||||||
|
m.print "a"
|
||||||
|
sleep 0.1
|
||||||
|
s.echo = true
|
||||||
|
m.print "b"
|
||||||
|
assert_equal("b", m.readpartial(10))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_setecho2
|
||||||
PTY.open {|m, s|
|
PTY.open {|m, s|
|
||||||
assert(s.echo?)
|
assert(s.echo?)
|
||||||
m.print "a\n"
|
m.print "a\n"
|
||||||
@ -70,24 +102,43 @@ class TestIO_Console < Test::Unit::TestCase
|
|||||||
|
|
||||||
def test_iflush
|
def test_iflush
|
||||||
PTY.open {|m, s|
|
PTY.open {|m, s|
|
||||||
m.print "a\n"
|
m.print "a"
|
||||||
sleep 0.1
|
|
||||||
s.iflush
|
s.iflush
|
||||||
sleep 0.1
|
|
||||||
m.print "b\n"
|
m.print "b\n"
|
||||||
sleep 0.1
|
|
||||||
assert_equal("a\r\nb\r\n", m.readpartial(10))
|
|
||||||
assert_equal("b\n", s.readpartial(10))
|
assert_equal("b\n", s.readpartial(10))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_oflush
|
def test_oflush
|
||||||
PTY.open {|m, s|
|
PTY.open {|m, s|
|
||||||
s.print "a\n"
|
s.print "a"
|
||||||
s.oflush
|
s.oflush # oflush may be issued after "a" is already sent.
|
||||||
s.print "b\n"
|
s.print "b"
|
||||||
assert_equal("b\r\n", m.readpartial(10))
|
assert_includes(["b", "ab"], m.readpartial(10))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ioflush
|
||||||
|
PTY.open {|m, s|
|
||||||
|
m.print "a"
|
||||||
|
s.ioflush
|
||||||
|
m.print "b\n"
|
||||||
|
assert_equal("b\n", s.readpartial(10))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ioflush2
|
||||||
|
PTY.open {|m, s|
|
||||||
|
s.print "a"
|
||||||
|
s.ioflush # ioflush may be issued after "a" is already sent.
|
||||||
|
s.print "b"
|
||||||
|
assert_includes(["b", "ab"], m.readpartial(10))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_winsize
|
||||||
|
PTY.open {|m, s|
|
||||||
|
assert_equal([0, 0], s.winsize)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user