" Tests for defining text property types and adding text properties to the
" buffer.
source check.vim
CheckFeature textprop
source screendump.vim
func Test_proptype_global()
call prop_type_add('comment', {'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1})
let proptypes = prop_type_list()
call assert_equal(1, len(proptypes))
call assert_equal('comment', proptypes[0])
let proptype = prop_type_get('comment')
call assert_equal('Directory', proptype['highlight'])
call assert_equal(123, proptype['priority'])
call assert_equal(1, proptype['start_incl'])
call assert_equal(1, proptype['end_incl'])
call prop_type_delete('comment')
call assert_equal(0, len(prop_type_list()))
call prop_type_add('one', {})
call assert_equal(1, len(prop_type_list()))
let proptype = 'one'->prop_type_get()
call assert_false(has_key(proptype, 'highlight'))
call assert_equal(0, proptype['priority'])
call assert_equal(0, proptype['start_incl'])
call assert_equal(0, proptype['end_incl'])
call prop_type_add('two', {})
call assert_equal(2, len(prop_type_list()))
call prop_type_delete('one')
call assert_equal(1, len(prop_type_list()))
call prop_type_delete('two')
call assert_equal(0, len(prop_type_list()))
endfunc
func Test_proptype_buf()
let bufnr = bufnr('')
call prop_type_add('comment', {'bufnr': bufnr, 'highlight': 'Directory', 'priority': 123, 'start_incl': 1, 'end_incl': 1})
let proptypes = prop_type_list({'bufnr': bufnr})
call assert_equal(1, len(proptypes))
call assert_equal('comment', proptypes[0])
let proptype = prop_type_get('comment', {'bufnr': bufnr})
call assert_equal('Directory', proptype['highlight'])
call assert_equal(123, proptype['priority'])
call assert_equal(1, proptype['start_incl'])
call assert_equal(1, proptype['end_incl'])
call prop_type_delete('comment', {'bufnr': bufnr})
call assert_equal(0, len({'bufnr': bufnr}->prop_type_list()))
call prop_type_add('one', {'bufnr': bufnr})
let proptype = prop_type_get('one', {'bufnr': bufnr})
call assert_false(has_key(proptype, 'highlight'))
call assert_equal(0, proptype['priority'])
call assert_equal(0, proptype['start_incl'])
call assert_equal(0, proptype['end_incl'])
call prop_type_add('two', {'bufnr': bufnr})
call assert_equal(2, len(prop_type_list({'bufnr': bufnr})))
call prop_type_delete('one', {'bufnr': bufnr})
call assert_equal(1, len(prop_type_list({'bufnr': bufnr})))
call prop_type_delete('two', {'bufnr': bufnr})
call assert_equal(0, len(prop_type_list({'bufnr': bufnr})))
call assert_fails("call prop_type_add('one', {'bufnr': 98764})", "E158:")
endfunc
func AddPropTypes()
call prop_type_add('one', {})
call prop_type_add('two', {})
call prop_type_add('three', {})
call prop_type_add('whole', {})
endfunc
func DeletePropTypes()
call prop_type_delete('one')
call prop_type_delete('two')
call prop_type_delete('three')
call prop_type_delete('whole')
endfunc
func SetupPropsInFirstLine()
call setline(1, 'one two three')
call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one'})
eval 1->prop_add(5, {'length': 3, 'id': 12,