diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-10-09 20:25:08 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-10-09 20:25:08 -0700 |
commit | 69d86cae5ba5672e7020243d0f78f0ea6355fd8f (patch) | |
tree | 62d88bdf6839c96ec3aac323b497a581ab1f4f94 | |
parent | 6e391d7875158a9351eae9976067671a0ef5ad0e (diff) | |
download | view.love-69d86cae5ba5672e7020243d0f78f0ea6355fd8f.tar.gz |
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).
-rw-r--r-- | source_text_tests.lua | 13 | ||||
-rw-r--r-- | text_tests.lua | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/source_text_tests.lua b/source_text_tests.lua index 2dc3adb..0b45232 100644 --- a/source_text_tests.lua +++ b/source_text_tests.lua @@ -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() diff --git a/text_tests.lua b/text_tests.lua index bee6c31..41fe2df 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -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() |