From c11a6613625008c7d45702301cdf404873674c58 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Tue, 1 Sep 2020 22:00:55 -0400 Subject: feat: new fuzzy sorter --- lua/tests/telescope_spec.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lua/tests') diff --git a/lua/tests/telescope_spec.lua b/lua/tests/telescope_spec.lua index 8d20c5d..4579902 100644 --- a/lua/tests/telescope_spec.lua +++ b/lua/tests/telescope_spec.lua @@ -237,13 +237,25 @@ describe('Sorters', function() it('sort matches well', function() local sorter = require('telescope.sorters').get_fuzzy_file() - local exact_match = sorter:score('hello', 'hello') + local exact_match = sorter:score('abcdef', 'abcdef') local no_match = sorter:score('abcdef', 'ghijkl') local ok_match = sorter:score('abcdef', 'ab') - assert(exact_match < no_match) - assert(exact_match < ok_match) - assert(ok_match < no_match) + assert( + exact_match < no_match, + string.format("Exact match better than no match: %s %s", exact_match, no_match) + ) + assert(exact_match < ok_match, "Exact match better than OK match") + assert(ok_match < no_match, "OK match better than no match") + end) + + it('sorts matches after last os sep better', function() + local sorter = require('telescope.sorters').get_fuzzy_file() + + local exact_match = sorter:score('aaa/bbb', 'aaa') + local ok_match = sorter:score('bbb/aaa', 'aaa') + + assert(exact_match < ok_match, "Exact match better than OK match") end) -- it('sorts multiple finds better', function() -- cgit v1.2.3