all pending manual tests done!

This commit is contained in:
Kartik K. Agaram 2022-06-14 22:47:49 -07:00
parent b8d7774138
commit 21bd8281a7
2 changed files with 39 additions and 7 deletions

View File

@ -1,5 +1,7 @@
I care a lot about being able to automatically check _any_ property about my
program before it ever runs. However, some things don't have tests yet.
program before it ever runs. However, some things don't have tests yet, either
because I don't know how to test them or because I've been lazy. I'll at least
record those here.
### Compromises
@ -9,12 +11,8 @@ Lua is dynamically typed. Tests can't patch over lack of type-checking.
byte offsets as _offset, and character positions as _pos. For example,
string.sub should never use a _pos to substring, only an _offset.
### Todo list
undo:
deleting points
resize:
create a file containing a long line of characters without spaces. try
resizing the window vertically and horizontally, as far as possible.

View File

@ -586,7 +586,7 @@ function test_undo_name_point()
local p2 = drawing.points[drawing.shapes[1].p2]
check_eq(Next_history, 3, 'F - test_undo_name_point/next_history')
check_eq(p2.name, '', 'F - test_undo_name_point') -- not quite what it was before, but close enough
-- change is saved
-- undo is saved
Lines = load_from_disk(Filename)
local p2 = Lines[1].points[drawing.shapes[1].p2]
check_eq(p2.name, '', 'F - test_undo_name_point/save')
@ -632,9 +632,43 @@ function test_undo_move_point()
check_eq(Next_history, 2, 'F - test_undo_move_point/next_history')
check_eq(p2.x, 35, 'F - test_undo_move_point/x')
check_eq(p2.y, 36, 'F - test_undo_move_point/y')
-- change is saved
-- undo is saved
Lines = load_from_disk(Filename)
local p2 = Lines[1].points[drawing.shapes[1].p2]
check_eq(p2.x, 35, 'F - test_undo_move_point/save/x')
check_eq(p2.y, 36, 'F - test_undo_move_point/save/y')
end
function test_undo_delete_point()
io.write('\ntest_undo_delete_point')
-- create a drawing with two lines connected at a point
Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300}
Lines = load_array{'```lines', '```', ''}
Line_width = 256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line'
App.draw()
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)
App.run_after_mouse_release(Margin_left+35, Margin_top+Drawing_padding_top+36, 1)
App.run_after_mouse_press(Margin_left+35, Margin_top+Drawing_padding_top+36, 1)
App.run_after_mouse_release(Margin_left+55, Margin_top+Drawing_padding_top+26, 1)
local drawing = Lines[1]
check_eq(#drawing.shapes, 2, 'F - test_undo_delete_point/baseline/#shapes')
check_eq(drawing.shapes[1].mode, 'line', 'F - test_undo_delete_point/baseline/shape:1')
check_eq(drawing.shapes[2].mode, 'line', 'F - test_undo_delete_point/baseline/shape:2')
-- hover on the common point and delete
App.mouse_move(Margin_left+35, Margin_top+Drawing_padding_top+36)
App.run_after_keychord('C-d')
check_eq(drawing.shapes[1].mode, 'deleted', 'F - test_undo_delete_point/shape:1')
check_eq(drawing.shapes[2].mode, 'deleted', 'F - test_undo_delete_point/shape:2')
-- undo
App.run_after_keychord('C-z')
local drawing = Lines[1]
local p2 = drawing.points[drawing.shapes[1].p2]
check_eq(Next_history, 3, 'F - test_undo_move_point/next_history')
check_eq(drawing.shapes[1].mode, 'line', 'F - test_undo_delete_point/shape:1')
check_eq(drawing.shapes[2].mode, 'line', 'F - test_undo_delete_point/shape:2')
-- undo is saved
Lines = load_from_disk(Filename)
check_eq(#Lines[1].shapes, 2, 'F - test_undo_delete_point/save')
end