view src/testdir/test_sort.vim @ 7595:99e93f72ff91 v7.4.1097

commit https://github.com/vim/vim/commit/065ee9aebf9abe08ae8c0dba7d05cbdcc423c8e0 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 15 20:53:38 2016 +0100 patch 7.4.1097 Problem: Looking up the alloc ID for tests fails. Solution: Fix the line computation. Use assert_fails() for unlet test.
author Christian Brabandt <cb@256bit.org>
date Fri, 15 Jan 2016 21:00:07 +0100
parents 6ffc75d807bd
children 20dc2763a3b9
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