From 8b60368c1b9e23f0695557da170d416d71f7e6a3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 28 Mar 2021 11:15:19 -0400 Subject: vim-patch:8.1.0958: compiling weird regexp pattern is very slow Problem: Compiling weird regexp pattern is very slow. Solution: When reallocating post list increase size by 50%. (Kuang-che Wu, closes vim/vim#4012) Make assert_inrange() accept float values. https://github.com/vim/vim/commit/38f08e76acf7d21bb34cf8f79f0f82eb63cdc987 Omit changes to typval_compare() because patch v8.0.1505 was not ported. --- src/nvim/testdir/test_assert.vim | 31 +++++++++++++++++++++++++++++++ src/nvim/testdir/test_regexp_latin.vim | 11 +++++++++++ 2 files changed, 42 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_assert.vim b/src/nvim/testdir/test_assert.vim index b4f7478807..1d114221dc 100644 --- a/src/nvim/testdir/test_assert.vim +++ b/src/nvim/testdir/test_assert.vim @@ -52,6 +52,37 @@ func Test_assert_fails_in_try_block() endtry endfunc +func Test_assert_inrange() + call assert_equal(0, assert_inrange(7, 7, 7)) + call assert_equal(0, assert_inrange(5, 7, 5)) + call assert_equal(0, assert_inrange(5, 7, 6)) + call assert_equal(0, assert_inrange(5, 7, 7)) + call assert_equal(1, assert_inrange(5, 7, 4)) + call assert_match("Expected range 5 - 7, but got 4", v:errors[0]) + call remove(v:errors, 0) + call assert_equal(1, assert_inrange(5, 7, 8)) + call assert_match("Expected range 5 - 7, but got 8", v:errors[0]) + call remove(v:errors, 0) + + call assert_fails('call assert_inrange(1, 1)', 'E119:') + + if has('float') + call assert_equal(0, assert_inrange(7.0, 7, 7)) + call assert_equal(0, assert_inrange(7, 7.0, 7)) + call assert_equal(0, assert_inrange(7, 7, 7.0)) + call assert_equal(0, assert_inrange(5, 7, 5.0)) + call assert_equal(0, assert_inrange(5, 7, 6.0)) + call assert_equal(0, assert_inrange(5, 7, 7.0)) + + call assert_equal(1, assert_inrange(5, 7, 4.0)) + call assert_match("Expected range 5.0 - 7.0, but got 4.0", v:errors[0]) + call remove(v:errors, 0) + call assert_equal(1, assert_inrange(5, 7, 8.0)) + call assert_match("Expected range 5.0 - 7.0, but got 8.0", v:errors[0]) + call remove(v:errors, 0) + endif +endfunc + " Must be last. func Test_zz_quit_detected() " Verify that if a test function ends Vim the test script detects this. diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim index 1bb2ee53de..a1da5db778 100644 --- a/src/nvim/testdir/test_regexp_latin.vim +++ b/src/nvim/testdir/test_regexp_latin.vim @@ -39,6 +39,17 @@ func Test_range_with_newline() bwipe! endfunc +func Test_pattern_compile_speed() + if !exists('+spellcapcheck') || !has('reltime') + return + endif + let start = reltime() + " this used to be very slow, not it should be about a second + set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179} + call assert_inrange(0.01, 10.0, reltimefloat(reltime(start))) + set spc= +endfunc + func Test_get_equi_class() new " Incomplete equivalence class caused invalid memory access -- cgit From 3dbcf69888b0f44c06b9ede3928fcd9d68f65739 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 27 Mar 2021 01:39:45 -0400 Subject: test/old: run most tests in test_regexp_latin.vim Most tests here don't depend on 'set encoding=latin1'. Skip Test_recursive_addstate() because of ASAN build. --- src/nvim/testdir/Makefile | 5 +---- src/nvim/testdir/test_alot_latin.vim | 3 --- src/nvim/testdir/test_regexp_latin.vim | 5 ++++- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index b760828458..4641408069 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -31,14 +31,11 @@ endif SCRIPTS ?= $(SCRIPTS_DEFAULT) # Tests using runtest.vim. -NEW_TESTS_ALOT := test_alot_utf8 test_alot +NEW_TESTS_ALOT := test_alot_utf8 test_alot test_alot_latin NEW_TESTS_IN_ALOT := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' $(addsuffix .vim,$(NEW_TESTS_ALOT))) -NEW_TESTS_IN_ALOT_LATIN := $(shell sed -n '/^source/ s/^source //; s/\.vim$$//p' test_alot_latin.vim) # Ignored tests. -# test_alot_latin: Nvim does not allow setting encoding. # test_largefile: uses too much resources to run on CI. NEW_TESTS_IGNORE := \ - test_alot_latin $(NEW_TESTS_IN_ALOT_LATIN) \ test_largefile \ NEW_TESTS := $(sort $(basename $(notdir $(wildcard test_*.vim)))) diff --git a/src/nvim/testdir/test_alot_latin.vim b/src/nvim/testdir/test_alot_latin.vim index ebb3bde4ce..23a404cac1 100644 --- a/src/nvim/testdir/test_alot_latin.vim +++ b/src/nvim/testdir/test_alot_latin.vim @@ -4,7 +4,4 @@ " These tests use latin1 'encoding'. Setting 'encoding' is in the individual " files, so that they can be run by themselves. -" Nvim does not allow setting 'encoding', so skip this test group. -finish - source test_regexp_latin.vim diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim index a1da5db778..cacdd68d10 100644 --- a/src/nvim/testdir/test_regexp_latin.vim +++ b/src/nvim/testdir/test_regexp_latin.vim @@ -1,5 +1,5 @@ " Tests for regexp in latin1 encoding -set encoding=latin1 +" set encoding=latin1 scriptencoding latin1 func s:equivalence_test() @@ -22,11 +22,13 @@ func s:equivalence_test() endfunc func Test_equivalence_re1() + throw 'skipped: Nvim does not support enc=latin1' set re=1 call s:equivalence_test() endfunc func Test_equivalence_re2() + throw 'skipped: Nvim does not support enc=latin1' set re=2 call s:equivalence_test() endfunc @@ -98,6 +100,7 @@ func Test_multi_failure() endfunc func Test_recursive_addstate() + throw 'skipped: TODO: ' " This will call addstate() recursively until it runs into the limit. let lnum = search('\v((){328}){389}') call assert_equal(0, lnum) -- cgit From 4564f2c54f2ab3af500cc81a3802570b57123a51 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 28 Mar 2021 12:40:44 -0400 Subject: vim-patch:8.2.1621: crash when using submatch(0, 1) in substitute() Problem: Crash when using submatch(0, 1) in substitute(). Solution: Increment reference count. (closes vim/vim#6887) https://github.com/vim/vim/commit/8a0dcf43305586853f452a77fa295b0c8d54b463 N/A patches for version.c: vim-patch:8.2.2674: Motif: cancelling the font dialog resets the font Problem: Motif: cancelling the font dialog resets the font. Solution: When no font is selected to not change the font. (closes vim/vim#7825, closes vim/vim#8035) Fix compiler warnings. https://github.com/vim/vim/commit/9dbe701fe19597ad59c0e0c70a05927b587bea9f --- src/nvim/testdir/test_substitute.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim index 2a27f7a3a1..cc3bfe9f7f 100644 --- a/src/nvim/testdir/test_substitute.vim +++ b/src/nvim/testdir/test_substitute.vim @@ -746,3 +746,12 @@ func Test_sub_beyond_end() call assert_equal('#', getline(1)) bwipe! endfunc + +func Test_submatch_list_concatenate() + let pat = 'A\(.\)' + let Rep = {-> string([submatch(0, 1)] + [[submatch(1)]])} + " call substitute('A1', pat, Rep, '')->assert_equal("[['A1'], ['1']]") + call assert_equal(substitute('A1', pat, Rep, ''), "[['A1'], ['1']]") +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit