diff options
author | D. Ben Knoble <ben.knoble+github@gmail.com> | 2020-11-30 13:42:21 -0500 |
---|---|---|
committer | D. Ben Knoble <ben.knoble+github@gmail.com> | 2020-11-30 13:42:21 -0500 |
commit | 7e12be0c643857221fb0772ffceba9ff4cd66cc9 (patch) | |
tree | 2db8c638bc9e8d1c68e1751a48888918e4bd9e4e /test/test_code_action_python.vader | |
parent | 47da7483d8d4bbbe4022b9c0821d3a7d2d0afaaf (diff) | |
parent | 03b6978a270107b670b0363d50f3eed4b365ba26 (diff) | |
download | ale-7e12be0c643857221fb0772ffceba9ff4cd66cc9.zip |
Merge remote-tracking branch 'origin/master' into fix-swipl
* origin/master: (40 commits)
fix: correct suggested filetype for yamlfix
feat: add yamlfix fixer
Use _config for LSP config options
Add support for R languageserver (#3370)
Fix 3103 - add shellcheck shell directive detection. (#3216)
Added the Vundle command in installation instructions (#3400)
Adds support for Tlint - A Tighten Opinionated PHP Linter (#3291)
Add php phpcbf options (#3383)
Use has('gui_running') instead of has('gui')
Close #2727 - Add a hover-only setting for balloons
Fix #3332 - Modify everything for rename/actions
Add a missing blank line in documentation
Add luafmt fixer (#3289)
#3442 Fix code fix clangd issue
Close #1466 - Add GVIM refactor menu support
Look for node packages in .yarn/sdks as well
Update documentation for code actions and rename
cmp forwards, and reverse the code actions
Support for LSP/tsserver Code Actions (#3437)
Move the test for buffer-local variables
...
Diffstat (limited to 'test/test_code_action_python.vader')
-rw-r--r-- | test/test_code_action_python.vader | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/test_code_action_python.vader b/test/test_code_action_python.vader new file mode 100644 index 00000000..fd30633d --- /dev/null +++ b/test/test_code_action_python.vader @@ -0,0 +1,59 @@ +Given python(An example Python file): + def main(): + a = 1 + c = a + 1 + +Execute(): + let g:changes = [ + \ {'end': {'offset': 7, 'line': 1}, 'newText': 'func_qtffgsv', 'start': {'offset': 5, 'line': 1}}, + \ {'end': {'offset': 9, 'line': 1}, 'newText': '', 'start': {'offset': 8, 'line': 1}}, + \ {'end': {'offset': 15, 'line': 3}, 'newText': " return c\n\n\ndef main():\n c = func_qtffgsvi()\n", 'start': {'offset': 15, 'line': 3}} + \] + + call ale#code_action#ApplyChanges(expand('%:p'), g:changes, 0) + +Expect(The changes should be applied correctly): + def func_qtffgsvi(): + a = 1 + c = a + 1 + return c + + + def main(): + c = func_qtffgsvi() + + +Given python(Second python example): + import sys + import exifread + + def main(): + with open(sys.argv[1], 'rb') as f: + exif = exifread.process_file(f) + dt = str(exif['Image DateTime']) + date = dt[:10].replace(':', '-') + +Execute(): + let g:changes = [ + \ {'end': {'offset': 16, 'line': 2}, 'newText': "\n\ndef func_ivlpdpao(f):\n exif = exifread.process_file(f)\n dt = str(exif['Image DateTime'])\n date = dt[:10].replace(':', '-')\n return date\n", 'start': {'offset': 16, 'line': 2}}, + \ {'end': {'offset': 32, 'line': 6}, 'newText': 'date = func', 'start': {'offset': 9, 'line': 6}}, + \ {'end': {'offset': 42, 'line': 8}, 'newText': "ivlpdpao(f)\n", 'start': {'offset': 33, 'line': 6}} + \] + + call ale#code_action#ApplyChanges(expand('%:p'), g:changes, 0) + +Expect(The changes should be applied correctly): + import sys + import exifread + + + def func_ivlpdpao(f): + exif = exifread.process_file(f) + dt = str(exif['Image DateTime']) + date = dt[:10].replace(':', '-') + return date + + + def main(): + with open(sys.argv[1], 'rb') as f: + date = func_ivlpdpao(f) |