comparison src/testdir/test_syntax.vim @ 13304:013c44d9dc09 v8.0.1526

patch 8.0.1526: no test using a screen dump yet commit https://github.com/vim/vim/commit/da65058a9c4774dc534c7ae98d24c58b5db669fa Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 20 15:51:40 2018 +0100 patch 8.0.1526: no test using a screen dump yet Problem: No test using a screen dump yet. Solution: Add a test for C syntax highlighting. Add helper functions.
author Christian Brabandt <cb@256bit.org>
date Tue, 20 Feb 2018 16:00:06 +0100
parents 3cf157856dc8
children 5a85a4b85507
comparison
equal deleted inserted replaced
13303:b97157007be1 13304:013c44d9dc09
3 if !has("syntax") 3 if !has("syntax")
4 finish 4 finish
5 endif 5 endif
6 6
7 source view_util.vim 7 source view_util.vim
8 if has('terminal')
9 source screendump.vim
10 endif
8 11
9 func GetSyntaxItem(pat) 12 func GetSyntaxItem(pat)
10 let c = '' 13 let c = ''
11 let a = ['a', getreg('a'), getregtype('a')] 14 let a = ['a', getreg('a'), getregtype('a')]
12 0 15 0
495 syn clear 498 syn clear
496 set conceallevel& 499 set conceallevel&
497 bw! 500 bw!
498 endfunc 501 endfunc
499 502
500 fun Test_synstack_synIDtrans() 503 func Test_synstack_synIDtrans()
501 new 504 new
502 setfiletype c 505 setfiletype c
503 syntax on 506 syntax on
504 call setline(1, ' /* A comment with a TODO */') 507 call setline(1, ' /* A comment with a TODO */')
505 508
518 call assert_equal(['Comment', 'Todo'], map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")')) 521 call assert_equal(['Comment', 'Todo'], map(synstack(line("."), col(".")), 'synIDattr(synIDtrans(v:val), "name")'))
519 522
520 syn clear 523 syn clear
521 bw! 524 bw!
522 endfunc 525 endfunc
526
527 " Check highlighting for a small piece of C code with a screen dump.
528 func Test_syntax_c()
529 if !has('terminal')
530 return
531 endif
532 call writefile([
533 \ '/* comment line at the top */',
534 \ ' int',
535 \ 'main(int argc, char **argv)// another comment',
536 \ '{',
537 \ '#if 0',
538 \ ' int not_used;',
539 \ '#else',
540 \ ' int used;',
541 \ '#endif',
542 \ ' printf("Just an example piece of C code\n");',
543 \ ' return 0x0ff;',
544 \ '}',
545 \ ' static void',
546 \ 'myFunction(const double count, struct nothing, long there) {',
547 \ ' // 123: nothing to read here',
548 \ ' for (int i = 0; i < count; ++i) {',
549 \ ' break;',
550 \ ' }',
551 \ '}',
552 \ ], 'Xtest.c')
553 let buf = RunVimInTerminal('Xtest.c', {})
554 call VerifyScreenDump(buf, 'Test_syntax_c_01')
555 call StopVimInTerminal(buf)
556
557 call delete('Xtest.c')
558 endfun