2015-11-29 17:35:35 +01:00
|
|
|
" Test that the methods used for testing work.
|
|
|
|
|
|
2015-11-30 21:38:24 +01:00
|
|
|
func Test_assert_false()
|
|
|
|
|
call assert_false(0)
|
2016-02-06 20:29:28 +01:00
|
|
|
call assert_false(v:false)
|
2015-11-29 17:35:35 +01:00
|
|
|
endfunc
|
|
|
|
|
|
2015-11-30 21:38:24 +01:00
|
|
|
func Test_assert_true()
|
|
|
|
|
call assert_true(1)
|
|
|
|
|
call assert_true(123)
|
2016-02-06 20:29:28 +01:00
|
|
|
call assert_true(v:true)
|
2015-11-29 17:35:35 +01:00
|
|
|
endfunc
|
|
|
|
|
|
2015-11-30 21:38:24 +01:00
|
|
|
func Test_assert_equal()
|
2015-11-29 17:35:35 +01:00
|
|
|
let s = 'foo'
|
2015-11-30 21:38:24 +01:00
|
|
|
call assert_equal('foo', s)
|
2015-11-29 17:35:35 +01:00
|
|
|
let n = 4
|
2015-11-30 21:38:24 +01:00
|
|
|
call assert_equal(4, n)
|
2015-11-29 17:35:35 +01:00
|
|
|
let l = [1, 2, 3]
|
2015-11-30 21:38:24 +01:00
|
|
|
call assert_equal([1, 2, 3], l)
|
2015-11-29 17:35:35 +01:00
|
|
|
endfunc
|
2015-12-31 20:46:39 +01:00
|
|
|
|
2016-01-19 14:31:20 +01:00
|
|
|
func Test_assert_exception()
|
|
|
|
|
try
|
|
|
|
|
nocommand
|
|
|
|
|
catch
|
|
|
|
|
call assert_exception('E492:')
|
|
|
|
|
endtry
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
nocommand
|
|
|
|
|
catch
|
|
|
|
|
try
|
|
|
|
|
" illegal argument, get NULL for error
|
|
|
|
|
call assert_exception([])
|
|
|
|
|
catch
|
|
|
|
|
call assert_exception('E730:')
|
|
|
|
|
endtry
|
|
|
|
|
endtry
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-01-31 16:28:04 +01:00
|
|
|
func Test_wrong_error_type()
|
|
|
|
|
let save_verrors = v:errors
|
|
|
|
|
let v:['errors'] = {'foo': 3}
|
|
|
|
|
call assert_equal('yes', 'no')
|
|
|
|
|
let verrors = v:errors
|
|
|
|
|
let v:errors = save_verrors
|
|
|
|
|
call assert_equal(type([]), type(verrors))
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-03-15 12:55:58 +01:00
|
|
|
func Test_compare_fail()
|
|
|
|
|
let s:v = {}
|
|
|
|
|
let s:x = {"a": s:v}
|
|
|
|
|
let s:v["b"] = s:x
|
|
|
|
|
let s:w = {"c": s:x, "d": ''}
|
|
|
|
|
try
|
|
|
|
|
call assert_equal(s:w, '')
|
|
|
|
|
catch
|
|
|
|
|
call assert_exception('E724:')
|
|
|
|
|
call assert_true(v:errors[0] =~ "Expected NULL but got ''")
|
|
|
|
|
call remove(v:errors, 0)
|
|
|
|
|
endtry
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-03-15 13:33:55 +01:00
|
|
|
func Test_assert_fail_fails()
|
|
|
|
|
call assert_fails('xxx', {})
|
|
|
|
|
call assert_true(v:errors[0] =~ "Expected {} but got 'E731:")
|
|
|
|
|
call remove(v:errors, 0)
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-03-15 12:55:58 +01:00
|
|
|
|
2015-12-31 20:46:39 +01:00
|
|
|
func Test_user_is_happy()
|
|
|
|
|
smile
|
|
|
|
|
sleep 300m
|
|
|
|
|
endfunc
|