"============================================================================= " $Id: list.vim 520 2012-03-19 18:09:15Z luc.hermitte $ " File: tests/lh/list.vim {{{1 " Author: Luc Hermitte " " License: GPLv3 with exceptions " " Version: 3.0.0 " Created: 19th Nov 2008 " Last Update: $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ "------------------------------------------------------------------------ " Description: " Tests for autoload/lh/list.vim " "------------------------------------------------------------------------ " Installation: «install details» " History: «history» " TODO: «missing features» " }}}1 "============================================================================= UTSuite [lh-vim-lib] Testing lh#list functions runtime autoload/lh/function.vim runtime autoload/lh/list.vim let s:cpo_save=&cpo set cpo&vim "------------------------------------------------------------------------ " Find_if function! s:Test_Find_If_string_predicate() :let b = { 'min': 12, 'max': 42 } :let l = [ 1, 5, 48, 25, 5, 28, 6] :let i = lh#list#Find_if(l, 'v:val>v:1_.min && v:val12 && v:1_<42 && v:1_%2==0') " echo i . '/' . len(l) Assert i == 5 Assert l[i] == 28 " :echo l[i] endfunction function! s:Test_find_if_double_bind() :let b = { 'min': 12, 'max': 42 } :let l = [ 1, 5, 48, 25, 5, 28, 6] :let f = lh#function#bind( 'v:3_>v:1_.min && v:3_ 5") " Comment string(s) Assert s == expected endfunction "------------------------------------------------------------------------ " subset function! s:Test_subset() :let l = [ 1, 25, 5, 48, 25, 5, 28, 6] :let indices = [ 0, 5, 7, 3 ] :let expected = [ 1, 5, 6, 48 ] :let s = lh#list#subset(l, indices) " Comment string(s) Assert s == expected endfunction "------------------------------------------------------------------------ " intersect function! s:Test_intersect() :let l1 = [ 1, 25, 7, 48, 26, 5, 28, 6] :let l2 = [ 3, 8, 7, 25, 6 ] :let expected = [ 25, 7, 6 ] :let s = lh#list#intersect(l1, l2) " Comment string(s) Assert s == expected endfunction "------------------------------------------------------------------------ let &cpo=s:cpo_save "============================================================================= " vim600: set fdm=marker: