fix all tests in LÖVE v12

This is all quite hacky. Many of my tests are unfortunately brittle to
changes in text rendering. Fortunately there's only one test that
currently requires a hacky special case (and a second test I tweaked
slightly to be more robust).

I can't think of a better approach. It doesn't help to standardize the
font, because version changes still come with changes to text-shaping
algorithms even if the font itself is unchanged. I could base all my
assertions on the widths of individual characters, but that would make
the tests much less readable and not express intent as clearly. So here
we are, with hopefully just a few hacky special cases (there might be a
few more as LÖVE v12 advances towards publication, and in further
versions).
This commit is contained in:
Kartik K. Agaram 2023-10-09 20:25:08 -07:00
parent 6e391d7875
commit 69d86cae5b
2 changed files with 20 additions and 6 deletions

View File

@ -1086,7 +1086,14 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line()
y = y + Editor_state.line_height
App.screen.check(y, 'jkl ', 'screen:2')
y = y + Editor_state.line_height
App.screen.check(y, 'mn', 'screen:3')
if Version == '12.0' then
-- HACK: Maybe v12.0 uses a different font? Strange that it only causes
-- issues in a couple of places.
-- We'll need to rethink our tests if issues like this start to multiply.
App.screen.check(y, 'mno ', 'screen:3')
else
App.screen.check(y, 'mn', 'screen:3')
end
end
function test_pagedown_never_moves_up()
@ -1796,10 +1803,10 @@ function test_position_cursor_on_recently_edited_wrapping_line()
y = y + Editor_state.line_height
App.screen.check(y, 'stu', 'baseline2/screen:3')
-- try to move the cursor earlier in the third screen line by clicking the mouse
edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+Editor_state.line_height*2+5, 1)
edit.run_after_mouse_release(Editor_state, Editor_state.left+2,Editor_state.top+Editor_state.line_height*2+5, 1)
-- cursor should move
check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
check_eq(Editor_state.cursor1.pos, 26, 'cursor:pos')
check_eq(Editor_state.cursor1.pos, 25, 'cursor:pos')
end
function test_backspace_can_scroll_up()

View File

@ -1116,7 +1116,14 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line()
y = y + Editor_state.line_height
App.screen.check(y, 'jkl ', 'screen:2')
y = y + Editor_state.line_height
App.screen.check(y, 'mn', 'screen:3')
if Version == '12.0' then
-- HACK: Maybe v12.0 uses a different font? Strange that it only causes
-- issues in a couple of places.
-- We'll need to rethink our tests if issues like this start to multiply.
App.screen.check(y, 'mno ', 'screen:3')
else
App.screen.check(y, 'mn', 'screen:3')
end
end
function test_pagedown_never_moves_up()
@ -1826,10 +1833,10 @@ function test_position_cursor_on_recently_edited_wrapping_line()
y = y + Editor_state.line_height
App.screen.check(y, 'stu', 'baseline2/screen:3')
-- try to move the cursor earlier in the third screen line by clicking the mouse
edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+Editor_state.line_height*2+5, 1)
edit.run_after_mouse_release(Editor_state, Editor_state.left+2,Editor_state.top+Editor_state.line_height*2+5, 1)
-- cursor should move
check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
check_eq(Editor_state.cursor1.pos, 26, 'cursor:pos')
check_eq(Editor_state.cursor1.pos, 25, 'cursor:pos')
end
function test_backspace_can_scroll_up()