aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/function_sort_spec.lua
diff options
context:
space:
mode:
authorwatiko <service@mail.watiko.net>2016-02-20 19:48:31 +0900
committerwatiko <service@mail.watiko.net>2016-03-02 17:32:24 +0900
commit29a1807de8986fa3b8416f3d73c26fda91bce403 (patch)
tree64720ff4b1b7e80f368b899bc9b01e2d4b0e511a /test/functional/legacy/function_sort_spec.lua
parent04ff218c1627e0cac68266c454fcc816a0ddedd1 (diff)
downloadrneovim-29a1807de8986fa3b8416f3d73c26fda91bce403.tar.gz
rneovim-29a1807de8986fa3b8416f3d73c26fda91bce403.tar.bz2
rneovim-29a1807de8986fa3b8416f3d73c26fda91bce403.zip
tests: Migrate legacy test sort
Diffstat (limited to 'test/functional/legacy/function_sort_spec.lua')
-rw-r--r--test/functional/legacy/function_sort_spec.lua29
1 files changed, 29 insertions, 0 deletions
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)