diff options
author | w0rp <devw0rp@gmail.com> | 2017-05-30 22:15:24 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-05-30 22:15:24 +0100 |
commit | b9f4b0373a62266ea5eadd3c90a47e82df995391 (patch) | |
tree | da74d7f529c4198351dbed579f5a0a7ffbd45114 /test | |
parent | 6ec965c8e4618c14b05b05bd554b3fed9c1191e1 (diff) | |
download | ale-b9f4b0373a62266ea5eadd3c90a47e82df995391.zip |
#591 Store buffer variables when fixing filess, and read them back in ale#Var
Diffstat (limited to 'test')
-rw-r--r-- | test/test_ale_fix.vader | 24 | ||||
-rw-r--r-- | test/test_ale_var.vader | 20 |
2 files changed, 44 insertions, 0 deletions
diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader index b4ffc062..5421dcfc 100644 --- a/test/test_ale_fix.vader +++ b/test/test_ale_fix.vader @@ -11,6 +11,7 @@ Before: let g:ale_enabled = 0 let g:ale_echo_cursor = 0 let g:ale_run_synchronously = 1 + let g:ale_fix_buffer_data = {} let g:ale_fixers = { \ 'testft': [], \} @@ -75,6 +76,8 @@ After: call delete('fix_test_file') endif + let g:ale_fix_buffer_data = {} + Given testft (A file with three lines): a b @@ -291,3 +294,24 @@ Expect(The buffer should be the same): a b c + +Given testft (A file with three lines): + a + b + c + +Execute(ale#fix#InitBufferData() should set up the correct data): + noautocmd silent file fix_test_file + + call ale#fix#InitBufferData(bufnr(''), 'save_file') + + AssertEqual { + \ bufnr(''): { + \ 'temporary_directory_list': [], + \ 'vars': b:, + \ 'filename': simplify(getcwd() . '/fix_test_file'), + \ 'done': 0, + \ 'lines_before': ['a', 'b', 'c'], + \ 'should_save': 1, + \ }, + \}, g:ale_fix_buffer_data diff --git a/test/test_ale_var.vader b/test/test_ale_var.vader index 576b403f..fb674d93 100644 --- a/test/test_ale_var.vader +++ b/test/test_ale_var.vader @@ -3,6 +3,9 @@ Before: After: unlet! g:ale_some_variable + unlet! b:undefined_variable_name + + let g:ale_fix_buffer_data = {} Execute(ale#Var should return global variables): AssertEqual 'abc', ale#Var(bufnr(''), 'some_variable') @@ -18,4 +21,21 @@ Execute(ale#Var should return buffer overrides for buffer numbers as strings): AssertEqual 'def', ale#Var(string(bufnr('')), 'some_variable') Execute(ale#Var should throw exceptions for undefined variables): + let b:undefined_variable_name = 'def' + AssertThrows call ale#Var(bufnr(''), 'undefined_variable_name') + +Execute(ale#Var return variables from deleted buffers, saved for fixing things): + let g:ale_fix_buffer_data[1347347] = {'vars': {'ale_some_variable': 'def'}} + + AssertEqual 'def', ale#Var(1347347, 'some_variable') + +Execute(ale#Var should return the global variable for unknown variables): + let g:ale_fix_buffer_data = {} + + AssertEqual 'abc', ale#Var(1347347, 'some_variable') + +Execute(ale#Var should return the global variables when the ALE fix variable is undefined): + unlet! g:ale_fix_buffer_data + + AssertEqual 'abc', ale#Var(1347347, 'some_variable') |