test: improve test conventions

Specifically, functions that are run in the context of the test runner
are put in module `test/testutil.lua` while the functions that are run
in the context of the test session are put in
`test/functional/testnvim.lua`.

Closes https://github.com/neovim/neovim/issues/27004.
This commit is contained in:
dundargoc 2024-04-20 17:44:13 +02:00 committed by dundargoc
parent c5af5c0b9a
commit 052498ed42
444 changed files with 3459 additions and 3131 deletions

View File

@ -87,9 +87,8 @@ Then, in another terminal:
>bash
gdb build/bin/nvim
target remote localhost:7777
<
- See also test/functional/testutil.lua https://github.com/neovim/neovim/blob/3098b18a2b63a841351f6d5e3697cb69db3035ef/test/functional/testutil.lua#L38-L44.
-- See `nvim_argv` in https://github.com/neovim/neovim/blob/master/test/functional/testnvim.lua.
USING LLDB TO STEP THROUGH UNIT TESTS ~

View File

@ -1,300 +0,0 @@
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use autodie;
use File::Basename;
use File::Spec::Functions;
sub read_in_file {
my $in_file = $_[0];
# Will contain lines before first STARTTEST
# as Lua comments.
my @description_lines = ();
# Will contain alternating blocks of lines of textual input
# (text between ENDTEST and EOF/next STARTTEST) and test commands
# (commands between STARTTEST and ENDTEST) as Lua code.
my @test_body_lines = ();
# Will contain current command block, i.e. lines
# between STARTTEST and ENDTEST.
my @command_lines = ();
# Will contain current input block, i.e. lines
# between ENDTEST and STARTTEST.
my @input_lines = ();
open my $in_file_handle, '<', $in_file;
use constant EMIT_DESCRIPTION => 0;
use constant EMIT_COMMAND => 1;
use constant EMIT_INPUT => 2;
# Push lines from current input and
# command blocks into @test_body_lines
# in the correct order.
sub end_input {
my $input_lines = $_[0];
my $command_lines = $_[1];
my $test_body_lines = $_[2];
# If there are input lines, wrap with an `insert`
# command and add before the previous command block.
if (@{$input_lines}) {
my $last_input_line = pop @{$input_lines};
unshift @{$command_lines}, '';
unshift @{$command_lines}, $last_input_line . ']=])';
unshift @{$command_lines}, @{$input_lines};
unshift @{$command_lines}, "insert([=[";
@{$input_lines} = ();
}
# Output remaining command lines.
push @{$test_body_lines}, @{$command_lines};
@{$command_lines} = ();
}
sub format_comment {
# Handle empty comments.
if (/^$/) {
return '';
}
# Capitalize first character and emit as Lua comment.
my $comment = '-- ' . ucfirst $_;
# Add trailing dot if not already there.
$comment .= '.' unless $comment =~ /\.$/;
return $comment;
}
my %states = (
# Add test description to @description_lines.
EMIT_DESCRIPTION() => sub {
if (/^STARTTEST/) {
return EMIT_COMMAND;
}
# If not an empty line, emit as Lua comment.
if (!/^$/) {
# Remove modeline
s/vim:.*set f\w+=vim//g;
# Remove trailing ":"
s/\s*:\s*$//g;
push @description_lines, '-- ' . $_;
}
return EMIT_DESCRIPTION;
},
# Add test commands to @command_lines.
EMIT_COMMAND() => sub {
if (/^ENDTEST/) {
return EMIT_INPUT;
}
# If line starts with ':"', emit a comment.
if (/^:"/) {
# Remove Vim comment prefix.
s/^:"\s*//;
push @command_lines, format_comment $_;
return EMIT_COMMAND;
}
# Extract possible inline comment.
if (/^[^"]*"[^"]*$/) {
# Remove command part and prepended whitespace.
s/^(.*?)\s*"\s*//;
push @command_lines, format_comment $_;
# Set implicit variable to command without comment.
$_ = $1;
}
# Only continue if remaining command is not empty.
if (!/^:?\s*$/) {
# Replace terminal escape characters with <esc>.
s/\e/<esc>/g;
my $startstr = "'";
my $endstr = "'";
# If line contains single quotes or backslashes, use double
# square brackets to wrap string.
if (/'/ || /\\/) {
# If the line contains a closing square bracket,
# wrap it with [=[...]=].
if (/\]/) {
$startstr = '[=[';
$endstr = ']=]';
} else {
$startstr = '[[';
$endstr = ']]';
}
}
# Emit 'feed' if not a search ('/') or ex (':') command.
if (!/^\// && !/^:/) {
# If command does not end with <esc>, insert trailing <cr>.
my $command = 'feed(' . $startstr . $_;
$command .= '<cr>' unless /<esc>$/;
$command .= $endstr . ')';
push @command_lines, $command;
} else {
# Remove prepending ':'.
s/^://;
push @command_lines, 'execute(' . $startstr . $_ . $endstr . ')';
}
}
return EMIT_COMMAND;
},
# Add input to @input_lines.
EMIT_INPUT() => sub {
if (/^STARTTEST/) {
end_input \@input_lines, \@command_lines, \@test_body_lines;
return EMIT_COMMAND;
}
# Skip initial lines if they are empty.
if (@input_lines or !/^$/) {
push @input_lines, ' ' . $_;
}
return EMIT_INPUT;
},
);
my $state = EMIT_DESCRIPTION;
while (<$in_file_handle>) {
# Remove trailing newline character and process line.
chomp;
$state = $states{$state}->($_);
}
# If not all lines have been processed yet,
# do it now.
end_input \@input_lines, \@command_lines, \@test_body_lines;
close $in_file_handle;
return (\@description_lines, \@test_body_lines);
}
sub read_ok_file {
my $ok_file = $_[0];
my @assertions = ();
if (-f $ok_file) {
push @assertions, '';
push @assertions, "-- Assert buffer contents.";
push @assertions, "expect([=[";
open my $ok_file_handle, '<', $ok_file;
while (<$ok_file_handle>) {
# Remove trailing newline character and process line.
chomp;
push @assertions, ' ' . $_;
}
close $ok_file_handle;
$assertions[-1] .= "]=])";
}
return \@assertions;
}
my $legacy_testfile = $ARGV[0];
my $out_dir = $ARGV[1];
if ($#ARGV != 1) {
say "Convert a legacy Vim test to a Neovim lua spec.";
say '';
say "Usage: $0 legacy-testfile output-directory";
say '';
say "legacy-testfile: Path to .in or .ok file.";
say "output-directory: Directory where Lua spec will be saved to.";
say '';
say "Note: Only works reliably for fairly simple tests.";
say " Manual adjustments to generated spec files are required.";
exit 1;
}
my @legacy_suffixes = ('.in', '.ok');
my ($base_name, $base_path, $suffix) = fileparse($legacy_testfile, @legacy_suffixes);
my $in_file = catfile($base_path, $base_name . '.in');
my $ok_file = catfile($base_path, $base_name . '.ok');
# Remove leading 'test'.
my $test_name = $base_name;
$test_name =~ s/^test_?//;
my $spec_file = do {
if ($test_name =~ /^([0-9]+)/) {
catfile($out_dir, sprintf('%03d', $1) . '_spec.lua')
} else {
catfile($out_dir, $test_name . '_spec.lua')
}
};
if (! -f $in_file) {
say "Test input file $in_file not found.";
exit 2;
}
if (! -d $out_dir) {
say "Output directory $out_dir does not exist.";
exit 3;
}
if (-f $spec_file) {
say "Output file $spec_file already exists.";
print "Overwrite (Y/n)? ";
my $input = <STDIN>;
chomp($input);
unless ($input =~ /^y|Y/) {
say "Aborting.";
exit 4;
}
}
# Read .in and .ok files.
my ($description_lines, $test_body_lines) = read_in_file $in_file;
my $assertion_lines = read_ok_file $ok_file;
# Append assertions to test body.
push @{$test_body_lines}, @{$assertion_lines} if @{$assertion_lines};
# Write spec file.
open my $spec_file_handle, ">", $spec_file;
print $spec_file_handle <<"EOS";
@{[join "\n", @{$description_lines}]}
local t = require('test.functional.testutil')
local feed, insert, source = t.feed, t.insert, t.source
local clear, execute, expect = t.clear, t.execute, t.expect
describe('$test_name', function()
before_each(clear)
it('is working', function()
@{[join "\n", map { /^$/ ? '' : ' ' . $_ } @{$test_body_lines}]}
end)
end)
EOS
close $spec_file_handle;
say "Written to $spec_file."

View File

@ -37,6 +37,7 @@ Layout
- `/test/benchmark` : benchmarks
- `/test/functional` : functional tests
- `/test/unit` : unit tests
- `/test/old/testdir` : old tests (from Vim)
- `/test/config` : contains `*.in` files which are transformed into `*.lua`
files using `configure_file` CMake command: this is for accessing CMake
variables in lua tests.
@ -44,11 +45,13 @@ Layout
parser: normally used to make macros not accessible via this mechanism
accessible the other way.
- `/test/*/preload.lua` : modules preloaded by busted `--helper` option
- `/test/**/testutil.lua` : common utility functions for test code
- `/test/**/testutil.lua` : common utility functions in the context of the test
runner
- `/test/**/testnvim.lua` : common utility functions in the context of the
test session (RPC channel to the Nvim child process created by clear() for each test)
- `/test/*/**/*_spec.lua` : actual tests. Files that do not end with
`_spec.lua` are libraries like `/test/**/testutil.lua`, except that they have
some common topic.
- `/test/old/testdir` : old tests (from Vim)
Running tests
@ -119,7 +122,7 @@ Debugging tests
If `$VALGRIND` is also set it will pass `--vgdb=yes` to valgrind instead of
starting gdbserver directly.
See [test/functional/testutil.lua](https://github.com/neovim/neovim/blob/9cadbf1d36b63f53f0de48c8c5ff6c752ff05d70/test/functional/testutil.lua#L52-L69) for details.
See `nvim_argv` in https://github.com/neovim/neovim/blob/master/test/functional/testnvim.lua.
- Hanging tests can happen due to unexpected "press-enter" prompts. The
default screen width is 50 columns. Commands that try to print lines longer
@ -297,7 +300,7 @@ Number; !must be defined to function properly):
- `VALGRIND` (F) (D): makes nvim instances to be run under `valgrind`. Log
files are named `valgrind-%p.log` in this case. Note that non-empty valgrind
log may fail tests. Valgrind arguments may be seen in
`/test/functional/testutil.lua`. May be used in conjunction with `GDB`.
`/test/functional/testnvim.lua`. May be used in conjunction with `GDB`.
- `VALGRIND_LOG` (F) (S): overrides valgrind log file name used for `VALGRIND`.

View File

@ -1,7 +1,7 @@
local t = require('test.functional.testutil')()
local n = require('test.functional.testnvim')()
local clear = t.clear
local exec_lua = t.exec_lua
local clear = n.clear
local exec_lua = n.exec_lua
local N = 7500

View File

@ -1,8 +1,9 @@
-- Test for benchmarking the RE engine.
local t = require('test.functional.testutil')()
local insert, source = t.insert, t.source
local clear, command = t.clear, t.command
local n = require('test.functional.testnvim')()
local insert, source = n.insert, n.source
local clear, command = n.clear, n.command
-- Temporary file for gathering benchmarking results for each regexp engine.
local result_file = 'benchmark.out'

View File

@ -1,4 +1,4 @@
-- Modules loaded here will not be cleared and reloaded by Busted.
-- Busted started doing this to help provide more isolation. See issue #62
-- for more information about this.
local t = require('test.functional.testutil')
local n = require('test.functional.testnvim')

View File

@ -1,7 +1,9 @@
local t = require('test.functional.testutil')()
local api = t.api
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local api = n.api
local function rand_utf8(count, seed)
math.randomseed(seed)
local symbols = { 'i', 'À', '', '𐀀' }
@ -119,7 +121,7 @@ end
local function benchmarks(benchmark_results)
describe('screenpos() perf', function()
before_each(t.clear)
before_each(n.clear)
-- no breakindent
for li, lines_type in ipairs(benchmark_lines) do
@ -134,7 +136,7 @@ local function benchmarks(benchmark_results)
screen:attach()
api.nvim_buf_set_lines(0, 0, 1, false, lines)
-- for smaller screen expect (last line always different, first line same as others)
t.feed('G$')
n.feed('G$')
screen:expect(result.screen)
benchmark(lines, result.value)
end)
@ -153,9 +155,9 @@ local function benchmarks(benchmark_results)
local screen = Screen.new(width, height + 1)
screen:attach()
api.nvim_buf_set_lines(0, 0, 1, false, lines)
t.command('set breakindent')
n.command('set breakindent')
-- for smaller screen expect (last line always different, first line same as others)
t.feed('G$')
n.feed('G$')
screen:expect(result.screen)
benchmark(lines, result.value)
end)

View File

@ -1,7 +1,7 @@
local t = require('test.functional.testutil')()
local n = require('test.functional.testnvim')()
local clear = t.clear
local exec_lua = t.exec_lua
local clear = n.clear
local exec_lua = n.exec_lua
describe('treesitter perf', function()
setup(function()
@ -9,7 +9,7 @@ describe('treesitter perf', function()
end)
it('can handle large folds', function()
t.command 'edit ./src/nvim/eval.c'
n.command 'edit ./src/nvim/eval.c'
exec_lua [[
local parser = vim.treesitter.get_parser(0, "c", {})
vim.treesitter.highlighter.new(parser)

View File

@ -1,13 +1,14 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local neq = t.neq
local exec_lua = t.exec_lua
local exec_lua = n.exec_lua
local matches = t.matches
local api = t.api
local source = t.source
local api = n.api
local source = n.source
local pcall_err = t.pcall_err
before_each(clear)

View File

@ -1,21 +1,23 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local clear = n.clear
local eq = t.eq
local ok = t.ok
local describe_lua_and_rpc = t.describe_lua_and_rpc(describe)
local api = t.api
local fn = t.fn
local request = t.request
local exc_exec = t.exc_exec
local exec_lua = t.exec_lua
local feed_command = t.feed_command
local insert = t.insert
local describe_lua_and_rpc = n.describe_lua_and_rpc(describe)
local api = n.api
local fn = n.fn
local request = n.request
local exc_exec = n.exc_exec
local exec_lua = n.exec_lua
local feed_command = n.feed_command
local insert = n.insert
local NIL = vim.NIL
local command = t.command
local feed = t.feed
local command = n.command
local feed = n.feed
local pcall_err = t.pcall_err
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
describe('api/buf', function()
before_each(clear)
@ -2066,7 +2068,7 @@ describe('api/buf', function()
end)
after_each(function()
t.rmdir(topdir .. '/Xacd')
n.rmdir(topdir .. '/Xacd')
end)
it('does not change cwd with non-current buffer', function()

View File

@ -1,10 +1,12 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local eq, ok = t.eq, t.ok
local fn = t.fn
local api = t.api
local command, eval, next_msg = t.command, t.eval, t.next_msg
local nvim_prog = t.nvim_prog
local fn = n.fn
local api = n.api
local command, eval, next_msg = n.command, n.eval, n.next_msg
local nvim_prog = n.nvim_prog
local pcall_err = t.pcall_err
local sleep = vim.uv.sleep
local write_file = t.write_file
@ -511,11 +513,11 @@ describe('API: buffer events:', function()
-- create several new sessions, in addition to our main API
local sessions = {}
local pipe = t.new_pipename()
local pipe = n.new_pipename()
eval("serverstart('" .. pipe .. "')")
sessions[1] = t.connect(pipe)
sessions[2] = t.connect(pipe)
sessions[3] = t.connect(pipe)
sessions[1] = n.connect(pipe)
sessions[2] = n.connect(pipe)
sessions[3] = n.connect(pipe)
local function request(sessionnr, method, ...)
local status, rv = sessions[sessionnr]:request(method, ...)
@ -814,7 +816,7 @@ describe('API: buffer events:', function()
clear()
sleep(250)
-- response
eq(true, t.request('nvim_buf_attach', 0, false, {}))
eq(true, n.request('nvim_buf_attach', 0, false, {}))
-- notification
eq({
[1] = 'notification',

View File

@ -1,17 +1,18 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local NIL = vim.NIL
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local api = t.api
local api = n.api
local matches = t.matches
local source = t.source
local source = n.source
local pcall_err = t.pcall_err
local exec_lua = t.exec_lua
local assert_alive = t.assert_alive
local feed = t.feed
local fn = t.fn
local exec_lua = n.exec_lua
local assert_alive = n.assert_alive
local feed = n.feed
local fn = n.fn
describe('nvim_get_commands', function()
local cmd_dict = {

View File

@ -1,20 +1,21 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local request = t.request
local request = n.request
local eq = t.eq
local ok = t.ok
local pcall_err = t.pcall_err
local insert = t.insert
local feed = t.feed
local clear = t.clear
local command = t.command
local exec = t.exec
local api = t.api
local assert_alive = t.assert_alive
local insert = n.insert
local feed = n.feed
local clear = n.clear
local command = n.command
local exec = n.exec
local api = n.api
local assert_alive = n.assert_alive
local function expect(contents)
return eq(contents, t.curbuf_contents())
return eq(contents, n.curbuf_contents())
end
local function set_extmark(ns_id, id, line, col, opts)

View File

@ -1,14 +1,16 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local eq, eval = t.eq, t.eval
local command = t.command
local exec_capture = t.exec_capture
local api = t.api
local fn = t.fn
local clear = n.clear
local eq, eval = t.eq, n.eval
local command = n.command
local exec_capture = n.exec_capture
local api = n.api
local fn = n.fn
local pcall_err = t.pcall_err
local ok = t.ok
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
describe('API: highlight', function()
clear()

View File

@ -1,15 +1,16 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq, neq = t.eq, t.neq
local exec_lua = t.exec_lua
local exec = t.exec
local feed = t.feed
local fn = t.fn
local api = t.api
local exec_lua = n.exec_lua
local exec = n.exec
local feed = n.feed
local fn = n.fn
local api = n.api
local matches = t.matches
local source = t.source
local source = n.source
local pcall_err = t.pcall_err
local shallowcopy = t.shallowcopy
@ -1146,7 +1147,7 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('asdf\n')
eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', t.exec_capture('nmap asdf'))
eq('\nNo mapping found', n.exec_capture('nmap asdf'))
end)
it('no double-free when unmapping simplifiable lua mappings', function()
@ -1170,13 +1171,13 @@ describe('nvim_set_keymap, nvim_del_keymap', function()
feed('<C-I>\n')
eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', t.exec_capture('nmap <C-I>'))
eq('\nNo mapping found', n.exec_capture('nmap <C-I>'))
end)
it('can set descriptions on mappings', function()
api.nvim_set_keymap('n', 'lhs', 'rhs', { desc = 'map description' })
eq(generate_mapargs('n', 'lhs', 'rhs', { desc = 'map description' }), get_mapargs('n', 'lhs'))
eq('\nn lhs rhs\n map description', t.exec_capture('nmap lhs'))
eq('\nn lhs rhs\n map description', n.exec_capture('nmap lhs'))
end)
it('can define !-mode abbreviations with lua callbacks', function()
@ -1331,7 +1332,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
it('does not crash when setting mapping in a non-existing buffer #13541', function()
pcall_err(api.nvim_buf_set_keymap, 100, '', 'lsh', 'irhs<Esc>', {})
t.assert_alive()
n.assert_alive()
end)
it('can make lua mappings', function()
@ -1426,7 +1427,7 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('asdf\n')
eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', t.exec_capture('nmap asdf'))
eq('\nNo mapping found', n.exec_capture('nmap asdf'))
end)
it('no double-free when unmapping simplifiable lua mappings', function()
@ -1450,6 +1451,6 @@ describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function()
feed('<C-I>\n')
eq(1, exec_lua [[return GlobalCount]])
eq('\nNo mapping found', t.exec_capture('nmap <C-I>'))
eq('\nNo mapping found', n.exec_capture('nmap <C-I>'))
end)
end)

View File

@ -1,9 +1,9 @@
local t = require('test.functional.testutil')()
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local command = t.command
local feed = t.feed
local clear = n.clear
local command = n.command
local feed = n.feed
describe('update_menu notification', function()
local screen

View File

@ -1,11 +1,12 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local clear = n.clear
local eq = t.eq
local fn = t.fn
local fn = n.fn
local neq = t.neq
local nvim_argv = t.nvim_argv
local request = t.request
local nvim_argv = n.nvim_argv
local request = n.request
local retry = t.retry
local NIL = vim.NIL
local is_os = t.is_os

View File

@ -1,11 +1,13 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local assert_log = t.assert_log
local eq, clear, eval, command, next_msg = t.eq, t.clear, t.eval, t.command, t.next_msg
local api = t.api
local exec_lua = t.exec_lua
local eq, clear, eval, command, next_msg = t.eq, n.clear, n.eval, n.command, n.next_msg
local api = n.api
local exec_lua = n.exec_lua
local retry = t.retry
local assert_alive = t.assert_alive
local check_close = t.check_close
local assert_alive = n.assert_alive
local check_close = n.check_close
local testlog = 'Xtest-server-notify-log'

View File

@ -1,17 +1,18 @@
-- Test server -> client RPC scenarios. Note: unlike `rpcnotify`, to evaluate
-- `rpcrequest` calls we need the client event loop to be running.
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eval = t.clear, t.eval
local eq, neq, run, stop = t.eq, t.neq, t.run, t.stop
local nvim_prog, command, fn = t.nvim_prog, t.command, t.fn
local source, next_msg = t.source, t.next_msg
local clear, eval = n.clear, n.eval
local eq, neq, run, stop = t.eq, t.neq, n.run, n.stop
local nvim_prog, command, fn = n.nvim_prog, n.command, n.fn
local source, next_msg = n.source, n.next_msg
local ok = t.ok
local api = t.api
local spawn, merge_args = t.spawn, t.merge_args
local set_session = t.set_session
local api = n.api
local spawn, merge_args = n.spawn, n.merge_args
local set_session = n.set_session
local pcall_err = t.pcall_err
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
describe('server -> client', function()
local cid
@ -91,19 +92,19 @@ describe('server -> client', function()
local function on_request(method, args)
eq('rcall', method)
local n = unpack(args) * 2
if n <= 16 then
local _n = unpack(args) * 2
if _n <= 16 then
local cmd
if n == 4 then
cmd = 'let g:result2 = rpcrequest(' .. cid .. ', "rcall", ' .. n .. ')'
elseif n == 8 then
cmd = 'let g:result3 = rpcrequest(' .. cid .. ', "rcall", ' .. n .. ')'
elseif n == 16 then
cmd = 'let g:result4 = rpcrequest(' .. cid .. ', "rcall", ' .. n .. ')'
if _n == 4 then
cmd = 'let g:result2 = rpcrequest(' .. cid .. ', "rcall", ' .. _n .. ')'
elseif _n == 8 then
cmd = 'let g:result3 = rpcrequest(' .. cid .. ', "rcall", ' .. _n .. ')'
elseif _n == 16 then
cmd = 'let g:result4 = rpcrequest(' .. cid .. ', "rcall", ' .. _n .. ')'
end
command(cmd)
end
return n
return _n
end
run(on_request, nil, on_setup)
end)
@ -280,7 +281,7 @@ describe('server -> client', function()
end)
describe('connecting to another (peer) nvim', function()
local nvim_argv = merge_args(t.nvim_argv, { '--headless' })
local nvim_argv = merge_args(n.nvim_argv, { '--headless' })
local function connect_test(server, mode, address)
local serverpid = fn.getpid()
local client = spawn(nvim_argv, false, nil, true)

View File

@ -1,13 +1,15 @@
local t = require('test.functional.testutil')()
local clear, eq, ok = t.clear, t.eq, t.ok
local exec = t.exec
local feed = t.feed
local api = t.api
local fn = t.fn
local request = t.request
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eq, ok = n.clear, t.eq, t.ok
local exec = n.exec
local feed = n.feed
local api = n.api
local fn = n.fn
local request = n.request
local NIL = vim.NIL
local pcall_err = t.pcall_err
local command = t.command
local command = n.command
describe('api/tabpage', function()
before_each(clear)

View File

@ -1,13 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local eval = t.eval
local exec = t.exec
local feed = t.feed
local api = t.api
local request = t.request
local eval = n.eval
local exec = n.exec
local feed = n.feed
local api = n.api
local request = n.request
local pcall_err = t.pcall_err
describe('nvim_ui_attach()', function()

View File

@ -1,6 +1,8 @@
local t = require('test.functional.testutil')()
local clear, fn, eq = t.clear, t.fn, t.eq
local api = t.api
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, fn, eq = n.clear, n.fn, t.eq
local api = n.api
local function read_mpack_file(fname)
local fd = io.open(fname, 'rb')

View File

@ -1,36 +1,37 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local uv = vim.uv
local fmt = string.format
local dedent = t.dedent
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
local NIL = vim.NIL
local clear, eq, neq = t.clear, t.eq, t.neq
local command = t.command
local command_output = t.api.nvim_command_output
local exec = t.exec
local exec_capture = t.exec_capture
local eval = t.eval
local expect = t.expect
local fn = t.fn
local api = t.api
local clear, eq, neq = n.clear, t.eq, t.neq
local command = n.command
local command_output = n.api.nvim_command_output
local exec = n.exec
local exec_capture = n.exec_capture
local eval = n.eval
local expect = n.expect
local fn = n.fn
local api = n.api
local matches = t.matches
local pesc = vim.pesc
local mkdir_p = t.mkdir_p
local ok, nvim_async, feed = t.ok, t.nvim_async, t.feed
local async_meths = t.async_meths
local mkdir_p = n.mkdir_p
local ok, nvim_async, feed = t.ok, n.nvim_async, n.feed
local async_meths = n.async_meths
local is_os = t.is_os
local parse_context = t.parse_context
local request = t.request
local rmdir = t.rmdir
local source = t.source
local next_msg = t.next_msg
local parse_context = n.parse_context
local request = n.request
local rmdir = n.rmdir
local source = n.source
local next_msg = n.next_msg
local tmpname = t.tmpname
local write_file = t.write_file
local exec_lua = t.exec_lua
local exc_exec = t.exc_exec
local insert = t.insert
local exec_lua = n.exec_lua
local exc_exec = n.exc_exec
local insert = n.insert
local skip = t.skip
local pcall_err = t.pcall_err
@ -722,12 +723,12 @@ describe('API', function()
end)
after_each(function()
t.rmdir('Xtestdir')
n.rmdir('Xtestdir')
end)
it('works', function()
api.nvim_set_current_dir('Xtestdir')
eq(start_dir .. t.get_pathsep() .. 'Xtestdir', fn.getcwd())
eq(start_dir .. n.get_pathsep() .. 'Xtestdir', fn.getcwd())
end)
it('sets previous directory', function()
@ -1487,7 +1488,7 @@ describe('API', function()
eq(NIL, api.nvim_get_var('Unknown_script_func'))
-- Check if autoload works properly
local pathsep = t.get_pathsep()
local pathsep = n.get_pathsep()
local xconfig = 'Xhome' .. pathsep .. 'Xconfig'
local xdata = 'Xhome' .. pathsep .. 'Xdata'
local autoload_folder = table.concat({ xconfig, 'nvim', 'autoload' }, pathsep)
@ -1971,7 +1972,7 @@ describe('API', function()
describe('RPC (K_EVENT)', function()
it('does not complete ("interrupt") normal-mode operator-pending #6166', function()
t.insert([[
n.insert([[
FIRST LINE
SECOND LINE]])
api.nvim_input('gg')
@ -2008,7 +2009,7 @@ describe('API', function()
it('does not complete ("interrupt") normal-mode map-pending #6166', function()
command("nnoremap dd :let g:foo='it worked...'<CR>")
t.insert([[
n.insert([[
FIRST LINE
SECOND LINE]])
api.nvim_input('gg')
@ -2020,13 +2021,13 @@ describe('API', function()
expect([[
FIRST LINE
SECOND LINE]])
eq('it worked...', t.eval('g:foo'))
eq('it worked...', n.eval('g:foo'))
end)
it('does not complete ("interrupt") insert-mode map-pending #6166', function()
command('inoremap xx foo')
command('set timeoutlen=9999')
t.insert([[
n.insert([[
FIRST LINE
SECOND LINE]])
api.nvim_input('ix')
@ -2173,32 +2174,32 @@ describe('API', function()
describe('nvim_replace_termcodes', function()
it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
eq('\128\254X', t.api.nvim_replace_termcodes('\128', true, true, true))
eq('\128\254X', n.api.nvim_replace_termcodes('\128', true, true, true))
end)
it('leaves non-K_SPECIAL string unchanged', function()
eq('abc', t.api.nvim_replace_termcodes('abc', true, true, true))
eq('abc', n.api.nvim_replace_termcodes('abc', true, true, true))
end)
it('converts <expressions>', function()
eq('\\', t.api.nvim_replace_termcodes('<Leader>', true, true, true))
eq('\\', n.api.nvim_replace_termcodes('<Leader>', true, true, true))
end)
it('converts <LeftMouse> to K_SPECIAL KS_EXTRA KE_LEFTMOUSE', function()
-- K_SPECIAL KS_EXTRA KE_LEFTMOUSE
-- 0x80 0xfd 0x2c
-- 128 253 44
eq('\128\253\44', t.api.nvim_replace_termcodes('<LeftMouse>', true, true, true))
eq('\128\253\44', n.api.nvim_replace_termcodes('<LeftMouse>', true, true, true))
end)
it('converts keycodes', function()
eq('\nx\27x\rx<x', t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true))
eq('\nx\27x\rx<x', n.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, true))
end)
it('does not convert keycodes if special=false', function()
eq(
'<NL>x<Esc>x<CR>x<lt>x',
t.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false)
n.api.nvim_replace_termcodes('<NL>x<Esc>x<CR>x<lt>x', true, true, false)
)
end)
@ -2227,18 +2228,18 @@ describe('API', function()
api.nvim_feedkeys(':let x1="…"\n', '', true)
-- Both nvim_replace_termcodes and nvim_feedkeys escape \x80
local inp = t.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true)
local inp = n.api.nvim_replace_termcodes(':let x2="…"<CR>', true, true, true)
api.nvim_feedkeys(inp, '', true) -- escape_ks=true
-- nvim_feedkeys with K_SPECIAL escaping disabled
inp = t.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true)
inp = n.api.nvim_replace_termcodes(':let x3="…"<CR>', true, true, true)
api.nvim_feedkeys(inp, '', false) -- escape_ks=false
t.stop()
n.stop()
end
-- spin the loop a bit
t.run(nil, nil, on_setup)
n.run(nil, nil, on_setup)
eq('', api.nvim_get_var('x1'))
-- Because of the double escaping this is neq
@ -2381,7 +2382,7 @@ describe('API', function()
{0:~ }|*6
{1:very fail} |
]])
t.poke_eventloop()
n.poke_eventloop()
-- shows up to &cmdheight lines
async_meths.nvim_err_write('more fail\ntoo fail\n')
@ -2693,7 +2694,7 @@ describe('API', function()
describe('nvim_list_runtime_paths', function()
setup(function()
local pathsep = t.get_pathsep()
local pathsep = n.get_pathsep()
mkdir_p('Xtest' .. pathsep .. 'a')
mkdir_p('Xtest' .. pathsep .. 'b')
end)
@ -3200,7 +3201,7 @@ describe('API', function()
end)
describe('nvim_get_runtime_file', function()
local p = t.alter_slashes
local p = n.alter_slashes
it('can find files', function()
eq({}, api.nvim_get_runtime_file('bork.borkbork', false))
eq({}, api.nvim_get_runtime_file('bork.borkbork', true))

View File

@ -1,27 +1,29 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear, curbuf, curbuf_contents, curwin, eq, neq, matches, ok, feed, insert, eval =
t.clear,
t.api.nvim_get_current_buf,
t.curbuf_contents,
t.api.nvim_get_current_win,
n.clear,
n.api.nvim_get_current_buf,
n.curbuf_contents,
n.api.nvim_get_current_win,
t.eq,
t.neq,
t.matches,
t.ok,
t.feed,
t.insert,
t.eval
local poke_eventloop = t.poke_eventloop
local exec = t.exec
local exec_lua = t.exec_lua
local fn = t.fn
local request = t.request
n.feed,
n.insert,
n.eval
local poke_eventloop = n.poke_eventloop
local exec = n.exec
local exec_lua = n.exec_lua
local fn = n.fn
local request = n.request
local NIL = vim.NIL
local api = t.api
local command = t.command
local api = n.api
local command = n.command
local pcall_err = t.pcall_err
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
describe('API/win', function()
before_each(clear)
@ -136,7 +138,7 @@ describe('API/win', function()
end)
after_each(function()
t.rmdir(topdir .. '/Xacd')
n.rmdir(topdir .. '/Xacd')
end)
it('does not change cwd with non-current window', function()
@ -1370,7 +1372,7 @@ describe('API/win', function()
local tab1 = api.nvim_get_current_tabpage()
local tab1_win = api.nvim_get_current_win()
t.command('tabnew')
n.command('tabnew')
local tab2 = api.nvim_get_current_tabpage()
local tab2_win = api.nvim_get_current_win()
@ -1790,7 +1792,7 @@ describe('API/win', function()
end)
after_each(function()
t.rmdir(topdir .. '/Xacd')
n.rmdir(topdir .. '/Xacd')
end)
it('does not change cwd with enter=false #15280', function()

View File

@ -1,14 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local clear = n.clear
local eq = t.eq
local api = t.api
local fn = t.fn
local exec = t.exec
local feed = t.feed
local api = n.api
local fn = n.fn
local exec = n.exec
local feed = n.feed
local assert_log = t.assert_log
local check_close = t.check_close
local check_close = n.check_close
local is_os = t.is_os
local testlog = 'Xtest_autocmd_oldtest_log'

View File

@ -1,24 +1,25 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local assert_visible = t.assert_visible
local assert_alive = t.assert_alive
local assert_visible = n.assert_visible
local assert_alive = n.assert_alive
local dedent = t.dedent
local eq = t.eq
local neq = t.neq
local eval = t.eval
local feed = t.feed
local clear = t.clear
local eval = n.eval
local feed = n.feed
local clear = n.clear
local matches = t.matches
local api = t.api
local api = n.api
local pcall_err = t.pcall_err
local fn = t.fn
local expect = t.expect
local command = t.command
local exc_exec = t.exc_exec
local exec_lua = t.exec_lua
local fn = n.fn
local expect = n.expect
local command = n.command
local exc_exec = n.exc_exec
local exec_lua = n.exec_lua
local retry = t.retry
local source = t.source
local source = n.source
describe('autocmd', function()
before_each(clear)

View File

@ -1,11 +1,12 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local eval = t.eval
local request = t.request
local source = t.source
local eval = n.eval
local request = n.request
local source = n.source
describe('autocmd BufEnter', function()
before_each(clear)
@ -33,7 +34,7 @@ describe('autocmd BufEnter', function()
end)
it('triggered by ":split normal|:help|:bw"', function()
t.add_builddir_to_rtp()
n.add_builddir_to_rtp()
command('split normal')
command('wincmd j')
command('help')

View File

@ -1,10 +1,11 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local clear = n.clear
local eq = t.eq
local eval = t.eval
local source = t.source
local request = t.request
local eval = n.eval
local source = n.source
local request = n.request
describe('BufModified', function()
before_each(clear)

View File

@ -1,14 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local expect = t.expect
local eval = t.eval
local next_msg = t.next_msg
local feed = t.feed
local api = t.api
local expect = n.expect
local eval = n.eval
local next_msg = n.next_msg
local feed = n.feed
local api = n.api
describe('cmdline autocommands', function()
local channel

View File

@ -1,12 +1,13 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local clear = n.clear
local eq = t.eq
local feed = t.feed
local feed = n.feed
local retry = t.retry
local exec = t.source
local exec = n.source
local sleep = vim.uv.sleep
local api = t.api
local api = n.api
before_each(clear)

View File

@ -1,11 +1,12 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local clear = n.clear
local eq = t.eq
local eval = t.eval
local api = t.api
local source = t.source
local command = t.command
local eval = n.eval
local api = n.api
local source = n.source
local command = n.command
describe('CursorMoved', function()
before_each(clear)

View File

@ -1,10 +1,11 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local eval = t.eval
local request = t.request
local eval = n.eval
local request = n.request
local is_os = t.is_os
describe('autocmd DirChanged and DirChangedPre', function()
@ -27,7 +28,7 @@ describe('autocmd DirChanged and DirChangedPre', function()
end)
teardown(function()
for _, dir in pairs(dirs) do
t.rmdir(dir)
n.rmdir(dir)
end
end)

View File

@ -1,14 +1,14 @@
local t = require('test.functional.testutil')()
local n = require('test.functional.testnvim')()
local eval = t.eval
local clear = t.clear
local command = t.command
local eval = n.eval
local clear = n.clear
local command = n.command
describe('autocmd FileType', function()
before_each(clear)
it('is triggered by :help only once', function()
t.add_builddir_to_rtp()
n.add_builddir_to_rtp()
command('let g:foo = 0')
command('autocmd FileType help let g:foo = g:foo + 1')
command('help help')

View File

@ -1,7 +1,9 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local tt = require('test.functional.terminal.testutil')
local clear = t.clear
local feed_command = t.feed_command
local clear = n.clear
local feed_command = n.feed_command
local feed_data = tt.feed_data
if t.skip(t.is_os('win')) then

View File

@ -1,7 +1,9 @@
local t = require('test.functional.testutil')()
local clear, eval, eq = t.clear, t.eval, t.eq
local feed, command = t.feed, t.command
local exec_lua = t.exec_lua
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eval, eq = n.clear, n.eval, t.eq
local feed, command = n.feed, n.command
local exec_lua = n.exec_lua
describe('ModeChanged', function()
before_each(function()

View File

@ -1,9 +1,10 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local clear = n.clear
local eq = t.eq
local eval = t.eval
local source_vim = t.source
local eval = n.eval
local source_vim = n.source
describe('RecordingEnter', function()
before_each(clear)

View File

@ -1,9 +1,11 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local eq = t.eq
local exec = t.exec
local feed = t.feed
local api = t.api
local exec = n.exec
local feed = n.feed
local api = n.api
before_each(clear)

View File

@ -1,11 +1,12 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local api = t.api
local clear = n.clear
local command = n.command
local api = n.api
local eq = t.eq
local eval = t.eval
local feed = t.feed
local eval = n.eval
local feed = n.feed
describe('autocmd SearchWrapped', function()
before_each(function()

View File

@ -1,14 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local dedent = t.dedent
local eq = t.eq
local fn = t.fn
local eval = t.eval
local exec = t.exec
local feed = t.feed
local fn = n.fn
local eval = n.eval
local exec = n.exec
local feed = n.feed
describe(':autocmd', function()
before_each(function()

View File

@ -1,10 +1,11 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local fn = t.fn
local next_msg = t.next_msg
local fn = n.fn
local next_msg = n.next_msg
local is_os = t.is_os
local skip = t.skip

View File

@ -1,7 +1,9 @@
local t = require('test.functional.testutil')()
local clear, eq = t.clear, t.eq
local api = t.api
local command = t.command
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eq = n.clear, t.eq
local api = n.api
local command = n.command
describe('TabClosed', function()
before_each(clear)

View File

@ -1,9 +1,10 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local eval = t.eval
local eval = n.eval
describe('autocmd TabNew', function()
before_each(clear)

View File

@ -1,13 +1,14 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local dedent = t.dedent
local eval = t.eval
local eval = n.eval
local eq = t.eq
local feed = t.feed
local api = t.api
local exec_capture = t.exec_capture
local feed = n.feed
local api = n.api
local exec_capture = n.exec_capture
describe('TabNewEntered', function()
describe('au TabNewEntered', function()

View File

@ -1,15 +1,16 @@
local uv = vim.uv
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local tt = require('test.functional.terminal.testutil')
local uv = vim.uv
local clear, command, testprg = t.clear, t.command, t.testprg
local eval, eq, neq, retry = t.eval, t.eq, t.neq, t.retry
local clear, command, testprg = n.clear, n.command, n.testprg
local eval, eq, neq, retry = n.eval, t.eq, t.neq, t.retry
local matches = t.matches
local ok = t.ok
local feed = t.feed
local api = t.api
local feed = n.feed
local api = n.api
local pcall_err = t.pcall_err
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
local skip = t.skip
local is_os = t.is_os

View File

@ -1,12 +1,14 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local exec = t.exec
local command = t.command
local feed = t.feed
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local exec = n.exec
local command = n.command
local feed = n.feed
local eq = t.eq
local neq = t.neq
local eval = t.eval
local poke_eventloop = t.poke_eventloop
local eval = n.eval
local poke_eventloop = n.poke_eventloop
local write_file = t.write_file
-- oldtest: Test_ChangedP()

View File

@ -1,7 +1,9 @@
local t = require('test.functional.testutil')()
local clear, eval, eq = t.clear, t.eval, t.eq
local feed, command, expect = t.feed, t.command, t.expect
local api, fn, neq = t.api, t.fn, t.neq
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eval, eq = n.clear, n.eval, t.eq
local feed, command, expect = n.feed, n.command, n.expect
local api, fn, neq = n.api, n.fn, t.neq
describe('TextYankPost', function()
before_each(function()

View File

@ -1,14 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local clear = n.clear
local eq = t.eq
local eval = t.eval
local exec = t.exec
local command = t.command
local feed = t.feed
local api = t.api
local assert_alive = t.assert_alive
local eval = n.eval
local exec = n.exec
local command = n.command
local feed = n.feed
local api = n.api
local assert_alive = n.assert_alive
before_each(clear)

View File

@ -1,15 +1,17 @@
local t = require('test.functional.testutil')()
local clear, eq, eval, next_msg, ok, source = t.clear, t.eq, t.eval, t.next_msg, t.ok, t.source
local command, fn, api = t.command, t.fn, t.api
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eq, eval, next_msg, ok, source = n.clear, t.eq, n.eval, n.next_msg, t.ok, n.source
local command, fn, api = n.command, n.fn, n.api
local matches = t.matches
local sleep = vim.uv.sleep
local spawn, nvim_argv = t.spawn, t.nvim_argv
local get_session, set_session = t.get_session, t.set_session
local nvim_prog = t.nvim_prog
local spawn, nvim_argv = n.spawn, n.nvim_argv
local get_session, set_session = n.get_session, n.set_session
local nvim_prog = n.nvim_prog
local is_os = t.is_os
local retry = t.retry
local expect_twostreams = t.expect_twostreams
local assert_alive = t.assert_alive
local expect_twostreams = n.expect_twostreams
local assert_alive = n.assert_alive
local pcall_err = t.pcall_err
local skip = t.skip

View File

@ -1,24 +1,25 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local assert_alive = t.assert_alive
local command = t.command
local feed_command = t.feed_command
local feed = t.feed
local eval = t.eval
local assert_alive = n.assert_alive
local command = n.command
local feed_command = n.feed_command
local feed = n.feed
local eval = n.eval
local eq = t.eq
local run = t.run
local fn = t.fn
local nvim_prog = t.nvim_prog
local run = n.run
local fn = n.fn
local nvim_prog = n.nvim_prog
local pcall_err = t.pcall_err
local exec_capture = t.exec_capture
local poke_eventloop = t.poke_eventloop
local exec_capture = n.exec_capture
local poke_eventloop = n.poke_eventloop
describe('v:exiting', function()
local cid
before_each(function()
t.clear()
cid = t.api.nvim_get_chan_info(0).id
n.clear()
cid = n.api.nvim_get_chan_info(0).id
end)
it('defaults to v:null', function()
@ -74,7 +75,7 @@ describe(':cquit', function()
end
before_each(function()
t.clear()
n.clear()
end)
it('exits with non-zero after :cquit', function()

View File

@ -1,37 +1,38 @@
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local uv = vim.uv
local t = require('test.functional.testutil')()
local assert_log = t.assert_log
local assert_nolog = t.assert_nolog
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local neq = t.neq
local ok = t.ok
local feed = t.feed
local fn = t.fn
local nvim_prog = t.nvim_prog
local request = t.request
local feed = n.feed
local fn = n.fn
local nvim_prog = n.nvim_prog
local request = n.request
local retry = t.retry
local rmdir = t.rmdir
local rmdir = n.rmdir
local matches = t.matches
local api = t.api
local api = n.api
local mkdir = t.mkdir
local sleep = vim.uv.sleep
local read_file = t.read_file
local trim = vim.trim
local currentdir = t.fn.getcwd
local assert_alive = t.assert_alive
local check_close = t.check_close
local expect_exit = t.expect_exit
local currentdir = n.fn.getcwd
local assert_alive = n.assert_alive
local check_close = n.check_close
local expect_exit = n.expect_exit
local write_file = t.write_file
local Screen = require('test.functional.ui.screen')
local feed_command = t.feed_command
local feed_command = n.feed_command
local skip = t.skip
local is_os = t.is_os
local is_ci = t.is_ci
local spawn = t.spawn
local set_session = t.set_session
local spawn = n.spawn
local set_session = n.set_session
describe('fileio', function()
before_each(function() end)
@ -228,7 +229,7 @@ describe('fileio', function()
local initial_content = 'foo'
local backup_dir = 'Xtest_backupdir'
local sep = t.get_pathsep()
local sep = n.get_pathsep()
local link_file_name = 'Xtest_startup_file2'
local backup_file_name = backup_dir .. sep .. link_file_name .. '~'

View File

@ -1,38 +1,39 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local tt = require('test.functional.terminal.testutil')
local clear = t.clear
local clear = n.clear
local eq = t.eq
local eval = t.eval
local exc_exec = t.exc_exec
local feed_command = t.feed_command
local feed = t.feed
local insert = t.insert
local eval = n.eval
local exc_exec = n.exc_exec
local feed_command = n.feed_command
local feed = n.feed
local insert = n.insert
local neq = t.neq
local next_msg = t.next_msg
local testprg = t.testprg
local next_msg = n.next_msg
local testprg = n.testprg
local ok = t.ok
local source = t.source
local source = n.source
local write_file = t.write_file
local mkdir = t.mkdir
local rmdir = t.rmdir
local assert_alive = t.assert_alive
local command = t.command
local fn = t.fn
local os_kill = t.os_kill
local rmdir = n.rmdir
local assert_alive = n.assert_alive
local command = n.command
local fn = n.fn
local os_kill = n.os_kill
local retry = t.retry
local api = t.api
local api = n.api
local NIL = vim.NIL
local poke_eventloop = t.poke_eventloop
local get_pathsep = t.get_pathsep
local pathroot = t.pathroot
local exec_lua = t.exec_lua
local nvim_set = t.nvim_set
local expect_twostreams = t.expect_twostreams
local expect_msg_seq = t.expect_msg_seq
local poke_eventloop = n.poke_eventloop
local get_pathsep = n.get_pathsep
local pathroot = n.pathroot
local exec_lua = n.exec_lua
local nvim_set = n.nvim_set
local expect_twostreams = n.expect_twostreams
local expect_msg_seq = n.expect_msg_seq
local pcall_err = t.pcall_err
local matches = t.matches
local Screen = require('test.functional.ui.screen')
local skip = t.skip
local is_os = t.is_os
@ -732,7 +733,7 @@ describe('jobs', function()
describe('jobwait()', function()
before_each(function()
if is_os('win') then
t.set_shell_powershell()
n.set_shell_powershell()
end
end)
@ -1239,7 +1240,7 @@ describe('pty process teardown', function()
skip(fn.executable('sleep') == 0, 'missing "sleep" command')
-- Use a nested nvim (in :term) to test without --headless.
fn.termopen({
t.nvim_prog,
n.nvim_prog,
'-u',
'NONE',
'-i',

View File

@ -1,11 +1,13 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local assert_log = t.assert_log
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local exec_lua = t.exec_lua
local expect_exit = t.expect_exit
local request = t.request
local exec_lua = n.exec_lua
local expect_exit = n.expect_exit
local request = n.request
describe('log', function()
local testlog = 'Xtest_logging'

View File

@ -1,14 +1,15 @@
local uv = vim.uv
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local uv = vim.uv
local eq = t.eq
local matches = t.matches
local feed = t.feed
local eval = t.eval
local clear = t.clear
local fn = t.fn
local nvim_prog_abs = t.nvim_prog_abs
local feed = n.feed
local eval = n.eval
local clear = n.clear
local fn = n.fn
local nvim_prog_abs = n.nvim_prog_abs
local write_file = t.write_file
local is_os = t.is_os
local skip = t.skip

View File

@ -1,14 +1,16 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local command = t.command
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local command = n.command
local eq = t.eq
local eval = t.eval
local feed = t.feed
local fn = t.fn
local insert = t.insert
local eval = n.eval
local feed = n.feed
local fn = n.fn
local insert = n.insert
local is_os = t.is_os
local mkdir = t.mkdir
local rmdir = t.rmdir
local rmdir = n.rmdir
local write_file = t.write_file
local function join_path(...)

View File

@ -1,18 +1,19 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local exec_capture = t.exec_capture
local exec_lua = t.exec_lua
local expect = t.expect
local fn = t.fn
local insert = t.insert
local nvim_prog = t.nvim_prog
local new_argv = t.new_argv
local exec_capture = n.exec_capture
local exec_lua = n.exec_lua
local expect = n.expect
local fn = n.fn
local insert = n.insert
local nvim_prog = n.nvim_prog
local new_argv = n.new_argv
local neq = t.neq
local set_session = t.set_session
local spawn = t.spawn
local set_session = n.set_session
local spawn = n.spawn
local tmpname = t.tmpname
local write_file = t.write_file

View File

@ -1,11 +1,12 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local clear = t.clear
local api = t.api
local exc_exec = t.exc_exec
local fn = t.fn
local rmdir = t.rmdir
local clear = n.clear
local api = n.api
local exc_exec = n.exc_exec
local fn = n.fn
local rmdir = n.rmdir
local write_file = t.write_file
local mkdir = t.mkdir

View File

@ -1,38 +1,39 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
local assert_log = t.assert_log
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local ok = t.ok
local eq = t.eq
local matches = t.matches
local eval = t.eval
local exec = t.exec
local exec_capture = t.exec_capture
local exec_lua = t.exec_lua
local feed = t.feed
local fn = t.fn
local eval = n.eval
local exec = n.exec
local exec_capture = n.exec_capture
local exec_lua = n.exec_lua
local feed = n.feed
local fn = n.fn
local pesc = vim.pesc
local mkdir = t.mkdir
local mkdir_p = t.mkdir_p
local nvim_prog = t.nvim_prog
local nvim_set = t.nvim_set
local mkdir_p = n.mkdir_p
local nvim_prog = n.nvim_prog
local nvim_set = n.nvim_set
local read_file = t.read_file
local retry = t.retry
local rmdir = t.rmdir
local rmdir = n.rmdir
local sleep = vim.uv.sleep
local startswith = vim.startswith
local write_file = t.write_file
local api = t.api
local alter_slashes = t.alter_slashes
local api = n.api
local alter_slashes = n.alter_slashes
local is_os = t.is_os
local dedent = t.dedent
local tbl_map = vim.tbl_map
local tbl_filter = vim.tbl_filter
local endswith = vim.endswith
local check_close = t.check_close
local check_close = n.check_close
local testlog = 'Xtest-startupspec-log'
@ -994,7 +995,7 @@ describe('sysinit', function()
local xdgdir = 'Xxdg'
local vimdir = 'Xvim'
local xhome = 'Xhome'
local pathsep = t.get_pathsep()
local pathsep = n.get_pathsep()
before_each(function()
rmdir(xdgdir)
@ -1055,7 +1056,7 @@ end)
describe('user config init', function()
local xhome = 'Xhome'
local pathsep = t.get_pathsep()
local pathsep = n.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata'
local init_lua_path = table.concat({ xconfig, 'nvim', 'init.lua' }, pathsep)
@ -1218,7 +1219,7 @@ end)
describe('runtime:', function()
local xhome = 'Xhome'
local pathsep = t.get_pathsep()
local pathsep = n.get_pathsep()
local xconfig = xhome .. pathsep .. 'Xconfig'
local xdata = xhome .. pathsep .. 'Xdata'
local xenv = { XDG_CONFIG_HOME = xconfig, XDG_DATA_HOME = xdata }
@ -1360,7 +1361,7 @@ end)
describe('user session', function()
local xhome = 'Xhome'
local pathsep = t.get_pathsep()
local pathsep = n.get_pathsep()
local session_file = table.concat({ xhome, 'session.lua' }, pathsep)
before_each(function()

View File

@ -1,5 +1,7 @@
local t = require('test.functional.testutil')()
local eq, clear, eval, feed, api, retry = t.eq, t.clear, t.eval, t.feed, t.api, t.retry
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq, clear, eval, feed, api, retry = t.eq, n.clear, n.eval, n.feed, n.api, t.retry
describe('K', function()
local test_file = 'K_spec_out'
@ -12,19 +14,19 @@ describe('K', function()
end)
it("invokes colon-prefixed 'keywordprg' as Vim command", function()
t.source([[
n.source([[
let @a='fnord'
set keywordprg=:put]])
-- K on the text "a" resolves to `:put a`.
feed('ia<ESC>K')
t.expect([[
n.expect([[
a
fnord]])
end)
it("invokes non-prefixed 'keywordprg' as shell command", function()
t.source([[
n.source([[
let @a='fnord'
set keywordprg=echo\ fnord>>]])
@ -42,7 +44,7 @@ describe('K', function()
end)
it("<esc> kills the buffer for a running 'keywordprg' command", function()
t.source('set keywordprg=less')
n.source('set keywordprg=less')
eval('writefile(["hello", "world"], "' .. test_file .. '")')
feed('i' .. test_file .. '<esc>K')
eq('t', eval('mode()'))

View File

@ -1,13 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local assert_alive = t.assert_alive
local clear, feed = t.clear, t.feed
local eval, eq, neq = t.eval, t.eq, t.neq
local feed_command, source, expect = t.feed_command, t.source, t.expect
local fn = t.fn
local command = t.command
local api = t.api
local poke_eventloop = t.poke_eventloop
local assert_alive = n.assert_alive
local clear, feed = n.clear, n.feed
local eval, eq, neq = n.eval, t.eq, t.neq
local feed_command, source, expect = n.feed_command, n.source, n.expect
local fn = n.fn
local command = n.command
local api = n.api
local poke_eventloop = n.poke_eventloop
describe('completion', function()
local screen

View File

@ -1,10 +1,11 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local eval = t.eval
local feed = t.feed
local clear = t.clear
local command = t.command
local eval = n.eval
local feed = n.feed
local clear = n.clear
local command = n.command
describe('v:count/v:count1', function()
before_each(function()

View File

@ -1,8 +1,10 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear, feed, source = t.clear, t.feed, t.source
local command = t.command
local poke_eventloop = t.poke_eventloop
local clear, feed, source = n.clear, n.feed, n.source
local command = n.command
local poke_eventloop = n.poke_eventloop
local sleep = vim.uv.sleep
describe('CTRL-C (mapped)', function()

View File

@ -1,12 +1,13 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local insert = t.insert
local exec = t.exec
local feed = t.feed
local expect = t.expect
local command = t.command
local fn = t.fn
local clear = n.clear
local insert = n.insert
local exec = n.exec
local feed = n.feed
local expect = n.expect
local command = n.command
local fn = n.fn
local eq = t.eq
local neq = t.neq
@ -376,7 +377,7 @@ a]],
end)
it('splits folds according to >N and <N with foldexpr', function()
t.source([[
n.source([[
function TestFoldExpr(lnum)
let thisline = getline(a:lnum)
if thisline == 'a'

View File

@ -1,15 +1,16 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local dedent = t.dedent
local eq = t.eq
local fn = t.fn
local feed = t.feed
local exec_capture = t.exec_capture
local fn = n.fn
local feed = n.feed
local exec_capture = n.exec_capture
local write_file = t.write_file
local api = t.api
local api = n.api
describe('jumplist', function()
local fname1 = 'Xtest-functional-normal-jump'

View File

@ -1,8 +1,10 @@
local t = require('test.functional.testutil')()
local clear, insert, eq = t.clear, t.insert, t.eq
local command, expect = t.command, t.expect
local feed, eval = t.feed, t.eval
local exc_exec = t.exc_exec
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, insert, eq = n.clear, n.insert, t.eq
local command, expect = n.command, n.expect
local feed, eval = n.feed, n.eval
local exc_exec = n.exc_exec
describe('gu and gU', function()
before_each(clear)

View File

@ -1,10 +1,11 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq, neq, call = t.eq, t.neq, t.call
local eval, feed, clear = t.eval, t.feed, t.clear
local command, insert, expect = t.command, t.insert, t.expect
local feed_command = t.feed_command
local curwin = t.api.nvim_get_current_win
local eq, neq, call = t.eq, t.neq, n.call
local eval, feed, clear = n.eval, n.feed, n.clear
local command, insert, expect = n.command, n.insert, n.expect
local feed_command = n.feed_command
local curwin = n.api.nvim_get_current_win
describe("'langmap'", function()
before_each(function()
@ -133,7 +134,7 @@ describe("'langmap'", function()
hello]])
end)
it('command-line CTRL-R', function()
t.source([[
n.source([[
let i_value = 0
let j_value = 0
call setreg('i', 'i_value')
@ -171,7 +172,7 @@ describe("'langmap'", function()
end)
it('prompt for number', function()
command('set langmap=12,21')
t.source([[
n.source([[
let gotten_one = 0
function Map()
let answer = inputlist(['a', '1.', '2.', '3.'])
@ -214,7 +215,7 @@ describe("'langmap'", function()
end
feed('qa' .. command_string .. 'q')
expect(expect_string)
eq(expect_macro or t.fn.nvim_replace_termcodes(command_string, true, true, true), eval('@a'))
eq(expect_macro or n.fn.nvim_replace_termcodes(command_string, true, true, true), eval('@a'))
if setup_function then
setup_function()
end

View File

@ -1,14 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local eval = t.eval
local feed = t.feed
local clear = t.clear
local expect = t.expect
local command = t.command
local fn = t.fn
local api = t.api
local insert = t.insert
local eval = n.eval
local feed = n.feed
local clear = n.clear
local expect = n.expect
local command = n.command
local fn = n.fn
local api = n.api
local insert = n.insert
describe('macros with default mappings', function()
before_each(function()

View File

@ -1,15 +1,17 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local api = t.api
local clear = t.clear
local command = t.command
local fn = t.fn
local api = n.api
local clear = n.clear
local command = n.command
local fn = n.fn
local eq = t.eq
local feed = t.feed
local feed = n.feed
local write_file = t.write_file
local pcall_err = t.pcall_err
local cursor = function()
return t.api.nvim_win_get_cursor(0)
return n.api.nvim_win_get_cursor(0)
end
describe('named marks', function()
@ -39,59 +41,59 @@ describe('named marks', function()
it('errors when set out of range with :mark', function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, '1000mark x')
local err = pcall_err(n.exec_capture, '1000mark x')
eq('nvim_exec2(): Vim(mark):E16: Invalid range: 1000mark x', err)
end)
it('errors when set out of range with :k', function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, '1000kx')
local err = pcall_err(n.exec_capture, '1000kx')
eq('nvim_exec2(): Vim(k):E16: Invalid range: 1000kx', err)
end)
it('errors on unknown mark name with :mark', function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, 'mark #')
local err = pcall_err(n.exec_capture, 'mark #')
eq('nvim_exec2(): Vim(mark):E191: Argument must be a letter or forward/backward quote', err)
end)
it("errors on unknown mark name with '", function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, "normal! '#")
local err = pcall_err(n.exec_capture, "normal! '#")
eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err)
end)
it('errors on unknown mark name with `', function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, 'normal! `#')
local err = pcall_err(n.exec_capture, 'normal! `#')
eq('nvim_exec2(): Vim(normal):E78: Unknown mark', err)
end)
it("errors when moving to a mark that is not set with '", function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, "normal! 'z")
local err = pcall_err(n.exec_capture, "normal! 'z")
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
err = pcall_err(t.exec_capture, "normal! '.")
err = pcall_err(n.exec_capture, "normal! '.")
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end)
it('errors when moving to a mark that is not set with `', function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, 'normal! `z')
local err = pcall_err(n.exec_capture, 'normal! `z')
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
err = pcall_err(t.exec_capture, 'normal! `>')
err = pcall_err(n.exec_capture, 'normal! `>')
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end)
it("errors when moving to a global mark that is not set with '", function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, "normal! 'Z")
local err = pcall_err(n.exec_capture, "normal! 'Z")
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end)
it('errors when moving to a global mark that is not set with `', function()
command('edit ' .. file1)
local err = pcall_err(t.exec_capture, 'normal! `Z')
local err = pcall_err(n.exec_capture, 'normal! `Z')
eq('nvim_exec2(): Vim(normal):E20: Mark not set', err)
end)
@ -166,7 +168,7 @@ describe('named marks', function()
feed('mA')
command('next')
command('bw! ' .. file1)
local err = pcall_err(t.exec_capture, "normal! 'A")
local err = pcall_err(n.exec_capture, "normal! 'A")
eq('nvim_exec2(): Vim(normal):E92: Buffer 1 not found', err)
os.remove(file1)
end)

View File

@ -1,10 +1,12 @@
local t = require('test.functional.testutil')()
local clear, feed, insert = t.clear, t.feed, t.insert
local command = t.command
local exec_lua = t.exec_lua
local eval = t.eval
local expect = t.expect
local fn = t.fn
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, feed, insert = n.clear, n.feed, n.insert
local command = n.command
local exec_lua = n.exec_lua
local eval = n.eval
local expect = n.expect
local fn = n.fn
local eq = t.eq
describe('meta-keys #8226 #13042', function()

View File

@ -1,11 +1,13 @@
-- Cmdline-mode tests.
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear, insert, fn, eq, feed = t.clear, t.insert, t.fn, t.eq, t.feed
local eval = t.eval
local command = t.command
local api = t.api
local clear, insert, fn, eq, feed = n.clear, n.insert, n.fn, t.eq, n.feed
local eval = n.eval
local command = n.command
local api = n.api
describe('cmdline', function()
before_each(clear)

View File

@ -1,14 +1,16 @@
-- Insert-mode tests.
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear, feed, insert = t.clear, t.feed, t.insert
local expect = t.expect
local command = t.command
local clear, feed, insert = n.clear, n.feed, n.insert
local expect = n.expect
local command = n.command
local eq = t.eq
local eval = t.eval
local curbuf_contents = t.curbuf_contents
local api = t.api
local eval = n.eval
local curbuf_contents = n.curbuf_contents
local api = n.api
describe('insert-mode', function()
before_each(function()
@ -223,10 +225,10 @@ describe('insert-mode', function()
end
local function test_cols(expected_cols)
local cols = { { t.fn.col('.'), t.fn.virtcol('.') } }
local cols = { { n.fn.col('.'), n.fn.virtcol('.') } }
for _ = 2, #expected_cols do
feed('<BS>')
table.insert(cols, { t.fn.col('.'), t.fn.virtcol('.') })
table.insert(cols, { n.fn.col('.'), n.fn.virtcol('.') })
end
eq(expected_cols, cols)
end

View File

@ -1,11 +1,13 @@
-- Normal mode tests.
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local feed = t.feed
local fn = t.fn
local command = t.command
local clear = n.clear
local feed = n.feed
local fn = n.fn
local command = n.command
local eq = t.eq
describe('Normal mode', function()
@ -25,7 +27,7 @@ describe('Normal mode', function()
local screen = Screen.new(60, 17)
screen:attach()
fn.termopen(
{ t.nvim_prog, '--clean', '--cmd', 'startinsert' },
{ n.nvim_prog, '--clean', '--cmd', 'startinsert' },
{ env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } }
)
screen:expect({

View File

@ -1,17 +1,18 @@
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local t = require('test.functional.testutil')()
local clear = t.clear
local insert = t.insert
local feed = t.feed
local expect = t.expect
local clear = n.clear
local insert = n.insert
local feed = n.feed
local expect = n.expect
local eq = t.eq
local map = vim.tbl_map
local filter = vim.tbl_filter
local feed_command = t.feed_command
local command = t.command
local curbuf_contents = t.curbuf_contents
local fn = t.fn
local feed_command = n.feed_command
local command = n.command
local curbuf_contents = n.curbuf_contents
local fn = n.fn
local dedent = t.dedent
local function reset()

View File

@ -1,6 +1,8 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local command = t.command
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local command = n.command
local eq = t.eq
local pcall_err = t.pcall_err

View File

@ -1,17 +1,18 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local neq = t.neq
local feed = t.feed
local eval = t.eval
local exec = t.exec
local fn = t.fn
local api = t.api
local curwin = t.api.nvim_get_current_win
local assert_alive = t.assert_alive
local feed = n.feed
local eval = n.eval
local exec = n.exec
local fn = n.fn
local api = n.api
local curwin = n.api.nvim_get_current_win
local assert_alive = n.assert_alive
describe('tabpage', function()
before_each(clear)

View File

@ -1,16 +1,17 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local eval = t.eval
local expect = t.expect
local clear = n.clear
local command = n.command
local eval = n.eval
local expect = n.expect
local eq = t.eq
local feed = t.feed
local feed_command = t.feed_command
local insert = t.insert
local fn = t.fn
local exec = t.exec
local exec_lua = t.exec_lua
local feed = n.feed
local feed_command = n.feed_command
local insert = n.insert
local fn = n.fn
local exec = n.exec
local exec_lua = n.exec_lua
local function lastmessage()
local messages = fn.split(fn.execute('messages'), '\n')
@ -44,7 +45,7 @@ describe('u CTRL-R g- g+', function()
local function undo_and_redo(hist_pos, undo, redo, expect_str)
command('enew!')
create_history(hist_pos)
local cur_contents = t.curbuf_contents()
local cur_contents = n.curbuf_contents()
feed(undo)
expect(expect_str)
feed(redo)

View File

@ -1,14 +1,15 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local eq = t.eq
local dedent = t.dedent
local exec = t.exec
local feed = t.feed
local clear = t.clear
local fn = t.fn
local command = t.command
local api = t.api
local Screen = require('test.functional.ui.screen')
local exec = n.exec
local feed = n.feed
local clear = n.clear
local fn = n.fn
local command = n.command
local api = n.api
local cmdtest = function(cmd, prep, ret1)
describe(':' .. cmd, function()

View File

@ -1,8 +1,10 @@
local t = require('test.functional.testutil')()
local eq, command, fn = t.eq, t.command, t.fn
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq, command, fn = t.eq, n.command, n.fn
local ok = t.ok
local matches = t.matches
local clear = t.clear
local clear = n.clear
describe(':argument', function()
before_each(function()
@ -11,19 +13,19 @@ describe(':argument', function()
it('does not restart :terminal buffer', function()
command('terminal')
t.feed([[<C-\><C-N>]])
n.feed([[<C-\><C-N>]])
command('argadd')
t.feed([[<C-\><C-N>]])
n.feed([[<C-\><C-N>]])
local bufname_before = fn.bufname('%')
local bufnr_before = fn.bufnr('%')
matches('^term://', bufname_before) -- sanity
command('argument 1')
t.feed([[<C-\><C-N>]])
n.feed([[<C-\><C-N>]])
local bufname_after = fn.bufname('%')
local bufnr_after = fn.bufnr('%')
eq('[' .. bufname_before .. ']', t.eval('trim(execute("args"))'))
eq('[' .. bufname_before .. ']', n.eval('trim(execute("args"))'))
ok(fn.line('$') > 1)
eq(bufname_before, bufname_after)
eq(bufnr_before, bufnr_after)

View File

@ -1,13 +1,14 @@
-- Specs for :cd, :tcd, :lcd and getcwd()
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local call = t.call
local clear = t.clear
local command = t.command
local exc_exec = t.exc_exec
local pathsep = t.get_pathsep()
local call = n.call
local clear = n.clear
local command = n.command
local exc_exec = n.exc_exec
local pathsep = n.get_pathsep()
local skip = t.skip
local is_os = t.is_os
local mkdir = t.mkdir
@ -289,14 +290,14 @@ describe('getcwd()', function()
end)
after_each(function()
t.rmdir(directories.global)
n.rmdir(directories.global)
end)
it('returns empty string if working directory does not exist', function()
skip(is_os('win'))
command('cd ' .. directories.global)
command("call delete('../" .. directories.global .. "', 'd')")
eq('', t.eval('getcwd()'))
eq('', n.eval('getcwd()'))
end)
it("works with 'autochdir' after local directory was set (#9892)", function()

View File

@ -1,16 +1,18 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local feed = t.feed
local eq = t.eq
local expect = t.expect
local eval = t.eval
local fn = t.fn
local insert = t.insert
local write_file = t.write_file
local exc_exec = t.exc_exec
local command = t.command
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = n.clear
local feed = n.feed
local eq = t.eq
local expect = n.expect
local eval = n.eval
local fn = n.fn
local insert = n.insert
local write_file = t.write_file
local exc_exec = n.exc_exec
local command = n.command
describe('mappings with <Cmd>', function()
local screen
local tmpfile = 'X_ex_cmds_cmd_map'

View File

@ -1,7 +1,8 @@
local t = require('test.functional.testutil')()
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local feed = t.feed
local clear = t.clear
local feed = n.feed
local clear = n.clear
describe(':debug', function()
local screen

View File

@ -1,13 +1,15 @@
local t = require('test.functional.testutil')()
local assert_alive = t.assert_alive
local clear, source = t.clear, t.source
local api = t.api
local insert = t.insert
local eq, next_msg = t.eq, t.next_msg
local exc_exec = t.exc_exec
local exec_lua = t.exec_lua
local command = t.command
local eval = t.eval
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local assert_alive = n.assert_alive
local clear, source = n.clear, n.source
local api = n.api
local insert = n.insert
local eq, next_msg = t.eq, n.next_msg
local exc_exec = n.exc_exec
local exec_lua = n.exec_lua
local command = n.command
local eval = n.eval
describe('Vimscript dictionary notifications', function()
local channel

View File

@ -1,9 +1,10 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local command = t.command
local feed = t.feed
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = n.clear
local command = n.command
local feed = n.feed
describe(':digraphs', function()
local screen
before_each(function()

View File

@ -1,8 +1,9 @@
local t = require('test.functional.testutil')()
local command = t.command
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear, feed, feed_command = t.clear, t.feed, t.feed_command
local exec = t.exec
local command = n.command
local clear, feed, feed_command = n.clear, n.feed, n.feed_command
local exec = n.exec
describe(':drop', function()
local screen

View File

@ -1,16 +1,17 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq = t.eq
local NIL = vim.NIL
local eval = t.eval
local clear = t.clear
local api = t.api
local fn = t.fn
local source = t.source
local eval = n.eval
local clear = n.clear
local api = n.api
local fn = n.fn
local source = n.source
local dedent = t.dedent
local command = t.command
local exc_exec = t.exc_exec
local exec_capture = t.exec_capture
local command = n.command
local exc_exec = n.exc_exec
local exec_capture = n.exec_capture
local matches = t.matches
describe(':echo :echon :echomsg :echoerr', function()
@ -349,8 +350,8 @@ describe(':echo :echon :echomsg :echoerr', function()
end)
describe('used to represent special values', function()
local function chr(n)
return ('%c'):format(n)
local function chr(_n)
return ('%c'):format(_n)
end
local function ctrl(c)
return ('%c'):format(c:upper():byte() - 0x40)

View File

@ -1,9 +1,11 @@
local t = require('test.functional.testutil')()
local eq, command, fn = t.eq, t.command, t.fn
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local eq, command, fn = t.eq, n.command, n.fn
local ok = t.ok
local matches = t.matches
local clear = t.clear
local feed = t.feed
local clear = n.clear
local feed = n.feed
describe(':edit', function()
before_each(function()

View File

@ -1,6 +1,8 @@
local t = require('test.functional.testutil')()
local clear, feed_command, feed = t.clear, t.feed_command, t.feed
local eq, neq, eval = t.eq, t.neq, t.eval
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, feed_command, feed = n.clear, n.feed_command, n.feed
local eq, neq, eval = t.eq, t.neq, n.eval
describe('&encoding', function()
before_each(function()

View File

@ -1,10 +1,12 @@
local t = require('test.functional.testutil')()
local command = t.command
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local command = n.command
local eq = t.eq
local clear = t.clear
local fn = t.fn
local clear = n.clear
local fn = n.fn
local pcall_err = t.pcall_err
local assert_alive = t.assert_alive
local assert_alive = n.assert_alive
describe('Ex cmds', function()
before_each(function()

View File

@ -1,9 +1,11 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local command = t.command
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local command = n.command
local eq = t.eq
local fn = t.fn
local rmdir = t.rmdir
local fn = n.fn
local rmdir = n.rmdir
local mkdir = t.mkdir
describe(':file', function()

View File

@ -1,5 +1,7 @@
local t = require('test.functional.testutil')()
local clear, feed_command, feed, ok, eval = t.clear, t.feed_command, t.feed, t.ok, t.eval
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, feed_command, feed, ok, eval = n.clear, n.feed_command, n.feed, t.ok, n.eval
describe(':grep', function()
before_each(clear)

View File

@ -1,19 +1,20 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local clear = n.clear
local command = n.command
local eq = t.eq
local fn = t.fn
local api = t.api
local fn = n.fn
local api = n.api
local mkdir = t.mkdir
local rmdir = t.rmdir
local rmdir = n.rmdir
local write_file = t.write_file
describe(':help', function()
before_each(clear)
it('window closed makes cursor return to a valid win/buf #9773', function()
t.add_builddir_to_rtp()
n.add_builddir_to_rtp()
command('help help')
eq(1001, fn.win_getid())
command('quit')

View File

@ -1,11 +1,13 @@
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local t = require('test.functional.testutil')()
local eq, command = t.eq, t.command
local clear = t.clear
local eval, exc_exec = t.eval, t.exc_exec
local exec = t.exec
local fn = t.fn
local api = t.api
local eq, command = t.eq, n.command
local clear = n.clear
local eval, exc_exec = n.eval, n.exc_exec
local exec = n.exec
local fn = n.fn
local api = n.api
describe(':highlight', function()
local screen

View File

@ -1,11 +1,13 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local command = t.command
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local command = n.command
local eq = t.eq
local eval = t.eval
local feed = t.feed
local api = t.api
local testprg = t.testprg
local eval = n.eval
local feed = n.feed
local api = n.api
local testprg = n.testprg
local retry = t.retry
describe(':ls', function()

View File

@ -1,10 +1,12 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local eval = t.eval
local has_powershell = t.has_powershell
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local eval = n.eval
local has_powershell = n.has_powershell
local matches = t.matches
local api = t.api
local testprg = t.testprg
local api = n.api
local testprg = n.testprg
describe(':make', function()
clear()
@ -18,7 +20,7 @@ describe(':make', function()
return
end
before_each(function()
t.set_shell_powershell()
n.set_shell_powershell()
end)
it('captures stderr & non zero exit code #14349', function()

View File

@ -1,16 +1,17 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local eq = t.eq
local exec = t.exec
local exec_capture = t.exec_capture
local feed = t.feed
local api = t.api
local clear = t.clear
local command = t.command
local expect = t.expect
local insert = t.insert
local eval = t.eval
local exec = n.exec
local exec_capture = n.exec_capture
local feed = n.feed
local api = n.api
local clear = n.clear
local command = n.command
local expect = n.expect
local insert = n.insert
local eval = n.eval
describe(':*map', function()
before_each(clear)

View File

@ -1,8 +1,10 @@
local t = require('test.functional.testutil')()
local clear, command = t.clear, t.command
local expect, feed = t.expect, t.feed
local eq, eval = t.eq, t.eval
local fn = t.fn
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, command = n.clear, n.command
local expect, feed = n.expect, n.feed
local eq, eval = t.eq, n.eval
local fn = n.fn
describe(':emenu', function()
before_each(function()

View File

@ -1,17 +1,18 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local clear = t.clear
local command = t.command
local get_pathsep = t.get_pathsep
local clear = n.clear
local command = n.command
local get_pathsep = n.get_pathsep
local eq = t.eq
local neq = t.neq
local fn = t.fn
local fn = n.fn
local matches = t.matches
local pesc = vim.pesc
local rmdir = t.rmdir
local rmdir = n.rmdir
local sleep = vim.uv.sleep
local api = t.api
local api = n.api
local skip = t.skip
local is_os = t.is_os
local mkdir = t.mkdir

View File

@ -1,11 +1,12 @@
local t = require('test.functional.testutil')()
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = t.clear
local command = t.command
local get_pathsep = t.get_pathsep
local clear = n.clear
local command = n.command
local get_pathsep = n.get_pathsep
local eq = t.eq
local fn = t.fn
local rmdir = t.rmdir
local fn = n.fn
local rmdir = n.rmdir
local mkdir = t.mkdir
local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec'

View File

@ -1,11 +1,13 @@
local t = require('test.functional.testutil')()
local clear = t.clear
local command = t.command
local fn = t.fn
local feed = t.feed
local expect = t.expect
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear = n.clear
local command = n.command
local fn = n.fn
local feed = n.feed
local expect = n.expect
local eq = t.eq
local eval = t.eval
local eval = n.eval
before_each(clear)

View File

@ -1,13 +1,14 @@
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local Screen = require('test.functional.ui.screen')
local t = require('test.functional.testutil')()
local clear = t.clear
local command = t.command
local expect_exit = t.expect_exit
local api, eq, feed_command = t.api, t.eq, t.feed_command
local feed, poke_eventloop = t.feed, t.poke_eventloop
local clear = n.clear
local command = n.command
local expect_exit = n.expect_exit
local api, eq, feed_command = n.api, t.eq, n.feed_command
local feed, poke_eventloop = n.feed, n.poke_eventloop
local ok = t.ok
local eval = t.eval
local eval = n.eval
local shada_file = 'Xtest.shada'
@ -109,7 +110,7 @@ describe(':browse oldfiles', function()
-- Ensure v:oldfiles isn't busted. Since things happen so fast,
-- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood).
-- Let's verify the contents and the length of v:oldfiles before moving on.
oldfiles = t.api.nvim_get_vvar('oldfiles')
oldfiles = n.api.nvim_get_vvar('oldfiles')
eq(2, #oldfiles)
ok(filename == oldfiles[1] or filename == oldfiles[2])
ok(filename2 == oldfiles[1] or filename2 == oldfiles[2])

View File

@ -1,5 +1,7 @@
local t = require('test.functional.testutil')()
local clear, eq, command, fn = t.clear, t.eq, t.command, t.fn
local t = require('test.testutil')
local n = require('test.functional.testnvim')()
local clear, eq, command, fn = n.clear, t.eq, n.command, n.fn
describe(':z^', function()
before_each(clear)

Some files were not shown because too many files have changed in this diff Show More