mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	test: format
This commit is contained in:
		
				
					committed by
					
						
						Justin M. Keyes
					
				
			
			
				
	
			
			
			
						parent
						
							4a200ceafa
						
					
				
				
					commit
					c4117d4b2f
				
			@@ -64,153 +64,137 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
 | 
				
			|||||||
        args = args..', "RpcCommand"'
 | 
					        args = args..', "RpcCommand"'
 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('without options', function()
 | 
					      it('without options', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {}')
 | 
				
			||||||
          call(fn, args..', {}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('RpcCommand')
 | 
				
			||||||
            command('RpcCommand')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method)
 | 
					        local function handler(method)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with nargs', function()
 | 
					      it('with nargs', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {"nargs": "*"}')
 | 
				
			||||||
          call(fn, args..', {"nargs": "*"}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('RpcCommand arg1 arg2 arg3')
 | 
				
			||||||
            command('RpcCommand arg1 arg2 arg3')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({'arg1', 'arg2', 'arg3'}, arguments[1])
 | 
					          eq({'arg1', 'arg2', 'arg3'}, arguments[1])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with range', function()
 | 
					      it('with range', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn,args..', {"range": ""}')
 | 
				
			||||||
          call(fn,args..', {"range": ""}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('1,1RpcCommand')
 | 
				
			||||||
            command('1,1RpcCommand')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({1, 1}, arguments[1])
 | 
					          eq({1, 1}, arguments[1])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with nargs/range', function()
 | 
					      it('with nargs/range', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {"nargs": "1", "range": ""}')
 | 
				
			||||||
          call(fn, args..', {"nargs": "1", "range": ""}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('1,1RpcCommand arg')
 | 
				
			||||||
            command('1,1RpcCommand arg')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({'arg'}, arguments[1])
 | 
					          eq({'arg'}, arguments[1])
 | 
				
			||||||
            eq({1, 1}, arguments[2])
 | 
					          eq({1, 1}, arguments[2])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with nargs/count', function()
 | 
					      it('with nargs/count', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {"nargs": "1", "range": "5"}')
 | 
				
			||||||
          call(fn, args..', {"nargs": "1", "range": "5"}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('5RpcCommand arg')
 | 
				
			||||||
            command('5RpcCommand arg')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({'arg'}, arguments[1])
 | 
					          eq({'arg'}, arguments[1])
 | 
				
			||||||
            eq(5, arguments[2])
 | 
					          eq(5, arguments[2])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with nargs/count/bang', function()
 | 
					      it('with nargs/count/bang', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {"nargs": "1", "range": "5", "bang": ""}')
 | 
				
			||||||
          call(fn, args..', {"nargs": "1", "range": "5", "bang": ""}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('5RpcCommand! arg')
 | 
				
			||||||
            command('5RpcCommand! arg')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({'arg'}, arguments[1])
 | 
					          eq({'arg'}, arguments[1])
 | 
				
			||||||
            eq(5, arguments[2])
 | 
					          eq(5, arguments[2])
 | 
				
			||||||
            eq(1, arguments[3])
 | 
					          eq(1, arguments[3])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with nargs/count/bang/register', function()
 | 
					      it('with nargs/count/bang/register', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {"nargs": "1", "range": "5", "bang": "",'..
 | 
				
			||||||
          call(fn, args..', {"nargs": "1", "range": "5", "bang": "",'..
 | 
					        ' "register": ""}')
 | 
				
			||||||
                     ' "register": ""}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('5RpcCommand! b arg')
 | 
				
			||||||
            command('5RpcCommand! b arg')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({'arg'}, arguments[1])
 | 
					          eq({'arg'}, arguments[1])
 | 
				
			||||||
            eq(5, arguments[2])
 | 
					          eq(5, arguments[2])
 | 
				
			||||||
            eq(1, arguments[3])
 | 
					          eq(1, arguments[3])
 | 
				
			||||||
            eq('b', arguments[4])
 | 
					          eq('b', arguments[4])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with nargs/count/bang/register/eval', function()
 | 
					      it('with nargs/count/bang/register/eval', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {"nargs": "1", "range": "5", "bang": "",'..
 | 
				
			||||||
          call(fn, args..', {"nargs": "1", "range": "5", "bang": "",'..
 | 
					        ' "register": "", "eval": "@<reg>"}')
 | 
				
			||||||
                     ' "register": "", "eval": "@<reg>"}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('let @b = "regb"')
 | 
				
			||||||
            command('let @b = "regb"')
 | 
					          command('5RpcCommand! b arg')
 | 
				
			||||||
            command('5RpcCommand! b arg')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({'arg'}, arguments[1])
 | 
					          eq({'arg'}, arguments[1])
 | 
				
			||||||
            eq(5, arguments[2])
 | 
					          eq(5, arguments[2])
 | 
				
			||||||
            eq(1, arguments[3])
 | 
					          eq(1, arguments[3])
 | 
				
			||||||
            eq('b', arguments[4])
 | 
					          eq('b', arguments[4])
 | 
				
			||||||
            eq('regb', arguments[5])
 | 
					          eq('regb', arguments[5])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
    end)
 | 
					    end)
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
@@ -236,37 +220,33 @@ local function autocmd_specs_for(fn, sync, first_arg_factory, init)
 | 
				
			|||||||
        args = args..', "BufEnter"'
 | 
					        args = args..', "BufEnter"'
 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('without options', function()
 | 
					      it('without options', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {}')
 | 
				
			||||||
          call(fn, args..', {}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('doautocmd BufEnter x.c')
 | 
				
			||||||
            command('doautocmd BufEnter x.c')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method)
 | 
					        local function handler(method)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with eval', function()
 | 
					      it('with eval', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..[[, {'eval': 'expand("<afile>")'}]])
 | 
				
			||||||
          call(fn, args..[[, {'eval': 'expand("<afile>")'}]])
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('doautocmd BufEnter x.c')
 | 
				
			||||||
            command('doautocmd BufEnter x.c')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq('x.c', arguments[1])
 | 
					          eq('x.c', arguments[1])
 | 
				
			||||||
            return ''
 | 
					          return ''
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
    end)
 | 
					    end)
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
@@ -292,79 +272,72 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
 | 
				
			|||||||
        args = args..', "TestFunction"'
 | 
					        args = args..', "TestFunction"'
 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('without options', function()
 | 
					      it('without options', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..', {}')
 | 
				
			||||||
          call(fn, args..', {}')
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          if sync then
 | 
				
			||||||
            if sync then
 | 
					            eq('rv', eval('TestFunction(1, "a", ["b", "c"])'))
 | 
				
			||||||
              eq('rv', eval('TestFunction(1, "a", ["b", "c"])'))
 | 
					          else
 | 
				
			||||||
            else
 | 
					            eq(1, eval('TestFunction(1, "a", ["b", "c"])'))
 | 
				
			||||||
              eq(1, eval('TestFunction(1, "a", ["b", "c"])'))
 | 
					 | 
				
			||||||
            end
 | 
					 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({{1, 'a', {'b', 'c'}}}, arguments)
 | 
					          eq({{1, 'a', {'b', 'c'}}}, arguments)
 | 
				
			||||||
            return 'rv'
 | 
					          return 'rv'
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with eval', function()
 | 
					      it('with eval', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..[[, {'eval': '2 + 2'}]])
 | 
				
			||||||
          call(fn, args..[[, {'eval': '2 + 2'}]])
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          if sync then
 | 
				
			||||||
            if sync then
 | 
					            eq('rv', eval('TestFunction(1, "a", ["b", "c"])'))
 | 
				
			||||||
              eq('rv', eval('TestFunction(1, "a", ["b", "c"])'))
 | 
					          else
 | 
				
			||||||
            else
 | 
					            eq(1, eval('TestFunction(1, "a", ["b", "c"])'))
 | 
				
			||||||
              eq(1, eval('TestFunction(1, "a", ["b", "c"])'))
 | 
					 | 
				
			||||||
            end
 | 
					 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({{1, 'a', {'b', 'c'}}, 4}, arguments)
 | 
					          eq({{1, 'a', {'b', 'c'}}, 4}, arguments)
 | 
				
			||||||
            return 'rv'
 | 
					          return 'rv'
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      describe('with range', function()
 | 
					      it('with range', function()
 | 
				
			||||||
        it('ok', function()
 | 
					        call(fn, args..[[, {'range': ''}]])
 | 
				
			||||||
          call(fn, args..[[, {'range': ''}]])
 | 
					        local function on_setup()
 | 
				
			||||||
          local function on_setup()
 | 
					          command('%call TestFunction(1, "a", ["b", "c"])')
 | 
				
			||||||
            command('%call TestFunction(1, "a", ["b", "c"])')
 | 
					        end
 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
            eq('test-handler', method)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
            eq({{1, 'a', {'b', 'c'}}, {1, 1}}, arguments)
 | 
					          eq({{1, 'a', {'b', 'c'}}, {1, 1}}, arguments)
 | 
				
			||||||
            return 'rv'
 | 
					          return 'rv'
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
        end)
 | 
					 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
      describe('with eval/range', function()
 | 
					 | 
				
			||||||
        it('ok', function()
 | 
					 | 
				
			||||||
          call(fn, args..[[, {'eval': '4', 'range': ''}]])
 | 
					 | 
				
			||||||
          local function on_setup()
 | 
					 | 
				
			||||||
            command('%call TestFunction(1, "a", ["b", "c"])')
 | 
					 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
          local function handler(method, arguments)
 | 
					      it('with eval/range', function()
 | 
				
			||||||
            eq('test-handler', method)
 | 
					        call(fn, args..[[, {'eval': '4', 'range': ''}]])
 | 
				
			||||||
            eq({{1, 'a', {'b', 'c'}}, {1, 1}, 4}, arguments)
 | 
					        local function on_setup()
 | 
				
			||||||
            return 'rv'
 | 
					          command('%call TestFunction(1, "a", ["b", "c"])')
 | 
				
			||||||
          end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          runx(sync, handler, on_setup)
 | 
					        local function handler(method, arguments)
 | 
				
			||||||
        end)
 | 
					          eq('test-handler', method)
 | 
				
			||||||
 | 
					          eq({{1, 'a', {'b', 'c'}}, {1, 1}, 4}, arguments)
 | 
				
			||||||
 | 
					          return 'rv'
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        runx(sync, handler, on_setup)
 | 
				
			||||||
      end)
 | 
					      end)
 | 
				
			||||||
    end)
 | 
					    end)
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user