test/scrollback: wiggle-room (#6256)

This commit is contained in:
Justin M. Keyes
2017-03-11 14:46:35 +01:00
committed by GitHub
parent c5edde90cc
commit fd27d5a70f

View File

@@ -368,10 +368,11 @@ describe("'scrollback' option", function()
clear() clear()
end) end)
local function expect_lines(expected) local function expect_lines(expected, epsilon)
local ep = epsilon and epsilon or 0
local actual = eval("line('$')") local actual = eval("line('$')")
if expected ~= actual then if expected > actual + ep and expected < actual - ep then
error('expected: '..expected..', actual: '..tostring(actual)) error('expected (+/- '..ep..'): '..expected..', actual: '..tostring(actual))
end end
end end
@@ -399,12 +400,12 @@ describe("'scrollback' option", function()
screen:expect('line30 ', nil, nil, nil, true) screen:expect('line30 ', nil, nil, nil, true)
retry(nil, nil, function() expect_lines(33) end) retry(nil, nil, function() expect_lines(33, 2) end)
curbufmeths.set_option('scrollback', 10) curbufmeths.set_option('scrollback', 10)
wait() wait()
retry(nil, nil, function() expect_lines(16) end) retry(nil, nil, function() expect_lines(16) end)
curbufmeths.set_option('scrollback', 10000) curbufmeths.set_option('scrollback', 10000)
eq(16, eval("line('$')")) retry(nil, nil, function() expect_lines(16) end)
-- Terminal job data is received asynchronously, may happen before the -- Terminal job data is received asynchronously, may happen before the
-- 'scrollback' option is synchronized with the internal sb_buffer. -- 'scrollback' option is synchronized with the internal sb_buffer.
command('sleep 100m') command('sleep 100m')