Last active
February 20, 2023 20:00
-
-
Save guyzmo/9ed8ec8cd54486cf6e97d4c8f2526a2e to your computer and use it in GitHub Desktop.
Testing the LUA get()/set() API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set visual=vim | |
set connect_timeout=69 | |
set arrow_cursor | |
set mask="!^\\.[^.]" | |
lua-source ./muttrc-type-test.lua | |
lua test_config_type("DT_STR ", "visual", "vim", "fubar") | |
lua test_config_type("DT_NUM ", "connect_timeout",69,42) | |
lua test_config_type("DT_BOOL ", "arrow_cursor", true, false) | |
lua test_config_type("DT_QUAD ", "abort_noattach", mutt.QUAD_NO, mutt.QUAD_ASKNO) | |
lua test_config_type("DT_PATH ", "alias_file", "./muttrc", "/home/guyzmo/.muttrc") | |
lua test_config_type("DT_MAGIC", "mbox_type", "mbox", "Maildir") | |
lua test_config_type("DT_SORT ", "sort", "from", "date") | |
lua test_config_type("DT_RX ", "mask", "!^\\\\.[^.]", ".*") | |
lua test_config_type("DT_MBCHARTBL", "to_chars", "+TCFL", "+T") | |
lua test_config_type("DT_ADDR ", "from", "fubar@example.org", "barfu@example.com") | |
lua test_config_type("DT_STR ", "my_fubar", "Ford Prefect", "Zaphod Beeblebrox") | |
####################################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function check(s, a, b); print("** " .. s .. " " .. ((a==b) and "✓" or "✗ FAILURE")) ; end | |
function test_config_type(tname, setting, a, b) | |
print("- TESTING " .. tname .. " -----------------------------------------------------") | |
print("** [" .. tname .. "] " .. setting .. " is set to: " .. tostring(mutt.get(setting))) | |
print("** [" .. tname .. "] setting " .. setting .. " to " .. tostring(b)) | |
a = mutt.get(setting) == a | |
mutt.set(setting, b) | |
b = mutt.get(setting) == b | |
print("** [" .. tname .. "] " .. setting .. " is set to: " .. tostring(mutt.get(setting))) | |
check("[" .. tname .. "]", a, b) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- TESTING DT_STR ----------------------------------------------------- | |
** [DT_STR ] visual is set to: vim | |
** [DT_STR ] setting visual to fubar | |
** [DT_STR ] visual is set to: fubar | |
** [DT_STR ] ✓ | |
- TESTING DT_NUM ----------------------------------------------------- | |
** [DT_NUM ] connect_timeout is set to: 69 | |
** [DT_NUM ] setting connect_timeout to 42 | |
** [DT_NUM ] connect_timeout is set to: 42 | |
** [DT_NUM ] ✓ | |
- TESTING DT_BOOL ----------------------------------------------------- | |
** [DT_BOOL ] arrow_cursor is set to: true | |
** [DT_BOOL ] setting arrow_cursor to false | |
** [DT_BOOL ] arrow_cursor is set to: false | |
** [DT_BOOL ] ✓ | |
- TESTING DT_QUAD ----------------------------------------------------- | |
** [DT_QUAD ] abort_noattach is set to: 0 | |
** [DT_QUAD ] setting abort_noattach to 2 | |
** [DT_QUAD ] abort_noattach is set to: 2 | |
** [DT_QUAD ] ✓ | |
- TESTING DT_PATH ----------------------------------------------------- | |
** [DT_PATH ] alias_file is set to: ./muttrc | |
** [DT_PATH ] setting alias_file to /home/guyzmo/.muttrc | |
** [DT_PATH ] alias_file is set to: /home/guyzmo/.muttrc | |
** [DT_PATH ] ✓ | |
- TESTING DT_MAGIC ----------------------------------------------------- | |
** [DT_MAGIC] mbox_type is set to: mbox | |
** [DT_MAGIC] setting mbox_type to Maildir | |
** [DT_MAGIC] mbox_type is set to: Maildir | |
** [DT_MAGIC] ✓ | |
- TESTING DT_SORT ----------------------------------------------------- | |
** [DT_SORT ] sort is set to: from | |
** [DT_SORT ] setting sort to date | |
** [DT_SORT ] sort is set to: date | |
** [DT_SORT ] ✓ | |
- TESTING DT_RX ----------------------------------------------------- | |
** [DT_RX ] mask is set to: !^\\.[^.] | |
** [DT_RX ] setting mask to .* | |
** [DT_RX ] mask is set to: .* | |
** [DT_RX ] ✓ | |
- TESTING DT_MBCHARTBL ----------------------------------------------------- | |
** [DT_MBCHARTBL] to_chars is set to: +TCFL | |
** [DT_MBCHARTBL] setting to_chars to +T | |
** [DT_MBCHARTBL] to_chars is set to: +T | |
** [DT_MBCHARTBL] ✓ | |
- TESTING DT_ADDR ----------------------------------------------------- | |
** [DT_ADDR ] from is set to: fubar@example.org | |
** [DT_ADDR ] setting from to barfu@example.com | |
** [DT_ADDR ] from is set to: barfu@example.com | |
** [DT_ADDR ] ✓ | |
- TESTING DT_STR ----------------------------------------------------- | |
** [DT_STR ] my_fubar is set to: Ford Prefect | |
** [DT_STR ] setting my_fubar to Zaphod Beeblebrox | |
** [DT_STR ] my_fubar is set to: Zaphod Beeblebrox | |
** [DT_STR ] ✓ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment