forked from Archives/tmpl.vim
Add vader tests
parent
baf582735c
commit
2062b9f765
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# vim: set filetype=sh noexpandtab ts=2 sts=2 sw=2 foldmethod=marker:
|
||||||
|
# vim: set foldmarker=[[[,]]]:
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "${0}")"
|
||||||
|
|
||||||
|
${VIM_BIN:-nvim} -Nu test_vimrc.vim -c 'Vader! *'
|
@ -0,0 +1,26 @@
|
|||||||
|
# Simple date
|
||||||
|
Given (date template):
|
||||||
|
<# DATE #>
|
||||||
|
|
||||||
|
Execute (run variable replacement):
|
||||||
|
let datestr = strftime('%Y-%m-%d')
|
||||||
|
call tmpl#ExpandTmplVars()
|
||||||
|
AssertEqual getline(1), datestr
|
||||||
|
|
||||||
|
# Year
|
||||||
|
Given (year template):
|
||||||
|
<# YEAR #>
|
||||||
|
|
||||||
|
Execute (run variable replacement):
|
||||||
|
let datestr = strftime('%Y')
|
||||||
|
call tmpl#ExpandTmplVars()
|
||||||
|
AssertEqual getline(1), datestr
|
||||||
|
|
||||||
|
# Time
|
||||||
|
Given (time template):
|
||||||
|
<# TIME #>
|
||||||
|
|
||||||
|
Execute (run variable replacement):
|
||||||
|
let datestr = strftime('%H:%M:%S')
|
||||||
|
call tmpl#ExpandTmplVars()
|
||||||
|
AssertEqual getline(1), datestr
|
@ -0,0 +1,29 @@
|
|||||||
|
Given (include MIT license):
|
||||||
|
<$ LICENSE.MIT $>
|
||||||
|
|
||||||
|
Execute (run variable replacement):
|
||||||
|
call tmpl#ExpandIncludeVars()
|
||||||
|
$d
|
||||||
|
|
||||||
|
Expect (MIT license):
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (C) <# YEAR #> by <# AUTHOR #>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
@ -0,0 +1,8 @@
|
|||||||
|
Given (variable with no replacement):
|
||||||
|
<# I_DO_NOT_EXIST #>
|
||||||
|
|
||||||
|
Execute (run variable replacement):
|
||||||
|
call tmpl#ExpandTmplVars()
|
||||||
|
|
||||||
|
Expect (no change):
|
||||||
|
<# I_DO_NOT_EXIST #>
|
@ -0,0 +1,10 @@
|
|||||||
|
Given (template variables):
|
||||||
|
<# AUTHOR #>
|
||||||
|
<# WHOAMI #>
|
||||||
|
|
||||||
|
Execute (run variable replacement):
|
||||||
|
call tmpl#ExpandTmplVars()
|
||||||
|
|
||||||
|
Expect (replaced variables):
|
||||||
|
jgoguen
|
||||||
|
A test
|
@ -0,0 +1,12 @@
|
|||||||
|
filetype off
|
||||||
|
let s:tmplvim_dir = expand('%:p:h:h')
|
||||||
|
let s:vader_dir = printf('%s/../vader.vim', s:tmplvim_dir)
|
||||||
|
let &runtimepath = s:tmplvim_dir.','.&runtimepath
|
||||||
|
if isdirectory(s:vader_dir)
|
||||||
|
let &runtimepath .= ','.s:vader_dir
|
||||||
|
endif
|
||||||
|
filetype plugin indent on
|
||||||
|
syntax enable
|
||||||
|
set nomore
|
||||||
|
set noswapfile
|
||||||
|
set viminfo=
|
@ -0,0 +1,10 @@
|
|||||||
|
Before:
|
||||||
|
let g:tmplvim_author = 'jgoguen'
|
||||||
|
let g:tmplvim_template_vars = {'WHOAMI': 'A test'}
|
||||||
|
|
||||||
|
Include (static variable tests): suites/template_static_vars.vader
|
||||||
|
Include (date variable tests): suites/date_vars.vader
|
||||||
|
|
||||||
|
Include (file include tests): suites/include_file.vader
|
||||||
|
|
||||||
|
Include (var does not exist): suites/no_such_var.vader
|
Loading…
Reference in New Issue