From c511448b28a5b5c1e60ab87518f65245d169ae5b Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Sat, 17 Oct 2020 16:02:51 -0400 Subject: Added `textadept.run.set_arguments()`. This replaces custom code in *modules/textadept/menu.lua*. --- test/test.lua | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'test') 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 '/' -- cgit v1.2.3