diff src/testdir/test_syn_attr.vim @ 8514:260d01c1cd17 v7.4.1547

commit https://github.com/vim/vim/commit/385111bd86e0b38667879c3e89506ca1ae98e1df Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 12 19:23:00 2016 +0100 patch 7.4.1547 Problem: Getting a cterm highlight attribute that is not set results in the string "-1". Solution: Return an empty string. (Taro Muraoka)
author Christian Brabandt <cb@256bit.org>
date Sat, 12 Mar 2016 19:30:04 +0100
parents
children 24ac80377d86
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_syn_attr.vim
@@ -0,0 +1,31 @@
+" Test syntax highlighting functions.
+
+func Test_missing_attr()
+  hi Mine term=bold cterm=italic
+  call assert_equal('Mine', synIDattr(hlID("Mine"), "name"))
+  call assert_equal('', synIDattr(hlID("Mine"), "bg", 'term'))
+  call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term'))
+  call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm'))
+  hi Mine term=reverse cterm=inverse
+  call assert_equal('1', synIDattr(hlID("Mine"), "reverse", 'term'))
+  call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm'))
+  hi Mine term=underline cterm=standout gui=undercurl
+  call assert_equal('1', synIDattr(hlID("Mine"), "underline", 'term'))
+  call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
+  call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui'))
+  hi Mine term=NONE cterm=NONE gui=NONE
+  call assert_equal('', synIDattr(hlID("Mine"), "bold", 'term'))
+  call assert_equal('', synIDattr(hlID("Mine"), "italic", 'cterm'))
+  call assert_equal('', synIDattr(hlID("Mine"), "reverse", 'term'))
+  call assert_equal('', synIDattr(hlID("Mine"), "inverse", 'cterm'))
+  call assert_equal('', synIDattr(hlID("Mine"), "underline", 'term'))
+  call assert_equal('', synIDattr(hlID("Mine"), "standout", 'cterm'))
+  call assert_equal('', synIDattr(hlID("Mine"), "undercurl", 'gui'))
+
+  if has('gui')
+    hi Mine guifg=blue guibg=red font=something
+    call assert_equal('blue', synIDattr(hlID("Mine"), "fg", 'gui'))
+    call assert_equal('red', synIDattr(hlID("Mine"), "bg", 'gui'))
+    call assert_equal('something', synIDattr(hlID("Mine"), "font", 'gui'))
+  endif
+endfunc