diff options
author | roel0 <roel.postelmans@altran.com> | 2018-03-27 10:18:24 +0200 |
---|---|---|
committer | roel0 <roel.postelmans@altran.com> | 2018-03-27 10:18:24 +0200 |
commit | dfb3e194d7a05b747c77d312a72e5149595bbcef (patch) | |
tree | c98cf493af29ceabaaa2e63ab3a014c30e609ca6 /test/test_c_parse_makefile.vader | |
parent | cf62ef7b070c08bc6858aa88f0ff45be56b7c9b7 (diff) | |
download | ale-dfb3e194d7a05b747c77d312a72e5149595bbcef.zip |
Extended unit tests + simplified parsing algoritme #1167
Diffstat (limited to 'test/test_c_parse_makefile.vader')
-rw-r--r-- | test/test_c_parse_makefile.vader | 100 |
1 files changed, 85 insertions, 15 deletions
diff --git a/test/test_c_parse_makefile.vader b/test/test_c_parse_makefile.vader index f1988ec8..7c2fc21e 100644 --- a/test/test_c_parse_makefile.vader +++ b/test/test_c_parse_makefile.vader @@ -25,7 +25,7 @@ Execute(The CFlags parser should be able to parse include directives): call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') AssertEqual - \ ['-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')] + \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))] \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -c file.c') Execute(The CFlags parser should be able to parse macro directives): @@ -34,7 +34,7 @@ Execute(The CFlags parser should be able to parse macro directives): call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') AssertEqual - \ ['-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'), + \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), \ '-DTEST=1'] \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=1 -c file.c') @@ -44,7 +44,7 @@ Execute(The CFlags parser should be able to parse macro directives with spaces): call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') AssertEqual - \ ['-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'), + \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), \ '-DTEST=$(( 2 * 4 ))'] \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=$(( 2 * 4 )) -c file.c') @@ -54,7 +54,7 @@ Execute(The CFlags parser should be able to parse shell directives with spaces): call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') AssertEqual - \ ['-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'), + \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), \ '-DTEST=`date +%s`'] \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=`date +%s` -c file.c') @@ -64,10 +64,10 @@ Execute(The CFlagsToList parser should be able to parse multiple cflags): call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') AssertEqual - \ ['-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'), + \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), \ '-DTEST=`date +%s`'] \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), - \ split('gcc -Isubdir -DTEST=`date +%s` -c file.c')) + \ split('gcc -Isubdir -DTEST=`date +%s` -c file.c', '-')) Execute(The CFlagsToList parser should be able to parse multiple cflags #2): runtime! ale_linters/c/gcc.vim @@ -75,13 +75,13 @@ Execute(The CFlagsToList parser should be able to parse multiple cflags #2): call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') AssertEqual - \ ['-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'), - \ '-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'), + \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')), \ '-DTEST=`date +%s`'] \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), \ split('gcc -Isubdir ' . \ '-I'. ale#path#Simplify('kernel/include') . - \ ' -DTEST=`date +%s` -c file.c')) + \ ' -DTEST=`date +%s` -c file.c', '-')) Execute(The CFlagsToList parser should be able to parse multiple cflags #3): runtime! ale_linters/c/gcc.vim @@ -90,13 +90,13 @@ Execute(The CFlagsToList parser should be able to parse multiple cflags #3): AssertEqual \ ['-Dgoal=9', - \ '-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'), - \ '-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')), \ '-DTEST=`date +%s`'] \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), \ split('gcc -Dgoal=9 -Isubdir ' . \ '-I'. ale#path#Simplify('kernel/include') . - \ ' -DTEST=`date +%s` -c file.c')) + \ ' -DTEST=`date +%s` -c file.c', '-')) Execute(The CFlagsToList parser should be able to parse multiple cflags #4): runtime! ale_linters/c/gcc.vim @@ -105,10 +105,80 @@ Execute(The CFlagsToList parser should be able to parse multiple cflags #4): AssertEqual \ ['-Dgoal=9', - \ '-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'), - \ '-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')), \ '-DTEST=`date +%s`'] \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' . \ '-I'. ale#path#Simplify('kernel/include') . - \ ' -DTEST=`date +%s` -c file.c')) + \ ' -DTEST=`date +%s` -c file.c', '-')) + +Execute(The CFlagsToList parser should be able to parse multiple cflags #5): + runtime! ale_linters/c/gcc.vim + + call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') + + AssertEqual + \ ['-Dgoal=9', + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')), + \ '-DTEST=`date +%s`'] + \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), + \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' . + \ '-I"dir with spaces"' . ' -I'. ale#path#Simplify('kernel/include') . + \ ' -DTEST=`date +%s` -c file.c', '-')) + +Execute(The CFlagsToList parser should be able to parse multiple cflags #6): + runtime! ale_linters/c/gcc.vim + + call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') + + AssertEqual + \ ['-Dgoal=9', + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')), + \ '-DTEST=`date +%s`'] + \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), + \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' . + \ '-I''dir with spaces''' . ' -I'. ale#path#Simplify('kernel/include') . + \ ' -DTEST=`date +%s` -c file.c', '-')) + +Execute(The CFlagsToList parser should be able to parse multiple cflags #7): + runtime! ale_linters/c/gcc.vim + + call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') + + AssertEqual + \ ['-Dgoal=9', + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir-with-dash')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')), + \ '-DTEST=`date +%s`'] + \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), + \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' . + \ '-I''dir with spaces''' . ' -Idir-with-dash' . + \ ' -I'. ale#path#Simplify('kernel/include') . + \ ' -DTEST=`date +%s` -c file.c', '-')) + +Execute(The CFlagsToList parser should be able to parse multiple cflags #8): + runtime! ale_linters/c/gcc.vim + + call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') + + AssertEqual + \ ['-Dgoal=9', + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')), + \ '-Dmacro-with-dash', + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir-with-dash')), + \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')), + \ '-DTEST=`date +%s`'] + \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'), + \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' . + \ '-Dmacro-with-dash ' . + \ '-I''dir with spaces''' . ' -Idir-with-dash' . + \ ' -I'. ale#path#Simplify('kernel/include') . + \ ' -DTEST=`date +%s` -c file.c', '-')) |