comparison src/testdir/test_functions.vim @ 22232:f22acf6472da v8.2.1665

patch 8.2.1665: cannot do fuzzy string matching Commit: https://github.com/vim/vim/commit/635414dd2f3ae7d4d972d79b806348a6516cb91a Author: Bram Moolenaar <Bram@vim.org> Date: Fri Sep 11 22:25:15 2020 +0200 patch 8.2.1665: cannot do fuzzy string matching Problem: Cannot do fuzzy string matching. Solution: Add matchfuzzy(). (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6932)
author Bram Moolenaar <Bram@vim.org>
date Fri, 11 Sep 2020 22:30:04 +0200
parents ff21e2962490
children 0491b9cafd44
comparison
equal deleted inserted replaced
22231:e1311fb42cd4 22232:f22acf6472da
2552 func Test_browsedir() 2552 func Test_browsedir()
2553 CheckFeature browse 2553 CheckFeature browse
2554 call assert_fails('call browsedir("open", [])', 'E730:') 2554 call assert_fails('call browsedir("open", [])', 'E730:')
2555 endfunc 2555 endfunc
2556 2556
2557 " Test for matchfuzzy()
2558 func Test_matchfuzzy()
2559 call assert_fails('call matchfuzzy(10, "abc")', 'E714:')
2560 call assert_fails('call matchfuzzy(["abc"], [])', 'E730:')
2561 call assert_equal([], matchfuzzy([], 'abc'))
2562 call assert_equal([], matchfuzzy(['abc'], ''))
2563 call assert_equal(['abc'], matchfuzzy(['abc', 10], 'ac'))
2564 call assert_equal([], matchfuzzy([10, 20], 'ac'))
2565 call assert_equal(['abc'], matchfuzzy(['abc'], 'abc'))
2566 call assert_equal(['crayon', 'camera'], matchfuzzy(['camera', 'crayon'], 'cra'))
2567 call assert_equal(['aabbaa', 'aaabbbaaa', 'aaaabbbbaaaa', 'aba'], matchfuzzy(['aba', 'aabbaa', 'aaabbbaaa', 'aaaabbbbaaaa'], 'aa'))
2568 call assert_equal(['one'], matchfuzzy(['one', 'two'], 'one'))
2569 call assert_equal(['oneTwo', 'onetwo'], matchfuzzy(['onetwo', 'oneTwo'], 'oneTwo'))
2570 call assert_equal(['one_two', 'onetwo'], matchfuzzy(['onetwo', 'one_two'], 'oneTwo'))
2571 call assert_equal(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], matchfuzzy(['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], 'aa'))
2572 call assert_equal([], matchfuzzy([repeat('a', 300)], repeat('a', 257)))
2573
2574 %bw!
2575 eval ['somebuf', 'anotherone', 'needle', 'yetanotherone']->map({_, v -> bufadd(v) + bufload(v)})
2576 let l = getbufinfo()->map({_, v -> v.name})->matchfuzzy('ndl')
2577 call assert_equal(1, len(l))
2578 call assert_match('needle', l[0])
2579 endfunc
2580
2557 " vim: shiftwidth=2 sts=2 expandtab 2581 " vim: shiftwidth=2 sts=2 expandtab