" development/tests/test-vars-vim.vim — exercises the vimwiki compat shim " (autoload/vimwiki/vars.vim) that third-party plugins call. " " Sourced by test-vars-vim.sh under headless Vim. Writes PASS/FAIL lines to " $NUWIKI_VARS_OUT; the shell wrapper fails on any FAIL (or missing output). let s:out = [] let s:dir_a = $NUWIKI_VARS_DIR_A let s:dir_b = $NUWIKI_VARS_DIR_B function! s:check(desc, got, want) abort if a:got ==# a:want call add(s:out, 'PASS ' . a:desc) else call add(s:out, 'FAIL ' . a:desc . ' got=[' . a:got . '] want=[' . a:want . ']') endif endfunction " ----- multi-wiki: explicit index ----- let g:nuwiki_wikis = [ \ {'root': s:dir_a, 'file_extension': 'wiki', 'syntax': 'markdown'}, \ {'root': s:dir_b, 'file_extension': '.wiki'}, \ ] let g:nuwiki_syntax = 'vimwiki' call s:check('idx0 path', vimwiki#vars#get_wikilocal('path', 0), s:dir_a . '/') call s:check('idx0 ext', vimwiki#vars#get_wikilocal('ext', 0), '.wiki') call s:check('idx0 syntax', vimwiki#vars#get_wikilocal('syntax', 0), 'markdown') " wiki[1] doesn't set syntax → global default call s:check('idx1 path', vimwiki#vars#get_wikilocal('path', 1), s:dir_b . '/') call s:check('idx1 syntax', vimwiki#vars#get_wikilocal('syntax', 1), 'vimwiki') " out-of-range clamps to first wiki call s:check('idx9 clamp', vimwiki#vars#get_wikilocal('path', 9), s:dir_a . '/') " misc keys call s:check('is_temporary', vimwiki#vars#get_wikilocal('is_temporary_wiki', 0) . '', '0') call s:check('unknown key', vimwiki#vars#get_wikilocal('bogus', 0), '') " ----- no index: resolve the wiki owning the current buffer ----- " (this is the BufRead path; regression guard for the s:resolve_index E121.) execute 'edit ' . fnameescape(s:dir_b . '/index.wiki') call s:check('noarg owning wiki_b', vimwiki#vars#get_wikilocal('path'), s:dir_b . '/') execute 'edit ' . fnameescape(s:dir_a . '/index.wiki') call s:check('noarg owning wiki_a', vimwiki#vars#get_wikilocal('path'), s:dir_a . '/') " buffer outside any wiki → first wiki enew call s:check('noarg outside→first', vimwiki#vars#get_wikilocal('path'), s:dir_a . '/') " ----- single-wiki shorthand (no g:nuwiki_wikis) ----- unlet g:nuwiki_wikis let g:nuwiki_wiki_root = s:dir_a let g:nuwiki_file_extension = 'txt' enew call s:check('shorthand path', vimwiki#vars#get_wikilocal('path'), s:dir_a . '/') call s:check('shorthand ext', vimwiki#vars#get_wikilocal('ext'), '.txt') call s:check('shorthand syntax', vimwiki#vars#get_wikilocal('syntax'), 'vimwiki') call writefile(s:out, $NUWIKI_VARS_OUT)