mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.1523: cannot write and read terminal screendumps
Problem: Cannot write and read terminal screendumps.
Solution: Add term_dumpwrite(), term_dumpread() and term_dumpdiff().
Also add assert_equalfile().
d96ff16511
This commit is contained in:
parent
0b71bb73e8
commit
792c290343
@ -2007,6 +2007,8 @@ argv([-1, {winid}]) List the argument list
|
|||||||
assert_beeps({cmd}) none assert {cmd} causes a beep
|
assert_beeps({cmd}) none assert {cmd} causes a beep
|
||||||
assert_equal({exp}, {act} [, {msg}])
|
assert_equal({exp}, {act} [, {msg}])
|
||||||
none assert {exp} is equal to {act}
|
none assert {exp} is equal to {act}
|
||||||
|
assert_equalfile({fname-one}, {fname-two})
|
||||||
|
none assert file contents is equal
|
||||||
assert_exception({error} [, {msg}])
|
assert_exception({error} [, {msg}])
|
||||||
none assert {error} is in v:exception
|
none assert {error} is in v:exception
|
||||||
assert_fails({cmd} [, {error}]) none assert {cmd} fails
|
assert_fails({cmd} [, {error}]) none assert {cmd} fails
|
||||||
@ -2597,6 +2599,13 @@ assert_equal({expected}, {actual}, [, {msg}])
|
|||||||
< Will result in a string to be added to |v:errors|:
|
< Will result in a string to be added to |v:errors|:
|
||||||
test.vim line 12: Expected 'foo' but got 'bar' ~
|
test.vim line 12: Expected 'foo' but got 'bar' ~
|
||||||
|
|
||||||
|
*assert_equalfile()*
|
||||||
|
assert_equalfile({fname-one}, {fname-two})
|
||||||
|
When the files {fname-one} and {fname-two} do not contain
|
||||||
|
exactly the same text an error message is added to |v:errors|.
|
||||||
|
When {fname-one} or {fname-two} does not exist the error will
|
||||||
|
mention that.
|
||||||
|
|
||||||
assert_exception({error} [, {msg}]) *assert_exception()*
|
assert_exception({error} [, {msg}]) *assert_exception()*
|
||||||
When v:exception does not contain the string {error} an error
|
When v:exception does not contain the string {error} an error
|
||||||
message is added to |v:errors|.
|
message is added to |v:errors|.
|
||||||
@ -4479,8 +4488,7 @@ getftype({fname}) *getftype()*
|
|||||||
systems that support it. On some systems only "dir" and
|
systems that support it. On some systems only "dir" and
|
||||||
"file" are returned.
|
"file" are returned.
|
||||||
|
|
||||||
*getjumplist()*
|
getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
|
||||||
getjumplist([{winnr} [, {tabnr}]])
|
|
||||||
Returns the |jumplist| for the specified window.
|
Returns the |jumplist| for the specified window.
|
||||||
|
|
||||||
Without arguments use the current window.
|
Without arguments use the current window.
|
||||||
|
@ -6961,6 +6961,56 @@ static void assert_equal_common(typval_T *argvars, assert_type_T atype)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void assert_equalfile(typval_T *argvars)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
char buf1[NUMBUFLEN];
|
||||||
|
char buf2[NUMBUFLEN];
|
||||||
|
const char *const fname1 = tv_get_string_buf_chk(&argvars[0], buf1);
|
||||||
|
const char *const fname2 = tv_get_string_buf_chk(&argvars[1], buf2);
|
||||||
|
garray_T ga;
|
||||||
|
|
||||||
|
if (fname1 == NULL || fname2 == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IObuff[0] = NUL;
|
||||||
|
FILE *const fd1 = os_fopen(fname1, READBIN);
|
||||||
|
if (fd1 == NULL) {
|
||||||
|
snprintf((char *)IObuff, IOSIZE, (char *)e_notread, fname1);
|
||||||
|
} else {
|
||||||
|
FILE *const fd2 = os_fopen(fname2, READBIN);
|
||||||
|
if (fd2 == NULL) {
|
||||||
|
fclose(fd1);
|
||||||
|
snprintf((char *)IObuff, IOSIZE, (char *)e_notread, fname2);
|
||||||
|
} else {
|
||||||
|
for (int64_t count = 0; ; count++) {
|
||||||
|
const int c1 = fgetc(fd1);
|
||||||
|
const int c2 = fgetc(fd2);
|
||||||
|
if (c1 == EOF) {
|
||||||
|
if (c2 != EOF) {
|
||||||
|
STRCPY(IObuff, "first file is shorter");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else if (c2 == EOF) {
|
||||||
|
STRCPY(IObuff, "second file is shorter");
|
||||||
|
break;
|
||||||
|
} else if (c1 != c2) {
|
||||||
|
snprintf((char *)IObuff, IOSIZE,
|
||||||
|
"difference at byte %" PRId64, count);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (IObuff[0] != NUL) {
|
||||||
|
prepare_assert_error(&ga);
|
||||||
|
ga_concat(&ga, IObuff);
|
||||||
|
assert_error(&ga);
|
||||||
|
ga_clear(&ga);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void f_assert_beeps(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_assert_beeps(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
const char *const cmd = tv_get_string_chk(&argvars[0]);
|
const char *const cmd = tv_get_string_chk(&argvars[0]);
|
||||||
@ -6988,6 +7038,12 @@ static void f_assert_equal(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
assert_equal_common(argvars, ASSERT_EQUAL);
|
assert_equal_common(argvars, ASSERT_EQUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "assert_equalfile(fname-one, fname-two)" function
|
||||||
|
static void f_assert_equalfile(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
|
{
|
||||||
|
assert_equalfile(argvars);
|
||||||
|
}
|
||||||
|
|
||||||
// "assert_notequal(expected, actual[, msg])" function
|
// "assert_notequal(expected, actual[, msg])" function
|
||||||
static void f_assert_notequal(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_assert_notequal(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,7 @@ return {
|
|||||||
asin={args=1, func="float_op_wrapper", data="&asin"}, -- WJMc
|
asin={args=1, func="float_op_wrapper", data="&asin"}, -- WJMc
|
||||||
assert_beeps={args={1, 2}},
|
assert_beeps={args={1, 2}},
|
||||||
assert_equal={args={2, 3}},
|
assert_equal={args={2, 3}},
|
||||||
|
assert_equalfile={args=2},
|
||||||
assert_exception={args={1, 2}},
|
assert_exception={args={1, 2}},
|
||||||
assert_fails={args={1, 2}},
|
assert_fails={args={1, 2}},
|
||||||
assert_false={args={1, 2}},
|
assert_false={args={1, 2}},
|
||||||
|
@ -1,5 +1,40 @@
|
|||||||
" Test that the methods used for testing work.
|
" Test that the methods used for testing work.
|
||||||
|
|
||||||
|
func Test_assert_equalfile()
|
||||||
|
call assert_equalfile('abcabc', 'xyzxyz')
|
||||||
|
call assert_match("E485: Can't read file abcabc", v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
|
let goodtext = ["one", "two", "three"]
|
||||||
|
call writefile(goodtext, 'Xone')
|
||||||
|
call assert_equalfile('Xone', 'xyzxyz')
|
||||||
|
call assert_match("E485: Can't read file xyzxyz", v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
|
call writefile(goodtext, 'Xtwo')
|
||||||
|
call assert_equalfile('Xone', 'Xtwo')
|
||||||
|
|
||||||
|
call writefile([goodtext[0]], 'Xone')
|
||||||
|
call assert_equalfile('Xone', 'Xtwo')
|
||||||
|
call assert_match("first file is shorter", v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
|
call writefile(goodtext, 'Xone')
|
||||||
|
call writefile([goodtext[0]], 'Xtwo')
|
||||||
|
call assert_equalfile('Xone', 'Xtwo')
|
||||||
|
call assert_match("second file is shorter", v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
|
call writefile(['1234X89'], 'Xone')
|
||||||
|
call writefile(['1234Y89'], 'Xtwo')
|
||||||
|
call assert_equalfile('Xone', 'Xtwo')
|
||||||
|
call assert_match("difference at byte 4", v:errors[0])
|
||||||
|
call remove(v:errors, 0)
|
||||||
|
|
||||||
|
call delete('Xone')
|
||||||
|
call delete('Xtwo')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_assert_fails_in_try_block()
|
func Test_assert_fails_in_try_block()
|
||||||
try
|
try
|
||||||
call assert_equal(0, assert_fails('throw "error"'))
|
call assert_equal(0, assert_fails('throw "error"'))
|
||||||
|
Loading…
Reference in New Issue
Block a user