view src/testdir/test_sort.vim @ 8023:75e0831549f1 v7.4.1306

commit https://github.com/vim/vim/commit/76467dfcafcf295fd987f712730774c6f55317d3 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 12 19:30:26 2016 +0100 patch 7.4.1306 Problem: Job control doesn't work well on MS-Windows. Solution: Various fixes. (Ken Takata, Ozaki Kiichi , Yukihiro Nakadaira, Yasuhiro Matsumoto)
author Christian Brabandt <cb@256bit.org>
date Fri, 12 Feb 2016 19:45:05 +0100
parents 20dc2763a3b9
children c16aa03d8db5
line wrap: on
line source

" 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