From 37f1313b16971200f56552dbbf8c2b0b2b65417e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 23 May 2022 08:13:58 -0700 Subject: first successful pagedown test, first bug found by test I also really need to rethink how people debug my programs. My approach of inserting and deleting print() takes a lot of commitment. I need my old trace-based whitebox testing idea. However, in my past projects I never did figure out a good framework for tweaking how verbose a trace to emit. Perhaps that's too many knobs. Perhaps we just need a way to run a single test with the most verbose trace possible. Then it's just a matter of having the trace tell a coherent story? But even if the trace stays out of program output in that situation, it's still in the programmer's face in the _code_. Ugh. Current plan: ship program with maximum tests and zero commented-out prints. If you want to debug, insert prints. This is better than previous, text-mode, projects just by virtue of the stdout channel being dedicated to debug stuff. --- main.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 8faca1c..e72a875 100644 --- a/main.lua +++ b/main.lua @@ -81,7 +81,7 @@ Zoom = 1.5 Filename = love.filesystem.getUserDirectory()..'/lines.txt' -New_foo = true +Debug_main = false if #arg > 0 then Filename = arg[1] @@ -120,9 +120,9 @@ function App.draw() line.y = nil end local y = 15 - if New_foo then print('== draw') end + if Debug_main then print('== draw') end for line_index,line in ipairs(Lines) do - if New_foo then print('draw:', line_index, y) end + if Debug_main then print('draw:', line_index, y) end if y + math.floor(15*Zoom) > App.screen.height then break end if line_index >= Screen_top1.line then Screen_bottom1.line = line_index @@ -146,15 +146,15 @@ function App.draw() Drawing.draw(line) y = y + Drawing.pixels(line.h) + 10 -- padding else - if New_foo then print('text') end + if Debug_main then print('text') end line.y = y y, Screen_bottom1.pos = Text.draw(line, Line_width, line_index) y = y + math.floor(15*Zoom) -- text height - if New_foo then print('aa', y) end + if Debug_main then print('aa', y) end end end end - New_foo = false + Debug_main = false --? print('screen bottom: '..tostring(Screen_bottom1.pos)..' in '..tostring(Lines[Screen_bottom1.line].data)) --? os.exit(1) end @@ -195,7 +195,7 @@ function App.textinput(t) end function App.keychord_pressed(chord) - New_foo = true +--? Debug_main = true if love.mouse.isDown('1') or chord:sub(1,2) == 'C-' then Drawing.keychord_pressed(chord) elseif chord == 'escape' and love.mouse.isDown('1') then @@ -226,6 +226,7 @@ function App.keychord_pressed(chord) end save_to_disk(Lines, Filename) elseif chord == 'pagedown' then + print('setting top to', Screen_bottom1.line) Screen_top1.line = Screen_bottom1.line Screen_top1.pos = Screen_bottom1.pos Cursor1.line = Screen_top1.line -- cgit 1.4.1-2-gfad0