diff options
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_sort.vim | 23 | ||||
-rw-r--r-- | test/functional/legacy/function_sort_spec.lua | 29 |
3 files changed, 29 insertions, 24 deletions
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index ea2a19a08f..1d1da94bac 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -1,4 +1,3 @@ " A series of tests that can run in one Vim invocation. " This makes testing go faster, since Vim doesn't need to restart. -source test_sort.vim diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim deleted file mode 100644 index 32ad7f8ad5..0000000000 --- a/src/nvim/testdir/test_sort.vim +++ /dev/null @@ -1,23 +0,0 @@ -" Test sort() - -func Test_sort_strings() - " numbers compared as strings - call assert_equal([1, 2, 3], sort([3, 2, 1])) - call assert_equal([13, 28, 3], sort([3, 28, 13])) -endfunc - -func Test_sort_numeric() - call assert_equal([1, 2, 3], sort([3, 2, 1], 'n')) - call assert_equal([3, 13, 28], sort([13, 28, 3], 'n')) - " strings are not sorted - call assert_equal(['13', '28', '3'], sort(['13', '28', '3'], 'n')) -endfunc - -func Test_sort_numbers() - call assert_equal([3, 13, 28], sort([13, 28, 3], 'N')) - call assert_equal(['3', '13', '28'], sort(['13', '28', '3'], 'N')) -endfunc - -func Test_sort_float() - call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f')) -endfunc diff --git a/test/functional/legacy/function_sort_spec.lua b/test/functional/legacy/function_sort_spec.lua new file mode 100644 index 0000000000..9083911021 --- /dev/null +++ b/test/functional/legacy/function_sort_spec.lua @@ -0,0 +1,29 @@ +local helpers = require('test.functional.helpers') +local clear = helpers.clear +local eq = helpers.eq +local eval = helpers.eval + +describe('sort', function() + before_each(clear) + + it('numbers compared as strings', function() + eq({1, 2, 3}, eval('sort([3, 2, 1])')) + eq({13, 28, 3}, eval('sort([3, 28, 13])')) + end) + + it('numbers compared as numeric', function() + eq({1, 2, 3}, eval("sort([3, 2, 1], 'n')")) + eq({3, 13, 28}, eval("sort([3, 28, 13], 'n')")) + -- Strings are not sorted. + eq({'13', '28', '3'}, eval("sort(['13', '28', '3'], 'n')")) + end) + + it('numbers compared as numbers', function() + eq({3, 13, 28}, eval("sort([13, 28, 3], 'N')")) + eq({'3', '13', '28'}, eval("sort(['13', '28', '3'], 'N')")) + end) + + it('numbers compared as float', function() + eq({0.28, 3, 13.5}, eval("sort([13.5, 0.28, 3], 'f')")) + end) +end) |