diff options
author | 2020-10-17 16:02:51 -0400 | |
---|---|---|
committer | 2020-10-17 16:02:51 -0400 | |
commit | c511448b28a5b5c1e60ab87518f65245d169ae5b (patch) | |
tree | 6c0d4b904e22863ad2fe8dd3c55ff5d96cab835f /test | |
parent | 66bfb5b77b53ebfaea6c93be2be7504427098ee6 (diff) | |
download | textadept-c511448b28a5b5c1e60ab87518f65245d169ae5b.tar.gz textadept-c511448b28a5b5c1e60ab87518f65245d169ae5b.zip |
Added `textadept.run.set_arguments()`.
This replaces custom code in *modules/textadept/menu.lua*.
Diffstat (limited to 'test')
-rw-r--r-- | test/test.lua | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/test/test.lua b/test/test.lua index 30f22433..1505f2c2 100644 --- a/test/test.lua +++ b/test/test.lua @@ -2892,14 +2892,10 @@ end function test_menu_functions_interactive() buffer.new() - buffer.filename = '/tmp/test.lua' - textadept.menu.menubar[_L['Tools']][_L['Set Arguments...']][2]() textadept.menu.menubar[_L['Help']][_L['About']][2]() buffer:close(true) end --- TODO: test set arguments more thoroughly. - function test_menu_select_command_interactive() local num_buffers = #_BUFFERS textadept.menu.select_command() @@ -2971,6 +2967,37 @@ function test_run_compile_run() assert_raises(function() textadept.run.run({}) end, 'string/nil expected, got table') end +function test_run_set_arguments() + local lua_run_command = textadept.run.run_commands.lua + local lua_compile_command = textadept.run.compile_commands.lua + + buffer.new() + buffer.filename = '/tmp/test.lua' + textadept.run.set_arguments(nil, '-i', '-p') + assert_equal(textadept.run.run_commands[buffer.filename], lua_run_command .. ' -i') + assert_equal(textadept.run.compile_commands[buffer.filename], lua_compile_command .. ' -p') + textadept.run.set_arguments(buffer.filename, '', '') + assert_equal(textadept.run.run_commands[buffer.filename], lua_run_command .. ' ') + assert_equal(textadept.run.compile_commands[buffer.filename], lua_compile_command .. ' ') + buffer:close(true) + + assert_raises(function() textadept.run.set_arguments(1) end, 'string/nil expected, got number') + assert_raises(function() textadept.run.set_arguments('', true) end, 'string/nil expected, got boolean') + assert_raises(function() textadept.run.set_arguments('', '', {}) end, 'string/nil expected, got table') +end + +function test_run_set_arguments_interactive() + local lua_run_command = textadept.run.run_commands.lua + local lua_compile_command = textadept.run.compile_commands.lua + buffer.new() + buffer.filename = '/tmp/test.lua' + textadept.run.set_arguments(nil, '-i', '-p') + textadept.run.set_arguments() + assert_equal(textadept.run.run_commands[buffer.filename], lua_run_command .. ' -i') + assert_equal(textadept.run.compile_commands[buffer.filename], lua_compile_command .. ' -p') + buffer:close(true) +end + function test_run_build() textadept.run.build_commands[_HOME] = function() return 'lua modules/textadept/run/build.lua', _HOME .. '/test/' -- intentional trailing '/' |