about summary refs log tree commit diff stats
path: root/toot-toot.tlv
diff options
context:
space:
mode:
Diffstat (limited to 'toot-toot.tlv')
-rw-r--r--toot-toot.tlv45
1 files changed, 39 insertions, 6 deletions
diff --git a/toot-toot.tlv b/toot-toot.tlv
index 8d03654..66b0d9e 100644
--- a/toot-toot.tlv
+++ b/toot-toot.tlv
@@ -79,11 +79,11 @@
 - __teliva_timestamp: original
   check_eq:
     >function check_eq(x, expected, msg)
-    >  if x == expected then
+    >  if eq(x, expected) then
     >    Window:addch('.')
     >  else
     >    print('F - '..msg)
-    >    print('  expected '..tostring(expected)..' but got '..x)
+    >    print('  expected '..str(expected)..' but got '..str(x))
     >    teliva_num_test_failures = teliva_num_test_failures + 1
     >    -- overlay first test failure on editors
     >    if teliva_first_failure == nil then
@@ -92,6 +92,37 @@
     >  end
     >end
 - __teliva_timestamp: original
+  eq:
+    >function eq(a, b)
+    >  if type(a) ~= type(b) then return false end
+    >  if type(a) == 'table' then
+    >    if #a ~= #b then return false end
+    >    for k, v in pairs(a) do
+    >      if b[k] ~= v then
+    >        return false
+    >      end
+    >      return true
+    >    end
+    >  end
+    >  return a == b
+    >end
+- __teliva_timestamp: original
+  str:
+    >-- smarter tostring
+    >-- slow; used only for debugging
+    >function str(x)
+    >  if type(x) == 'table' then
+    >    local result = ''
+    >    result = result..#x..'{'
+    >    for k, v in pairs(x) do
+    >      result = result..str(k)..'='..str(v)..', '
+    >    end
+    >    result = result..'}'
+    >    return result
+    >  end
+    >  return tostring(x)
+    >end
+- __teliva_timestamp: original
   map:
     >-- only for arrays
     >function map(l, f)
@@ -147,16 +178,18 @@
     >  return result
     >end
 - __teliva_timestamp: original
-  Window:
-    >Window = curses.stdscr()
-    >curses.curs_set(0)  -- we'll simulate our own cursor
-- __teliva_timestamp: original
   menu:
+    >-- To show app-specific hotkeys in the menu bar, add hotkey/command
+    >-- arrays of strings to the menu array.
     >menu = {
     >  {'^k', 'clear'},
     >  {'^w', 'write prose to file "toot" (edit hotkey does NOT save)'},
     >}
 - __teliva_timestamp: original
+  Window:
+    >Window = curses.stdscr()
+    >curses.curs_set(0)  -- we'll simulate our own cursor
+- __teliva_timestamp: original
   main:
     >function main()
     >  init_colors()